调整文档,改进设计
This commit is contained in:
		
							
								
								
									
										22
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								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
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### 开发
 | 
			
		||||
先继承处理器跟参数类型,功能稳定后把参数提交给接口
 | 
			
		||||
### 开发建议
 | 
			
		||||
MES与IMES存在不少命名上的差异,可以考虑 接口类型独立, 参数与配置单独创建类型
 | 
			
		||||
							
								
								
									
										37
									
								
								src/base.ts
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								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<string,unknown>){
 | 
			
		||||
        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<TInput,TOutput,TConfig extends ConfigBase> {
 | 
			
		||||
    public readonly name: string = '';
 | 
			
		||||
    public readonly version: string = '1.0.0';
 | 
			
		||||
    public abstract exec(context:ProcessorContext<TInput,TOutput,TConfig>):Promise<void>|void
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface FileOptions {
 | 
			
		||||
    encode?: string;
 | 
			
		||||
    addBOM?: boolean;
 | 
			
		||||
}
 | 
			
		||||
export interface FileInfo extends FileOptions {
 | 
			
		||||
    name: string,
 | 
			
		||||
    content: string | Blob | Uint8Array,
 | 
			
		||||
}
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
export * from './base';
 | 
			
		||||
export * from './processors';
 | 
			
		||||
export * from './parsers';
 | 
			
		||||
export * from './parsers';
 | 
			
		||||
export * from './models/config';
 | 
			
		||||
export * from './models/file';
 | 
			
		||||
							
								
								
									
										28
									
								
								src/models/config.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/models/config.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
/**
 | 
			
		||||
 * 配置基类,下划线开头的变量不会被序列化
 | 
			
		||||
 */
 | 
			
		||||
export class ConfigBase {
 | 
			
		||||
    name: string = '';
 | 
			
		||||
    version:string = '1.0.0';
 | 
			
		||||
    [key: string]: any;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 加载反序列化数据
 | 
			
		||||
     * @param data 
 | 
			
		||||
     */
 | 
			
		||||
    load(data:Record<string,unknown>){
 | 
			
		||||
        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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										8
									
								
								src/models/file.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/models/file.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
export interface FileOptions {
 | 
			
		||||
    encode?: string;
 | 
			
		||||
    addBOM?: boolean;
 | 
			
		||||
}
 | 
			
		||||
export interface FileInfo extends FileOptions {
 | 
			
		||||
    name: string,
 | 
			
		||||
    content: string | Blob | Uint8Array,
 | 
			
		||||
}
 | 
			
		||||
@@ -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: 类型参数待补完
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user