更新编译结果

This commit is contained in:
Yuan 2023-12-14 13:11:42 +08:00
parent eb3d46c037
commit 25aa6ae382
6 changed files with 31 additions and 26 deletions

View File

@ -28,7 +28,7 @@ export declare abstract class GraphicDrawAssistant<GT extends GraphicTemplate, G
/** /**
* id * id
*/ */
nextId(): string; nextId(): number;
clearCache(): void; clearCache(): void;
/** /**
* *

View File

@ -8,12 +8,12 @@ export interface GraphicQueryStore {
/** /**
* id获取图形 * id获取图形
*/ */
queryById<T extends JlGraphic>(id: string): T; queryById<T extends JlGraphic>(id: number | string): T;
/** /**
* id模糊查询图形 * id模糊查询图形
* @param id * @param id
*/ */
queryByIdAmbiguous(id: string): JlGraphic[]; queryByIdAmbiguous(id: number | string): JlGraphic[];
/** /**
* *
*/ */
@ -33,13 +33,13 @@ export interface GraphicQueryStore {
* id或code查询图形 * id或code查询图形
* @param v * @param v
*/ */
queryByIdOrCode(v: string): JlGraphic[]; queryByIdOrCode(v: string | number): JlGraphic[];
/** /**
* id或code及类型查询图形 * id或code及类型查询图形
* @param v * @param v
* @param type * @param type
*/ */
queryByIdOrCodeAndType(v: string, type: string): JlGraphic[]; queryByIdOrCodeAndType(v: string | number, type: string): JlGraphic[];
/** /**
* code和类型获取图形 * code和类型获取图形
* @param code * @param code
@ -57,20 +57,20 @@ export interface GraphicQueryStore {
* *
*/ */
export declare class GraphicStore implements GraphicQueryStore { export declare class GraphicStore implements GraphicQueryStore {
store: Map<string, JlGraphic>; store: Map<number, JlGraphic>;
relationManage: RelationManage; relationManage: RelationManage;
constructor(); constructor();
/** /**
* *
*/ */
getAllGraphics(): JlGraphic[]; getAllGraphics(): JlGraphic[];
queryById<T extends JlGraphic>(id: string): T; queryById<T extends JlGraphic>(id: number | string): T;
queryByIdAmbiguous(id: string): JlGraphic[]; queryByIdAmbiguous(id: number | string): JlGraphic[];
queryByType<T extends JlGraphic>(type: string): T[]; queryByType<T extends JlGraphic>(type: string): T[];
queryByCode(code: string): JlGraphic[] | undefined; queryByCode(code: string): JlGraphic[] | undefined;
queryByCodeAmbiguous(code: string): JlGraphic[]; queryByCodeAmbiguous(code: string): JlGraphic[];
queryByIdOrCode(s: string): JlGraphic[]; queryByIdOrCode(s: string | number): JlGraphic[];
queryByIdOrCodeAndType(s: string, type: string): JlGraphic[]; queryByIdOrCodeAndType(s: string | number, type: string): JlGraphic[];
queryByCodeAndType<T extends JlGraphic>(code: string, type: string): T | undefined; queryByCodeAndType<T extends JlGraphic>(code: string, type: string): T | undefined;
queryByCodeAndTypeAmbiguous<T extends JlGraphic>(code: string, type: string): T[]; queryByCodeAndTypeAmbiguous<T extends JlGraphic>(code: string, type: string): T[];
/** /**

View File

@ -5,7 +5,7 @@ export declare class IdGenerator {
serial: number; serial: number;
type: string; type: string;
constructor(type: string); constructor(type: string);
next(): string; next(): number;
getType(): string; getType(): string;
initSerial(serial: number): void; initSerial(serial: number): void;
} }

View File

@ -38,8 +38,8 @@ export declare class ChildTransform {
* *
*/ */
export interface GraphicData { export interface GraphicData {
get id(): string; get id(): number;
set id(v: string); set id(v: number);
get graphicType(): string; get graphicType(): string;
set graphicType(v: string); set graphicType(v: string);
get transform(): GraphicTransform; get transform(): GraphicTransform;
@ -142,15 +142,15 @@ export declare abstract class JlGraphic extends Container {
/** /**
* id/code * id/code
*/ */
isIdOrCode(s: string): boolean; isIdOrCode(s: string | number): boolean;
/** /**
* idid * idid
*/ */
get id(): string; get id(): number;
/** /**
* idid * idid
*/ */
set id(v: string); set id(v: number);
/** /**
* codecode在图形数据或图形状态中 * codecode在图形数据或图形状态中
*/ */

View File

@ -17,7 +17,8 @@ class IdGenerator {
} }
next() { next() {
++this.serial; ++this.serial;
return this.getType() + this.serial; // console.log(this.getType() + this.serial)
return this.serial;
} }
getType() { getType() {
return this.type; return this.type;
@ -4252,15 +4253,20 @@ class GraphicStore {
return [...this.store.values()]; return [...this.store.values()];
} }
queryById(id) { queryById(id) {
const graphic = this.store.get(id); let nid = id;
if (typeof id === 'string') {
nid = parseInt(id);
}
const graphic = this.store.get(nid);
if (!graphic) if (!graphic)
throw Error(`未找到id为 [${id}] 的图形.`); throw Error(`未找到id为 [${nid}] 的图形.`);
return this.store.get(id); return this.store.get(nid);
} }
queryByIdAmbiguous(id) { queryByIdAmbiguous(id) {
const nid = id + '';
const list = []; const list = [];
this.store.forEach((g) => { this.store.forEach((g) => {
if (g.id.search(id) >= 0) { if ((g.id + '').search(nid) >= 0) {
list.push(g); list.push(g);
} }
}); });
@ -4332,7 +4338,7 @@ class GraphicStore {
* @param graphics 要存储的图形 * @param graphics 要存储的图形
*/ */
storeGraphics(graphic) { storeGraphics(graphic) {
if (!graphic.id || graphic.id.trim() === '') { if (!graphic.id || graphic.id === 0) {
throw new Error(`存储图形对象异常: id为空, ${graphic}`); throw new Error(`存储图形对象异常: id为空, ${graphic}`);
} }
if (this.store.has(graphic.id)) { if (this.store.has(graphic.id)) {
@ -4783,7 +4789,7 @@ class GraphicAnimation {
class JlGraphic extends Container { class JlGraphic extends Container {
__JlGraphic = true; __JlGraphic = true;
type; // 图形类型 type; // 图形类型
_id = ''; // 图形的唯一标识,不具有业务意义,唯一,不可重复,可用做图形数据关联。 _id = 0; // 图形的唯一标识,不具有业务意义,唯一,不可重复,可用做图形数据关联。
_code = ''; // 业务编号/名称,用于标识图形对象,具有业务意义 _code = ''; // 业务编号/名称,用于标识图形对象,具有业务意义
_datas; // 图形数据 _datas; // 图形数据
_states; // 图形状态数据 _states; // 图形状态数据
@ -6770,8 +6776,7 @@ class GraphicSceneBase extends EventEmitter {
// 更新id生成器 // 更新id生成器
const max = this.queryStore const max = this.queryStore
.getAllGraphics() .getAllGraphics()
.filter((g) => !isNaN(parseInt(g.id))) .map((g) => g.id)
.map((g) => parseInt(g.id))
.sort((a, b) => a - b) .sort((a, b) => a - b)
.pop() ?? 0; .pop() ?? 0;
GraphicIdGenerator.initSerial(max); GraphicIdGenerator.initSerial(max);

View File

@ -9,7 +9,7 @@ export declare class AnimationManager {
/** /**
* key - graphic.id * key - graphic.id
*/ */
graphicAnimationMap: Map<string, Map<string, GraphicAnimation>>; graphicAnimationMap: Map<number, Map<string, GraphicAnimation>>;
constructor(app: IGraphicScene); constructor(app: IGraphicScene);
private run; private run;
pause(): void; pause(): void;