@gct-paas/core 0.1.5-dev.7 → 0.1.5-dev.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.min.js +1 -1
- package/es/index.mjs +3 -2
- package/es/router/index.mjs +1 -1
- package/es/utils/i18n/index.mjs +3 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.mjs +1 -0
- package/es/utils/script-loader/script-loader.d.ts +62 -0
- package/es/utils/script-loader/script-loader.mjs +92 -0
- package/es/utils/style/index.d.ts +8 -0
- package/es/utils/style/index.mjs +67 -1
- package/package.json +3 -3
package/es/index.mjs
CHANGED
|
@@ -59,7 +59,7 @@ import { afterFieldSet, afterValueSet, cacheFnReturn, computedEx, emitFieldSet,
|
|
|
59
59
|
import { interceptors } from "./utils/axios/interceptors.mjs";
|
|
60
60
|
import { getDeviceFingerprint, getMobileBrowserFingerprint, getPageIdentification } from "./utils/deviceFingerprint.mjs";
|
|
61
61
|
import { TreeHelper } from "./utils/treeHelper/treeHelper.mjs";
|
|
62
|
-
import { calcFontStyle, calcStyle } from "./utils/style/index.mjs";
|
|
62
|
+
import { calcFontStyle, calcStyle, calcStylePX } from "./utils/style/index.mjs";
|
|
63
63
|
import { deleteAndInsertArr, genUrl, openWindow } from "./utils/util.mjs";
|
|
64
64
|
import { isSortFiled } from "./utils/is-sort-filed/is-sort-filed.mjs";
|
|
65
65
|
import { randomUUID, useUUid } from "./utils/useUUid.mjs";
|
|
@@ -70,6 +70,7 @@ import { downloadByBase64, downloadByData, downloadByOnlineUrl, downloadByUrl, u
|
|
|
70
70
|
import { sizeParser, typeParser } from "./utils/file/parser.mjs";
|
|
71
71
|
import { isMultipleOperator } from "./utils/design/design.mjs";
|
|
72
72
|
import { TextMeasureUtil, getMaxTextWidth, getMinTextWidth, getTotalTextWidth, measureText, measureTexts, truncateText } from "./utils/text-measure/text-measure.mjs";
|
|
73
|
+
import { scriptLoader } from "./utils/script-loader/script-loader.mjs";
|
|
73
74
|
import { permission } from "./utils/permission.mjs";
|
|
74
75
|
import { getVueComponentByCode } from "./utils/vue-component-code.mjs";
|
|
75
76
|
import "./utils/index.mjs";
|
|
@@ -136,4 +137,4 @@ function onInit() {
|
|
|
136
137
|
}
|
|
137
138
|
onInit();
|
|
138
139
|
//#endregion
|
|
139
|
-
export { AGLINE_ENUMS, APP_DARK_MODE_KEY_, APP_INST, APP_LOCAL_CACHE_KEY, APP_PREVIEW_PATH_REG, APP_PROD_PATH_REG, APP_RUN_PATH_REG, APP_SESSION_CACHE_KEY, ARRAY_TYPE, ASSIGNMENTSTRATEGY_ENUM, AggTypes, AppPublishStateEnum, BOOLEAN_TYPE, BasicAction, BindCmpStyleEnum, BindCmpStyleTypeEnum, BizServiceEnum, BorderStyle, BpmnNodeTypeEnum, BuiltOperators, BuiltinType, ButtonColorTheme, ButtonColorType, ButtonGroupType, ButtonOpeEnum, ButtonSize, ButtonStyle, ButtonType, ButtonTypeEnum, ButtonTypeGroup, ButtonType_vant, CARD_TRIGGER_ENUM, COLUMNS_TYPE, CURRENCY_ENUM, CURRENCY_LANG_ENUM, CUSTOM_LANGUAGE, CUSTOM_THEME, CacheTypeEnum, CategoryTypeEnum, Ch_BindCmpStyleEnum, ContentEnum, ContentTypeEnum, CoreConst, CreateType, CustomAction, DEFAULT_MQTT_INSTANCE_ID, DESIGNER_SESSION_CACHE_KEY, DEV_SINGLE_PATH_REG, DataSetReturnTypeEnum, DatasourceTypeEnum, DateRangeEnums, DefaultActions, DefaultDateTypeConst, Dependency_ENUM, DeployModeEnum, DeviceParamsTypeEnum, DictionaryUtil, DisplayEnums, DisplayTagTypeEnum, DisplayType, EditorRegisterConst, EntityFormulaReturnTypeEnum, EntityModelCategoryEnum, EntityModelTypeEnum, EnvironmentManager, EnvironmentType, ErrorHandler, ErrorStrategyFactory, ErrorTypeEnum, EventCategory, ExamineAndApproveStateEnum, ExceptionEnum, ExpressionModeEnum, ExpressionTabEnum, FIELD_TYPE, FIELD_TYPE_BASIC, FIELD_TYPE_CATEGORY, FIELD_TYPE_LOGIC, FIELD_TYPE_TRACE, FUNC_KEYS, FUN_BOL_TYPE, FUN_NUM_TYPE, FUN_OBJ_OR_ARR_TYPE, FUN_STR_TYPE, FieldDefaultValueTypeEnum, FieldIconMap, FieldSysVarDefaultValueEnum, FieldTypeToJs, FormComponents, FormContainerType, FormDesignEnum, GENDER_TYPE, GLOBAL_TYPE, GLOBAL_VAR_TYPE, GctGlobal, GctMqttTopsEnum, GlobalParamEnum, GlobalStoreUtil, HOST_REG, INNER_EVENT, IP_REG, IdentifierAddon, KeyMode, KickRuleEnum, KitPkgUtil, LOCALE_KEY, LOCALE_LIST_KEY, LOCAL_I18N_TRANSLATE, LOCK_INFO_KEY, LinkedList, LinkedNode, ListTreeSearchTypeEnum, LocaleUtil, LoginSortTypeEnum, LoginTypeEnum, MENU_COLLAPSED_WIDTH, MENU_WIDTH_RANGE, MQTT_CLIENT_EVENT, MQTT_DEFAULT_CONNECT_OPTIONS, MULTIPLE_TABS_KEY, MaterialEnum, MenuModeEnum, MenuSplitTyeEnum, MenuType, MenuTypeEnum, MessageType, MixSidebarTriggerEnum, Modal, ModeFnMap, ModeTabDict, ModeTabMap, ModelFieldEnum, ModelTypeOptions, MqttClient, MqttConnectionStatus, MqttManager, NUMBER_TYPE, Namespace, NodesConfigTypeEnum, OBJECT_TYPE, OTHER_LOGIN_KEYS, OpenMode, OperatorTypeEnum, OpinionTypeEnum, OverlayContainer, OverlayPopoverContainer, PLUGIN_BASE_URL, PROJ_CFG_KEY, PageEnum, PanelEnum, PassRule, PatternEnum, PermissionModeEnum, PersonalCenterType, Platform, PlatformSettingActions, PlatformSettingEnum, PlatformType, PluginModeEnum, PluginPgkUtil, PluginStaticResource, Postion, PrintModeEnums, PrintResourceEnum, PrintTypeEnum, ProcessStatusEnum, ProgressTypeEnum, ProjectName, PropGroup, REDIRECT_NAME, RELATION_FIELDS, RETURN_TYPE_MAP, ROLES_KEY, RdoButtonOpeEnum, RequestEnum, ResetConditionEnum, ResetRuleType, ResultEnum, ReturnTypeEnum, ReturnTypeMaps, RoleEnum, RouterTransitionEnum, RowSelectionTypeEnums, SCOPE, SCOPEINFO, SEARCH_SERVICE, SHOW_FIELDTYPES, SIDE_BAR_MINI_WIDTH, SIDE_BAR_SHOW_TIT_MINI_WIDTH, STRING_TYPE, STYLE_NAMESPACE_TAG, SUB_TABLE_EDIT_MODE, SUB_TABLE_OPE_EVENT_TYPE, SUB_TABLE_OPE_EVENT_TYPE_INLINE, SYSTEM_FIELD_KEY, SYSTEM_LOGIN_KEYS, SYSTEM_VAR_PREFIX, SearchComponents, SelectPickerEnums, SessionTimeoutProcessingEnum, SettingButtonPositionEnum, SignatureStyleEnum, SignatureTypeEnum, SizeEnum, StatisticalMethodEnums, StyleGroup, TENANT_KEY, TEST_SINGLE_PATH_REG, THEME_COLORS, TIMETYPE_ENUM, TIMETYPE_LANG_ENUM, TODO_TYPE, TOKEN_KEY, TableEditingMethodEnum, TableSearchTypeEnum, TableTypeEnum, TagTypeEnum, TextAlign, TextDecoration, TextMeasureUtil, ThemeEnum, ToolkitEnum, TopMenuAlignEnum, TransactionMode, TreeHelper, TriggerEnum, TypeEnum, USER_INFO_KEY, UniqueConstraintType, UploadTypeEnum, Uploader, UserServiceType, VERIFICATIONCONDITIONS_TYPE, VITE_MINIO_PATH, VarTypeEnum, WATERMARK_INIT_DATA, WidgetInScopeEnum, WinMsgTypeEnum, WorkbenchType, afterFieldSet, afterValueSet, allOperator, biBackFunctionGroup, biBackFunctionMap, bindCmpStyleMap, booleanOperator, booleanTypes, buildItemRules, buildShortUUID, buildUUID, buttonShowType, cacheFnReturn, calcFontStyle, calcStyle, ch_ProcessStatusMap, computedEx, controlConfigEnum, copyTextToClipboard, createAppVue, createWhiteImageWithText, cssLoader, dataURLtoBlob, deepMerge, deleteAndInsertArr, downloadByBase64, downloadByData, downloadByOnlineUrl, downloadByUrl, emitFieldSet, fileUrlParser, fixedAlignENUM, functionGroup, functionMap, gctMemoizeAsync, genUrl, getDeviceFingerprint, getLoginTypeOptions, getMaxTextWidth, getMinTextWidth, getMobileBrowserFingerprint, getOperatorList, getPageIdentification, getSeriesList, getTenant, getToken, getTotalTextWidth, getVueComponentByCode, globalRefSession, globalRefStorage, hasEmojiAndSpecStr, hasEmojiAndSpecStr1, innerVarIds, innerVarList, insertCustomCssToHead, interceptors, ipaasBackFunctionGroup, ipaasBackFunctionMap, isDef, isMobile, isMultipleOperator, isSortFiled, measureText, measureTexts, mitt, mobileSearchListByFieldType, modelLoader, notSingleArr, nullDisplayEnum, numberOperator, numberTypes, openWindow, openWindowEnums, operateSysEnums, operator2FuncMap, padSearchListByFieldType, pageLayoutModeEnum, parseMatrixParams, parseValueUnit, permission, presetColor, randomUUID, returnBolOperator, screenEnum, screenMap, scriptTypeEnum, searchListByFieldType, selectionTypeEnums, setTenant, setToken, setupApp, setupErrorHandler, setupI18n, sha256, sizeEnum, sizeParser, sortTypeEnum, statisticalMethodEnum, stringifyMatrixParams, t, tableColumnTypeEnum, tableColumnWidthEnum, tabsTypeENUM, tagEnum, timeReg, transformBindCmp2CmpType, transformUrl, truncateText, typeParser, uploaderFiles, urlReg, urlToBase64, useAppInst, useCopyToClipboard, useIFrameProps, useModal, useNamespace, usePermissionStore, usePlatformConfigStore, useTenantStore, useUUid, useUserStore, useWuJieBus, useWuJieProps, uuid2, validateEmoji, validateIsModelName, validateModelName, zeroWidthSpace };
|
|
140
|
+
export { AGLINE_ENUMS, APP_DARK_MODE_KEY_, APP_INST, APP_LOCAL_CACHE_KEY, APP_PREVIEW_PATH_REG, APP_PROD_PATH_REG, APP_RUN_PATH_REG, APP_SESSION_CACHE_KEY, ARRAY_TYPE, ASSIGNMENTSTRATEGY_ENUM, AggTypes, AppPublishStateEnum, BOOLEAN_TYPE, BasicAction, BindCmpStyleEnum, BindCmpStyleTypeEnum, BizServiceEnum, BorderStyle, BpmnNodeTypeEnum, BuiltOperators, BuiltinType, ButtonColorTheme, ButtonColorType, ButtonGroupType, ButtonOpeEnum, ButtonSize, ButtonStyle, ButtonType, ButtonTypeEnum, ButtonTypeGroup, ButtonType_vant, CARD_TRIGGER_ENUM, COLUMNS_TYPE, CURRENCY_ENUM, CURRENCY_LANG_ENUM, CUSTOM_LANGUAGE, CUSTOM_THEME, CacheTypeEnum, CategoryTypeEnum, Ch_BindCmpStyleEnum, ContentEnum, ContentTypeEnum, CoreConst, CreateType, CustomAction, DEFAULT_MQTT_INSTANCE_ID, DESIGNER_SESSION_CACHE_KEY, DEV_SINGLE_PATH_REG, DataSetReturnTypeEnum, DatasourceTypeEnum, DateRangeEnums, DefaultActions, DefaultDateTypeConst, Dependency_ENUM, DeployModeEnum, DeviceParamsTypeEnum, DictionaryUtil, DisplayEnums, DisplayTagTypeEnum, DisplayType, EditorRegisterConst, EntityFormulaReturnTypeEnum, EntityModelCategoryEnum, EntityModelTypeEnum, EnvironmentManager, EnvironmentType, ErrorHandler, ErrorStrategyFactory, ErrorTypeEnum, EventCategory, ExamineAndApproveStateEnum, ExceptionEnum, ExpressionModeEnum, ExpressionTabEnum, FIELD_TYPE, FIELD_TYPE_BASIC, FIELD_TYPE_CATEGORY, FIELD_TYPE_LOGIC, FIELD_TYPE_TRACE, FUNC_KEYS, FUN_BOL_TYPE, FUN_NUM_TYPE, FUN_OBJ_OR_ARR_TYPE, FUN_STR_TYPE, FieldDefaultValueTypeEnum, FieldIconMap, FieldSysVarDefaultValueEnum, FieldTypeToJs, FormComponents, FormContainerType, FormDesignEnum, GENDER_TYPE, GLOBAL_TYPE, GLOBAL_VAR_TYPE, GctGlobal, GctMqttTopsEnum, GlobalParamEnum, GlobalStoreUtil, HOST_REG, INNER_EVENT, IP_REG, IdentifierAddon, KeyMode, KickRuleEnum, KitPkgUtil, LOCALE_KEY, LOCALE_LIST_KEY, LOCAL_I18N_TRANSLATE, LOCK_INFO_KEY, LinkedList, LinkedNode, ListTreeSearchTypeEnum, LocaleUtil, LoginSortTypeEnum, LoginTypeEnum, MENU_COLLAPSED_WIDTH, MENU_WIDTH_RANGE, MQTT_CLIENT_EVENT, MQTT_DEFAULT_CONNECT_OPTIONS, MULTIPLE_TABS_KEY, MaterialEnum, MenuModeEnum, MenuSplitTyeEnum, MenuType, MenuTypeEnum, MessageType, MixSidebarTriggerEnum, Modal, ModeFnMap, ModeTabDict, ModeTabMap, ModelFieldEnum, ModelTypeOptions, MqttClient, MqttConnectionStatus, MqttManager, NUMBER_TYPE, Namespace, NodesConfigTypeEnum, OBJECT_TYPE, OTHER_LOGIN_KEYS, OpenMode, OperatorTypeEnum, OpinionTypeEnum, OverlayContainer, OverlayPopoverContainer, PLUGIN_BASE_URL, PROJ_CFG_KEY, PageEnum, PanelEnum, PassRule, PatternEnum, PermissionModeEnum, PersonalCenterType, Platform, PlatformSettingActions, PlatformSettingEnum, PlatformType, PluginModeEnum, PluginPgkUtil, PluginStaticResource, Postion, PrintModeEnums, PrintResourceEnum, PrintTypeEnum, ProcessStatusEnum, ProgressTypeEnum, ProjectName, PropGroup, REDIRECT_NAME, RELATION_FIELDS, RETURN_TYPE_MAP, ROLES_KEY, RdoButtonOpeEnum, RequestEnum, ResetConditionEnum, ResetRuleType, ResultEnum, ReturnTypeEnum, ReturnTypeMaps, RoleEnum, RouterTransitionEnum, RowSelectionTypeEnums, SCOPE, SCOPEINFO, SEARCH_SERVICE, SHOW_FIELDTYPES, SIDE_BAR_MINI_WIDTH, SIDE_BAR_SHOW_TIT_MINI_WIDTH, STRING_TYPE, STYLE_NAMESPACE_TAG, SUB_TABLE_EDIT_MODE, SUB_TABLE_OPE_EVENT_TYPE, SUB_TABLE_OPE_EVENT_TYPE_INLINE, SYSTEM_FIELD_KEY, SYSTEM_LOGIN_KEYS, SYSTEM_VAR_PREFIX, SearchComponents, SelectPickerEnums, SessionTimeoutProcessingEnum, SettingButtonPositionEnum, SignatureStyleEnum, SignatureTypeEnum, SizeEnum, StatisticalMethodEnums, StyleGroup, TENANT_KEY, TEST_SINGLE_PATH_REG, THEME_COLORS, TIMETYPE_ENUM, TIMETYPE_LANG_ENUM, TODO_TYPE, TOKEN_KEY, TableEditingMethodEnum, TableSearchTypeEnum, TableTypeEnum, TagTypeEnum, TextAlign, TextDecoration, TextMeasureUtil, ThemeEnum, ToolkitEnum, TopMenuAlignEnum, TransactionMode, TreeHelper, TriggerEnum, TypeEnum, USER_INFO_KEY, UniqueConstraintType, UploadTypeEnum, Uploader, UserServiceType, VERIFICATIONCONDITIONS_TYPE, VITE_MINIO_PATH, VarTypeEnum, WATERMARK_INIT_DATA, WidgetInScopeEnum, WinMsgTypeEnum, WorkbenchType, afterFieldSet, afterValueSet, allOperator, biBackFunctionGroup, biBackFunctionMap, bindCmpStyleMap, booleanOperator, booleanTypes, buildItemRules, buildShortUUID, buildUUID, buttonShowType, cacheFnReturn, calcFontStyle, calcStyle, calcStylePX, ch_ProcessStatusMap, computedEx, controlConfigEnum, copyTextToClipboard, createAppVue, createWhiteImageWithText, cssLoader, dataURLtoBlob, deepMerge, deleteAndInsertArr, downloadByBase64, downloadByData, downloadByOnlineUrl, downloadByUrl, emitFieldSet, fileUrlParser, fixedAlignENUM, functionGroup, functionMap, gctMemoizeAsync, genUrl, getDeviceFingerprint, getLoginTypeOptions, getMaxTextWidth, getMinTextWidth, getMobileBrowserFingerprint, getOperatorList, getPageIdentification, getSeriesList, getTenant, getToken, getTotalTextWidth, getVueComponentByCode, globalRefSession, globalRefStorage, hasEmojiAndSpecStr, hasEmojiAndSpecStr1, innerVarIds, innerVarList, insertCustomCssToHead, interceptors, ipaasBackFunctionGroup, ipaasBackFunctionMap, isDef, isMobile, isMultipleOperator, isSortFiled, measureText, measureTexts, mitt, mobileSearchListByFieldType, modelLoader, notSingleArr, nullDisplayEnum, numberOperator, numberTypes, openWindow, openWindowEnums, operateSysEnums, operator2FuncMap, padSearchListByFieldType, pageLayoutModeEnum, parseMatrixParams, parseValueUnit, permission, presetColor, randomUUID, returnBolOperator, screenEnum, screenMap, scriptLoader, scriptTypeEnum, searchListByFieldType, selectionTypeEnums, setTenant, setToken, setupApp, setupErrorHandler, setupI18n, sha256, sizeEnum, sizeParser, sortTypeEnum, statisticalMethodEnum, stringifyMatrixParams, t, tableColumnTypeEnum, tableColumnWidthEnum, tabsTypeENUM, tagEnum, timeReg, transformBindCmp2CmpType, transformUrl, truncateText, typeParser, uploaderFiles, urlReg, urlToBase64, useAppInst, useCopyToClipboard, useIFrameProps, useModal, useNamespace, usePermissionStore, usePlatformConfigStore, useTenantStore, useUUid, useUserStore, useWuJieBus, useWuJieProps, uuid2, validateEmoji, validateIsModelName, validateModelName, zeroWidthSpace };
|
package/es/router/index.mjs
CHANGED
|
@@ -18,7 +18,7 @@ var RouterUtil = class {
|
|
|
18
18
|
async add(route) {
|
|
19
19
|
if (Array.isArray(route)) route.forEach((r) => this.router.addRoute(r));
|
|
20
20
|
else this.router.addRoute(route);
|
|
21
|
-
if (
|
|
21
|
+
if (!this.router.currentRoute.value.name) await this.router.replace(this.router.currentRoute.value.fullPath);
|
|
22
22
|
}
|
|
23
23
|
/**刷新当前路由 */
|
|
24
24
|
async redo() {
|
package/es/utils/i18n/index.mjs
CHANGED
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
* @returns {*} {string}
|
|
11
11
|
*/
|
|
12
12
|
var t = (...args) => {
|
|
13
|
+
if (!args || args.length === 0) return "";
|
|
14
|
+
const key = args[0];
|
|
15
|
+
if (!key || typeof key !== "string" || key.trim() === "") return "";
|
|
13
16
|
return _gct.i18n.global.t(...args);
|
|
14
17
|
};
|
|
15
18
|
//#endregion
|
package/es/utils/index.d.ts
CHANGED
|
@@ -30,5 +30,6 @@ export * from './file/base64Conver';
|
|
|
30
30
|
export * from './file/parser';
|
|
31
31
|
export * from './design/design';
|
|
32
32
|
export * from './text-measure/text-measure';
|
|
33
|
+
export { scriptLoader, type IScriptOptions, } from './script-loader/script-loader';
|
|
33
34
|
export { permission } from './permission';
|
|
34
35
|
export { getVueComponentByCode } from './vue-component-code';
|
package/es/utils/index.mjs
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Script 动态加载工具类
|
|
3
|
+
*
|
|
4
|
+
* 从 CDN 动态加载 JS 脚本文件,具备以下特性:
|
|
5
|
+
* - 已成功加载的路径永久缓存,避免重复插入 script 标签
|
|
6
|
+
* - 同一时刻对同一路径的多次调用共享同一个 Promise(请求去重)
|
|
7
|
+
* - 加载失败不写入缓存,允许下次重试
|
|
8
|
+
* - 加载前检查 DOM 中是否已存在相同 src 的 script 标签
|
|
9
|
+
* - 支持配置 async、defer、crossOrigin、type 等脚本属性
|
|
10
|
+
*
|
|
11
|
+
* @author chitanda
|
|
12
|
+
* @date 2026-04-17
|
|
13
|
+
*/
|
|
14
|
+
/** Script 加载选项 */
|
|
15
|
+
export interface IScriptOptions {
|
|
16
|
+
/** 是否异步加载,默认 true */
|
|
17
|
+
async?: boolean;
|
|
18
|
+
/** 是否延迟加载 */
|
|
19
|
+
defer?: boolean;
|
|
20
|
+
/** 跨域属性 */
|
|
21
|
+
crossOrigin?: 'anonymous' | 'use-credentials';
|
|
22
|
+
/** 脚本 MIME 类型,默认 'text/javascript' */
|
|
23
|
+
type?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Script 动态加载工具类
|
|
27
|
+
*
|
|
28
|
+
* @class ScriptLoader
|
|
29
|
+
*/
|
|
30
|
+
declare class ScriptLoader {
|
|
31
|
+
/** 已成功加载的脚本 URL 集合(永久缓存) */
|
|
32
|
+
private _loadedSet;
|
|
33
|
+
/** 正在加载中的脚本 URL 对应的 Promise(用于请求去重) */
|
|
34
|
+
private _pendingMap;
|
|
35
|
+
/**
|
|
36
|
+
* 动态加载单个 JS 脚本文件
|
|
37
|
+
*
|
|
38
|
+
* 同一 URL 只会加载一次,首次调用时的 options 生效。
|
|
39
|
+
*
|
|
40
|
+
* @param {string} url 脚本文件的完整 URL
|
|
41
|
+
* @param {IScriptOptions} [options] 脚本加载选项
|
|
42
|
+
* @returns {Promise<void>} 加载完成后 resolve;加载失败则 reject
|
|
43
|
+
*/
|
|
44
|
+
load(url: string, options?: IScriptOptions): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* 加载 ExcelJS 库
|
|
47
|
+
*
|
|
48
|
+
* @return {*} {Promise<IObject>}
|
|
49
|
+
*/
|
|
50
|
+
loadExcelsJs(): Promise<IObject>;
|
|
51
|
+
/**
|
|
52
|
+
* 并发加载多个 JS 脚本文件
|
|
53
|
+
*
|
|
54
|
+
* @param {string[]} urls 脚本文件 URL 列表
|
|
55
|
+
* @param {IScriptOptions} [options] 脚本加载选项,对所有 URL 生效
|
|
56
|
+
* @returns {Promise<void>} 所有文件均加载完成后 resolve;任一失败则 reject
|
|
57
|
+
*/
|
|
58
|
+
loadBatch(urls: string[], options?: IScriptOptions): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
/** Script 动态加载工具单例 */
|
|
61
|
+
export declare const scriptLoader: ScriptLoader;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//#region src/utils/script-loader/script-loader.ts
|
|
2
|
+
/**
|
|
3
|
+
* Script 动态加载工具类
|
|
4
|
+
*
|
|
5
|
+
* @class ScriptLoader
|
|
6
|
+
*/
|
|
7
|
+
var ScriptLoader = class {
|
|
8
|
+
/** 已成功加载的脚本 URL 集合(永久缓存) */
|
|
9
|
+
_loadedSet = /* @__PURE__ */ new Set();
|
|
10
|
+
/** 正在加载中的脚本 URL 对应的 Promise(用于请求去重) */
|
|
11
|
+
_pendingMap = /* @__PURE__ */ new Map();
|
|
12
|
+
/**
|
|
13
|
+
* 动态加载单个 JS 脚本文件
|
|
14
|
+
*
|
|
15
|
+
* 同一 URL 只会加载一次,首次调用时的 options 生效。
|
|
16
|
+
*
|
|
17
|
+
* @param {string} url 脚本文件的完整 URL
|
|
18
|
+
* @param {IScriptOptions} [options] 脚本加载选项
|
|
19
|
+
* @returns {Promise<void>} 加载完成后 resolve;加载失败则 reject
|
|
20
|
+
*/
|
|
21
|
+
load(url, options) {
|
|
22
|
+
if (this._loadedSet.has(url)) return Promise.resolve();
|
|
23
|
+
if (this._pendingMap.has(url)) return this._pendingMap.get(url);
|
|
24
|
+
if (typeof document !== "undefined") {
|
|
25
|
+
const escaped = CSS.escape ? CSS.escape(url) : url;
|
|
26
|
+
if (document.querySelector(`script[src="${escaped}"]`)) {
|
|
27
|
+
this._loadedSet.add(url);
|
|
28
|
+
return Promise.resolve();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const promise = new Promise((resolve, reject) => {
|
|
32
|
+
if (typeof document === "undefined") {
|
|
33
|
+
reject(/* @__PURE__ */ new Error(`[ScriptLoader] 当前环境不支持 DOM,无法加载脚本: ${url}`));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const script = document.createElement("script");
|
|
37
|
+
script.src = url;
|
|
38
|
+
script.type = options?.type ?? "text/javascript";
|
|
39
|
+
script.async = options?.async ?? true;
|
|
40
|
+
if (options?.defer !== void 0) script.defer = options.defer;
|
|
41
|
+
if (options?.crossOrigin !== void 0) script.crossOrigin = options.crossOrigin;
|
|
42
|
+
/** 加载成功回调 */
|
|
43
|
+
const onLoad = () => {
|
|
44
|
+
cleanup();
|
|
45
|
+
this._loadedSet.add(url);
|
|
46
|
+
this._pendingMap.delete(url);
|
|
47
|
+
resolve();
|
|
48
|
+
};
|
|
49
|
+
/** 加载失败回调 */
|
|
50
|
+
const onError = () => {
|
|
51
|
+
cleanup();
|
|
52
|
+
this._pendingMap.delete(url);
|
|
53
|
+
const err = /* @__PURE__ */ new Error(`[ScriptLoader] 脚本文件加载失败: ${url}`);
|
|
54
|
+
console.error(err.message);
|
|
55
|
+
reject(err);
|
|
56
|
+
};
|
|
57
|
+
/** 移除事件监听,防止内存泄漏 */
|
|
58
|
+
const cleanup = () => {
|
|
59
|
+
script.removeEventListener("load", onLoad);
|
|
60
|
+
script.removeEventListener("error", onError);
|
|
61
|
+
};
|
|
62
|
+
script.addEventListener("load", onLoad);
|
|
63
|
+
script.addEventListener("error", onError);
|
|
64
|
+
document.head.appendChild(script);
|
|
65
|
+
});
|
|
66
|
+
this._pendingMap.set(url, promise);
|
|
67
|
+
return promise;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 加载 ExcelJS 库
|
|
71
|
+
*
|
|
72
|
+
* @return {*} {Promise<IObject>}
|
|
73
|
+
*/
|
|
74
|
+
async loadExcelsJs() {
|
|
75
|
+
await this.load("/extras/exceljs/4.4.0/exceljs.min.js");
|
|
76
|
+
return window.ExcelJS;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 并发加载多个 JS 脚本文件
|
|
80
|
+
*
|
|
81
|
+
* @param {string[]} urls 脚本文件 URL 列表
|
|
82
|
+
* @param {IScriptOptions} [options] 脚本加载选项,对所有 URL 生效
|
|
83
|
+
* @returns {Promise<void>} 所有文件均加载完成后 resolve;任一失败则 reject
|
|
84
|
+
*/
|
|
85
|
+
async loadBatch(urls, options) {
|
|
86
|
+
await Promise.all(urls.map((url) => this.load(url, options)));
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
/** Script 动态加载工具单例 */
|
|
90
|
+
var scriptLoader = new ScriptLoader();
|
|
91
|
+
//#endregion
|
|
92
|
+
export { scriptLoader };
|
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
8
|
export declare const calcStyle: (data: IData, ignoringStyle?: string[]) => IObject;
|
|
9
|
+
/**
|
|
10
|
+
* 计算配置样式 补充px
|
|
11
|
+
*
|
|
12
|
+
* @param data
|
|
13
|
+
* @param ignoringStyle 忽略计算的样式
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare const calcStylePX: (data: IData, ignoringStyle?: string[]) => IObject;
|
|
9
17
|
/**
|
|
10
18
|
* 计算字体样式
|
|
11
19
|
*
|
package/es/utils/style/index.mjs
CHANGED
|
@@ -71,6 +71,72 @@ var calcStyle = (data, ignoringStyle = []) => {
|
|
|
71
71
|
return style;
|
|
72
72
|
};
|
|
73
73
|
/**
|
|
74
|
+
* 计算配置样式 补充px
|
|
75
|
+
*
|
|
76
|
+
* @param data
|
|
77
|
+
* @param ignoringStyle 忽略计算的样式
|
|
78
|
+
* @returns
|
|
79
|
+
*/
|
|
80
|
+
var calcStylePX = (data, ignoringStyle = []) => {
|
|
81
|
+
if (!data) return {};
|
|
82
|
+
const style = {};
|
|
83
|
+
if (data.paddingTop && data.paddingTop != "0" && !ignoringStyle.includes("paddingTop")) style["padding-top"] = `${data.paddingTop}px`;
|
|
84
|
+
if (data.paddingRight && data.paddingRight != "0" && !ignoringStyle.includes("paddingRight")) style["padding-right"] = `${data.paddingRight}px`;
|
|
85
|
+
if (data.paddingBottom && data.paddingBottom != "0" && !ignoringStyle.includes("paddingBottom")) style["padding-bottom"] = `${data.paddingBottom}px`;
|
|
86
|
+
if (data.paddingLeft && data.paddingLeft != "0" && !ignoringStyle.includes("paddingLeft")) style["padding-left"] = `${data.paddingLeft}px`;
|
|
87
|
+
if (data.marginTop && data.marginTop != "0" && !ignoringStyle.includes("marginTop")) style["margin-top"] = `${data.marginTop}px`;
|
|
88
|
+
if (data.marginRight && data.marginRight != "0" && !ignoringStyle.includes("marginRight")) style["margin-right"] = `${data.marginRight}px`;
|
|
89
|
+
if (data.marginBottom && data.marginBottom != "0" && !ignoringStyle.includes("marginBottom")) style["margin-bottom"] = `${data.marginBottom}px`;
|
|
90
|
+
if (data.marginLeft && data.marginLeft != "0" && !ignoringStyle.includes("marginLeft")) style["margin-left"] = `${data.marginLeft}px`;
|
|
91
|
+
if (data.backgroundColor && !ignoringStyle.includes("backgroundColor")) style["background-color"] = data.backgroundColor;
|
|
92
|
+
if (data.width != null && data.width != "" && !ignoringStyle.includes("width")) style.width = `${data.width}px`;
|
|
93
|
+
if (data.height != null && data.height != "" && !ignoringStyle.includes("height")) {
|
|
94
|
+
style.height = `${data.height}px`;
|
|
95
|
+
style.overflowX = "hidden";
|
|
96
|
+
style.overflowY = "auto";
|
|
97
|
+
}
|
|
98
|
+
const position = data.position;
|
|
99
|
+
if (position && !ignoringStyle.includes("zIndex")) {
|
|
100
|
+
style.position = position;
|
|
101
|
+
style["z-index"] = 1;
|
|
102
|
+
}
|
|
103
|
+
if (data.top && !ignoringStyle.includes("top")) style.top = `${data.top}px`;
|
|
104
|
+
if (data.right && !ignoringStyle.includes("right")) style.right = `${data.right}px`;
|
|
105
|
+
if (data.bottom && !ignoringStyle.includes("bottom")) style.bottom = `${data.bottom}px`;
|
|
106
|
+
if (data.left && !ignoringStyle.includes("left")) style.left = `${data.left}px`;
|
|
107
|
+
if (data.borderBottomLeftRadius && !ignoringStyle.includes("borderBottomLeftRadius")) style["border-top-left-radius"] = `${data.borderBottomLeftRadius}px`;
|
|
108
|
+
if (data.borderTopRightRadius && !ignoringStyle.includes("borderTopRightRadius")) style["border-top-right-radius"] = `${data.borderTopRightRadius}px`;
|
|
109
|
+
if (data.borderBottomLeftRadius && !ignoringStyle.includes("borderBottomLeftRadius")) style["border-bottom-left-radius"] = `${data.borderBottomLeftRadius}px`;
|
|
110
|
+
if (data.borderBottomRightRadius && !ignoringStyle.includes("borderBottomRightRadius")) style["border-bottom-right-radius"] = `${data.borderBottomRightRadius}px`;
|
|
111
|
+
{
|
|
112
|
+
const top = data.borderTop;
|
|
113
|
+
if (top) {
|
|
114
|
+
if (top.borderColor && !ignoringStyle.includes("borderTopColor")) style["border-top-color"] = top.borderColor;
|
|
115
|
+
if (top.borderWidth && !ignoringStyle.includes("borderTopWidth")) style["border-top-width"] = `${top.borderWidth}px`;
|
|
116
|
+
if (top.borderStyle && !ignoringStyle.includes("borderTopStyle")) style["border-top-style"] = top.borderStyle;
|
|
117
|
+
}
|
|
118
|
+
const right = data.borderRight;
|
|
119
|
+
if (right) {
|
|
120
|
+
if (right.borderColor && !ignoringStyle.includes("borderRightColor")) style["border-right-color"] = right.borderColor;
|
|
121
|
+
if (right.borderWidth && !ignoringStyle.includes("borderRightWidth")) style["border-right-width"] = `${right.borderWidth}px`;
|
|
122
|
+
if (right.borderStyle && !ignoringStyle.includes("borderRightStyle")) style["border-right-style"] = right.borderStyle;
|
|
123
|
+
}
|
|
124
|
+
const bottom = data.borderBottom;
|
|
125
|
+
if (bottom) {
|
|
126
|
+
if (bottom.borderColor && !ignoringStyle.includes("borderBottomColor")) style["border-bottom-color"] = bottom.borderColor;
|
|
127
|
+
if (bottom.borderWidth && !ignoringStyle.includes("borderBottomWidth")) style["border-bottom-width"] = `${bottom.borderWidth}px`;
|
|
128
|
+
if (bottom.borderStyle && !ignoringStyle.includes("borderBottomStyle")) style["border-bottom-style"] = bottom.borderStyle;
|
|
129
|
+
}
|
|
130
|
+
const left = data.borderLeft;
|
|
131
|
+
if (left) {
|
|
132
|
+
if (left.borderColor && !ignoringStyle.includes("borderLeftColor")) style["border-left-color"] = left.borderColor;
|
|
133
|
+
if (left.borderWidth && !ignoringStyle.includes("borderLeftWidth")) style["border-left-width"] = `${left.borderWidth}px`;
|
|
134
|
+
if (left.borderStyle && !ignoringStyle.includes("borderLeftStyle")) style["border-left-style"] = left.borderStyle;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return style;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
74
140
|
* 计算字体样式
|
|
75
141
|
*
|
|
76
142
|
* @param data
|
|
@@ -94,4 +160,4 @@ var calcFontStyle = (data, ignoringStyle = []) => {
|
|
|
94
160
|
return style;
|
|
95
161
|
};
|
|
96
162
|
//#endregion
|
|
97
|
-
export { calcFontStyle, calcStyle };
|
|
163
|
+
export { calcFontStyle, calcStyle, calcStylePX };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gct-paas/core",
|
|
3
|
-
"version": "0.1.5-dev.
|
|
3
|
+
"version": "0.1.5-dev.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "paas 平台核心包",
|
|
6
6
|
"loader": "dist/index.esm.min.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@fingerprintjs/fingerprintjs": "^5.1.0",
|
|
35
35
|
"@floating-ui/dom": "^1.7.6",
|
|
36
|
-
"@gct-paas/api": "0.1.4-dev.
|
|
36
|
+
"@gct-paas/api": "0.1.4-dev.3",
|
|
37
37
|
"@module-federation/runtime": "^2.2.3",
|
|
38
38
|
"@vueuse/core": "^14.1.0",
|
|
39
39
|
"async-validator": "^4.2.5",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"playwright": "^1.58.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@gct-paas/api": "0.1.4-dev.
|
|
61
|
+
"@gct-paas/api": "0.1.4-dev.3",
|
|
62
62
|
"vue": ">=3",
|
|
63
63
|
"vue-i18n": ">=11",
|
|
64
64
|
"vue-router": ">=4"
|