diff --git a/README.md b/README.md index 4d6e6bf..d6ddef4 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,15 @@ 本项目使用typescript编写,IDE推荐使用vscode。 ### 术语表 -| 中文 | CAD | MES | IMES | 接口 | 备注 | -| --- | --- | --- | ---| --- | --- | -| 房名 | RoomName | RoomName | roomName | -| 柜名 | CabinetName | BoxName | bodyName | -| 小板名 | BoardName | BlockName | blockName | -| 材质 | Material | Material | material | | -| 大板名 | 无 | BoardName | goodsName | | -| 余料 | 无 | remain/scrap | remain | -| 排单 | 无 | PlanOrder |planOrder | +| 中文 | CAD | MES | IMES | 备注 | +| --- | --- | --- | --- | --- | +| 房名 | RoomName | roomName | roomName | | +| 柜名 | CabinetName | boxName | bodyName | | +| 小板名 | BoardName | blockName | blockName | | +| 材质 | Material | material | material | | +| 大板名 | 无 | boardName | goodsName | | +| 余料 | 无 | scrap | remain | | +| 排单 | 无 | planOrder |planOrder | | ### 编译与发布 @@ -21,5 +21,5 @@ pnpm build pnpm release ``` -### 开发 -先继承处理器跟参数类型,功能稳定后把参数提交给接口 \ No newline at end of file +### 开发建议 +MES与IMES存在不少命名上的差异,可以考虑 接口类型独立, 参数与配置单独创建类型 \ No newline at end of file diff --git a/src/base.ts b/src/base.ts index 583544d..9fead46 100644 --- a/src/base.ts +++ b/src/base.ts @@ -1,31 +1,5 @@ -/** - * 配置基类,下划线开头的变量不会被序列化 - */ -export class ConfigBase { - name: string = ''; - version:string = '1.0.0'; - [key: string]: any; +import { ConfigBase } from "./models/config"; - /** - * 加载反序列化数据 - * @param data - */ - load(data:Record){ - for (const key of Object.getOwnPropertyNames(this).filter(i=>i[0]!=='_')) { - if(data[key]!=undefined){ - this[key] = data[key]; - } - } - } - - /** - * 序列化json方法 - * @returns - */ - toJson(){ - return JSON.stringify(this,(k,v)=>k[0]=='_'?undefined:v); - } -} /** * 加工处理器上下文 @@ -52,13 +26,4 @@ export abstract class ProcessorBase { public readonly name: string = ''; public readonly version: string = '1.0.0'; public abstract exec(context:ProcessorContext):Promise|void -} - -export interface FileOptions { - encode?: string; - addBOM?: boolean; -} -export interface FileInfo extends FileOptions { - name: string, - content: string | Blob | Uint8Array, } \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index fe7dcf9..21be42b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,4 @@ export * from './base'; -export * from './processors'; -export * from './parsers'; \ No newline at end of file +export * from './parsers'; +export * from './models/config'; +export * from './models/file'; \ No newline at end of file diff --git a/src/models/config.ts b/src/models/config.ts new file mode 100644 index 0000000..ee9b495 --- /dev/null +++ b/src/models/config.ts @@ -0,0 +1,28 @@ +/** + * 配置基类,下划线开头的变量不会被序列化 + */ +export class ConfigBase { + name: string = ''; + version:string = '1.0.0'; + [key: string]: any; + + /** + * 加载反序列化数据 + * @param data + */ + load(data:Record){ + for (const key of Object.getOwnPropertyNames(this).filter(i=>i[0]!=='_')) { + if(data[key]!=undefined){ + this[key] = data[key]; + } + } + } + + /** + * 序列化json方法 + * @returns + */ + toJson(){ + return JSON.stringify(this,(k,v)=>k[0]=='_'?undefined:v); + } +} \ No newline at end of file diff --git a/src/models/file.ts b/src/models/file.ts new file mode 100644 index 0000000..322b403 --- /dev/null +++ b/src/models/file.ts @@ -0,0 +1,8 @@ +export interface FileOptions { + encode?: string; + addBOM?: boolean; +} +export interface FileInfo extends FileOptions { + name: string, + content: string | Blob | Uint8Array, +} \ No newline at end of file diff --git a/src/processors.ts b/src/processors.ts index be842aa..88f6293 100644 --- a/src/processors.ts +++ b/src/processors.ts @@ -1,4 +1,6 @@ -import { ConfigBase, FileInfo, ProcessorBase } from "./base"; +import { ProcessorBase } from "./base"; +import { ConfigBase } from "./models/config"; +import { FileInfo } from "./models/file"; // todo: 类型参数待补完