mirror of
https://github.com/Gongxh0901/kunpolibrary
synced 2025-07-30 03:48:42 +00:00
feat: 优化UI组件和窗口资源管理
- **ComponentExtendHelper:** 增加了对重复注册组件的检查和跳过逻辑,避免重复处理。 - **WindowResPool:** 优化了资源添加逻辑,对于已存在的资源不再抛出错误。 - **package.json:** 版本号更新至 。
This commit is contained in:
parent
80ebeafcb9
commit
c77e047fe7
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "kunpocc",
|
||||
"version": "1.1.6",
|
||||
"version": "1.1.7",
|
||||
"description": "基于creator3.0+的kunpocc库",
|
||||
"main": "./dist/kunpocc.cjs",
|
||||
"module": "./dist/kunpocc.mjs",
|
||||
|
@ -9,10 +9,19 @@ import { PropsHelper } from "./PropsHelper";
|
||||
import { _uidecorator } from "./UIDecorator";
|
||||
|
||||
export class ComponentExtendHelper {
|
||||
/** 已注册的组件集合 @internal */
|
||||
private static _registeredComponents: Set<string> = new Set<string>();
|
||||
|
||||
public static register(): void {
|
||||
for (const { ctor, res } of _uidecorator.getComponentMaps().values()) {
|
||||
const componentKey = `${res.pkg}/${res.name}`;
|
||||
if (this._registeredComponents.has(componentKey)) {
|
||||
debug(`自定义组件已注册,跳过 组件名:${res.name} 包名:${res.pkg}`);
|
||||
continue;
|
||||
}
|
||||
debug(`自定义组件注册 组件名:${res.name} 包名:${res.pkg}`);
|
||||
this.registerComponent(ctor, res.pkg, res.name);
|
||||
this._registeredComponents.add(componentKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ export class WindowResPool {
|
||||
*/
|
||||
public add(ctor: any, group: string, pkg: string, name: string): void {
|
||||
if (this.has(name)) {
|
||||
throw new Error(`窗口【${name}】信息已注册 请勿重复注册`);
|
||||
return;
|
||||
}
|
||||
this._windowInfos.set(name, {
|
||||
ctor: ctor,
|
||||
@ -89,6 +89,9 @@ export class WindowResPool {
|
||||
* @param info
|
||||
*/
|
||||
public addHeader(ctor: any, pkg: string, name: string): void {
|
||||
if (this.hasHeader(name)) {
|
||||
return;
|
||||
}
|
||||
this._headerInfos.set(name, {
|
||||
ctor: ctor,
|
||||
pkg: pkg
|
||||
|
Loading…
x
Reference in New Issue
Block a user