@mybricks/to-code-taro 1.0.0
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/cjs/abstractEventTypeDef.d.ts +11 -0
- package/dist/cjs/abstractEventTypeDef.js +93 -0
- package/dist/cjs/core/comlib/Index.js +45 -0
- package/dist/cjs/core/comlib/_ScanQrcode.js +60 -0
- package/dist/cjs/core/comlib/_SetStorage.js +76 -0
- package/dist/cjs/core/comlib/_ShowToast.js +96 -0
- package/dist/cjs/core/mybricks/MyBricksDescriptor.js +213 -0
- package/dist/cjs/core/mybricks/Subject.js +115 -0
- package/dist/cjs/core/mybricks/constant.js +70 -0
- package/dist/cjs/core/mybricks/context.js +33 -0
- package/dist/cjs/core/mybricks/createEnv.js +39 -0
- package/dist/cjs/core/mybricks/createJSHandle.js +150 -0
- package/dist/cjs/core/mybricks/createModuleEventsHandle.js +49 -0
- package/dist/cjs/core/mybricks/createReactiveInputHandler.js +63 -0
- package/dist/cjs/core/mybricks/event.js +70 -0
- package/dist/cjs/core/mybricks/index.js +871 -0
- package/dist/cjs/core/mybricks/log.js +38 -0
- package/dist/cjs/core/mybricks/utils.js +69 -0
- package/dist/cjs/core/mybricks/variables.js +217 -0
- package/dist/cjs/core/utils/ComContext.js +39 -0
- package/dist/cjs/core/utils/index.js +88 -0
- package/dist/cjs/core/utils/useContext.js +53 -0
- package/dist/cjs/core/utils/with.js +84 -0
- package/dist/cjs/generate/generateTaroProjectJson.d.ts +24 -0
- package/dist/cjs/generate/generateTaroProjectJson.js +101 -0
- package/dist/cjs/generate/generateTaroTempalteJson.d.ts +15 -0
- package/dist/cjs/generate/generateTaroTempalteJson.js +103 -0
- package/dist/cjs/generate/utils/appConfig.d.ts +21 -0
- package/dist/cjs/generate/utils/appConfig.js +47 -0
- package/dist/cjs/generate/utils/commonDir.d.ts +21 -0
- package/dist/cjs/generate/utils/commonDir.js +50 -0
- package/dist/cjs/generate/utils/fileNode.d.ts +17 -0
- package/dist/cjs/generate/utils/fileNode.js +57 -0
- package/dist/cjs/generate/utils/index.d.ts +7 -0
- package/dist/cjs/generate/utils/index.js +29 -0
- package/dist/cjs/generate/utils/tabBarImages.d.ts +14 -0
- package/dist/cjs/generate/utils/tabBarImages.js +36 -0
- package/dist/cjs/handleCom.d.ts +31 -0
- package/dist/cjs/handleCom.js +260 -0
- package/dist/cjs/handleDom.d.ts +19 -0
- package/dist/cjs/handleDom.js +86 -0
- package/dist/cjs/handleExtension.d.ts +10 -0
- package/dist/cjs/handleExtension.js +300 -0
- package/dist/cjs/handleGlobal.d.ts +21 -0
- package/dist/cjs/handleGlobal.js +155 -0
- package/dist/cjs/handleModule.d.ts +15 -0
- package/dist/cjs/handleModule.js +108 -0
- package/dist/cjs/handleSlot.d.ts +27 -0
- package/dist/cjs/handleSlot.js +197 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +44 -0
- package/dist/cjs/taro-template.json +5370 -0
- package/dist/cjs/toCodeTaro.d.ts +130 -0
- package/dist/cjs/toCodeTaro.js +427 -0
- package/dist/cjs/utils/code/component.d.ts +19 -0
- package/dist/cjs/utils/code/component.js +85 -0
- package/dist/cjs/utils/code/index.d.ts +18 -0
- package/dist/cjs/utils/code/index.js +71 -0
- package/dist/cjs/utils/code/renderManager.d.ts +22 -0
- package/dist/cjs/utils/code/renderManager.js +80 -0
- package/dist/cjs/utils/code/scene.d.ts +19 -0
- package/dist/cjs/utils/code/scene.js +82 -0
- package/dist/cjs/utils/convertNamespace.d.ts +11 -0
- package/dist/cjs/utils/convertNamespace.js +43 -0
- package/dist/cjs/utils/genJSModules.d.ts +12 -0
- package/dist/cjs/utils/genJSModules.js +116 -0
- package/dist/cjs/utils/getComponentClassName.d.ts +16 -0
- package/dist/cjs/utils/getComponentClassName.js +47 -0
- package/dist/cjs/utils/handlePageConfig.d.ts +24 -0
- package/dist/cjs/utils/handlePageConfig.js +73 -0
- package/dist/cjs/utils/handleProcess.d.ts +9 -0
- package/dist/cjs/utils/handleProcess.js +370 -0
- package/dist/cjs/utils/index.d.ts +62 -0
- package/dist/cjs/utils/index.js +321 -0
- package/dist/cjs/utils/pageConfig/converter.d.ts +17 -0
- package/dist/cjs/utils/pageConfig/converter.js +83 -0
- package/dist/cjs/utils/pageConfig/index.d.ts +10 -0
- package/dist/cjs/utils/pageConfig/index.js +33 -0
- package/dist/cjs/utils/pageConfig/pageConfig.d.ts +10 -0
- package/dist/cjs/utils/pageConfig/pageConfig.js +87 -0
- package/dist/cjs/utils/pageConfig/saveBase64Image.d.ts +14 -0
- package/dist/cjs/utils/pageConfig/saveBase64Image.js +81 -0
- package/dist/cjs/utils/pageConfig/tabBarConfig.d.ts +13 -0
- package/dist/cjs/utils/pageConfig/tabBarConfig.js +74 -0
- package/dist/cjs/utils/pageConfig/types.d.ts +68 -0
- package/dist/cjs/utils/pageConfig/types.js +17 -0
- package/dist/cjs/utils/pageConfig/validator.d.ts +13 -0
- package/dist/cjs/utils/pageConfig/validator.js +67 -0
- package/dist/cjs/utils/pxtransform.d.ts +28 -0
- package/dist/cjs/utils/pxtransform.js +102 -0
- package/dist/esm/abstractEventTypeDef.d.ts +11 -0
- package/dist/esm/abstractEventTypeDef.js +63 -0
- package/dist/esm/core/comlib/Index.js +3 -0
- package/dist/esm/core/comlib/_ScanQrcode.js +27 -0
- package/dist/esm/core/comlib/_SetStorage.js +52 -0
- package/dist/esm/core/comlib/_ShowToast.js +68 -0
- package/dist/esm/core/mybricks/MyBricksDescriptor.js +232 -0
- package/dist/esm/core/mybricks/Subject.js +143 -0
- package/dist/esm/core/mybricks/constant.js +18 -0
- package/dist/esm/core/mybricks/context.js +5 -0
- package/dist/esm/core/mybricks/createEnv.js +9 -0
- package/dist/esm/core/mybricks/createJSHandle.js +138 -0
- package/dist/esm/core/mybricks/createModuleEventsHandle.js +26 -0
- package/dist/esm/core/mybricks/createReactiveInputHandler.js +40 -0
- package/dist/esm/core/mybricks/event.js +44 -0
- package/dist/esm/core/mybricks/index.js +952 -0
- package/dist/esm/core/mybricks/log.js +12 -0
- package/dist/esm/core/mybricks/utils.js +41 -0
- package/dist/esm/core/mybricks/variables.js +190 -0
- package/dist/esm/core/utils/ComContext.js +10 -0
- package/dist/esm/core/utils/index.js +57 -0
- package/dist/esm/core/utils/useContext.js +24 -0
- package/dist/esm/core/utils/with.js +67 -0
- package/dist/esm/generate/generateTaroProjectJson.d.ts +24 -0
- package/dist/esm/generate/generateTaroProjectJson.js +102 -0
- package/dist/esm/generate/generateTaroTempalteJson.d.ts +15 -0
- package/dist/esm/generate/generateTaroTempalteJson.js +94 -0
- package/dist/esm/generate/utils/appConfig.d.ts +21 -0
- package/dist/esm/generate/utils/appConfig.js +30 -0
- package/dist/esm/generate/utils/commonDir.d.ts +21 -0
- package/dist/esm/generate/utils/commonDir.js +36 -0
- package/dist/esm/generate/utils/fileNode.d.ts +17 -0
- package/dist/esm/generate/utils/fileNode.js +49 -0
- package/dist/esm/generate/utils/index.d.ts +7 -0
- package/dist/esm/generate/utils/index.js +8 -0
- package/dist/esm/generate/utils/tabBarImages.d.ts +14 -0
- package/dist/esm/generate/utils/tabBarImages.js +15 -0
- package/dist/esm/handleCom.d.ts +31 -0
- package/dist/esm/handleCom.js +297 -0
- package/dist/esm/handleDom.d.ts +19 -0
- package/dist/esm/handleDom.js +63 -0
- package/dist/esm/handleExtension.d.ts +10 -0
- package/dist/esm/handleExtension.js +243 -0
- package/dist/esm/handleGlobal.d.ts +21 -0
- package/dist/esm/handleGlobal.js +117 -0
- package/dist/esm/handleModule.d.ts +15 -0
- package/dist/esm/handleModule.js +78 -0
- package/dist/esm/handleSlot.d.ts +27 -0
- package/dist/esm/handleSlot.js +205 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/taro-template.json +5370 -0
- package/dist/esm/toCodeTaro.d.ts +130 -0
- package/dist/esm/toCodeTaro.js +452 -0
- package/dist/esm/utils/code/component.d.ts +19 -0
- package/dist/esm/utils/code/component.js +54 -0
- package/dist/esm/utils/code/index.d.ts +18 -0
- package/dist/esm/utils/code/index.js +51 -0
- package/dist/esm/utils/code/renderManager.d.ts +22 -0
- package/dist/esm/utils/code/renderManager.js +62 -0
- package/dist/esm/utils/code/scene.d.ts +19 -0
- package/dist/esm/utils/code/scene.js +47 -0
- package/dist/esm/utils/convertNamespace.d.ts +11 -0
- package/dist/esm/utils/convertNamespace.js +27 -0
- package/dist/esm/utils/genJSModules.d.ts +12 -0
- package/dist/esm/utils/genJSModules.js +44 -0
- package/dist/esm/utils/getComponentClassName.d.ts +16 -0
- package/dist/esm/utils/getComponentClassName.js +37 -0
- package/dist/esm/utils/handlePageConfig.d.ts +24 -0
- package/dist/esm/utils/handlePageConfig.js +68 -0
- package/dist/esm/utils/handleProcess.d.ts +9 -0
- package/dist/esm/utils/handleProcess.js +379 -0
- package/dist/esm/utils/index.d.ts +62 -0
- package/dist/esm/utils/index.js +345 -0
- package/dist/esm/utils/pageConfig/converter.d.ts +17 -0
- package/dist/esm/utils/pageConfig/converter.js +105 -0
- package/dist/esm/utils/pageConfig/index.d.ts +10 -0
- package/dist/esm/utils/pageConfig/index.js +11 -0
- package/dist/esm/utils/pageConfig/pageConfig.d.ts +10 -0
- package/dist/esm/utils/pageConfig/pageConfig.js +60 -0
- package/dist/esm/utils/pageConfig/saveBase64Image.d.ts +14 -0
- package/dist/esm/utils/pageConfig/saveBase64Image.js +105 -0
- package/dist/esm/utils/pageConfig/tabBarConfig.d.ts +13 -0
- package/dist/esm/utils/pageConfig/tabBarConfig.js +82 -0
- package/dist/esm/utils/pageConfig/types.d.ts +68 -0
- package/dist/esm/utils/pageConfig/types.js +1 -0
- package/dist/esm/utils/pageConfig/validator.d.ts +13 -0
- package/dist/esm/utils/pageConfig/validator.js +64 -0
- package/dist/esm/utils/pxtransform.d.ts +28 -0
- package/dist/esm/utils/pxtransform.js +121 -0
- package/package.json +74 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/pageConfig/tabBarConfig.ts
|
|
20
|
+
var tabBarConfig_exports = {};
|
|
21
|
+
__export(tabBarConfig_exports, {
|
|
22
|
+
generateTabBarConfigContent: () => generateTabBarConfigContent
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(tabBarConfig_exports);
|
|
25
|
+
var import_converter = require("./converter");
|
|
26
|
+
var import_saveBase64Image = require("./saveBase64Image");
|
|
27
|
+
function generateTabBarConfigContent(tabBar, pageIdToPath = (pageId) => `pages/${pageId}/index`, imageFiles) {
|
|
28
|
+
if (!tabBar || !Array.isArray(tabBar)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const iconProcessor = imageFiles ? (iconPath, index, type) => (0, import_saveBase64Image.processTabBarIcon)(iconPath, index, type, imageFiles) : void 0;
|
|
32
|
+
const config = (0, import_converter.convertToTaroTabBarConfig)(tabBar, pageIdToPath, iconProcessor);
|
|
33
|
+
if (!config) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return formatTabBarConfigForAppConfig(config);
|
|
37
|
+
}
|
|
38
|
+
function formatTabBarConfigForAppConfig(config, indent = " ") {
|
|
39
|
+
const lines = [];
|
|
40
|
+
lines.push(`${indent}tabBar: {`);
|
|
41
|
+
if (config.color) {
|
|
42
|
+
lines.push(`${indent} color: '${config.color}',`);
|
|
43
|
+
}
|
|
44
|
+
if (config.selectedColor) {
|
|
45
|
+
lines.push(`${indent} selectedColor: '${config.selectedColor}',`);
|
|
46
|
+
}
|
|
47
|
+
if (config.backgroundColor) {
|
|
48
|
+
lines.push(`${indent} backgroundColor: '${config.backgroundColor}',`);
|
|
49
|
+
}
|
|
50
|
+
if (config.borderStyle) {
|
|
51
|
+
lines.push(`${indent} borderStyle: '${config.borderStyle}',`);
|
|
52
|
+
}
|
|
53
|
+
lines.push(`${indent} list: [`);
|
|
54
|
+
config.list.forEach((item, index) => {
|
|
55
|
+
const isLast = index === config.list.length - 1;
|
|
56
|
+
lines.push(`${indent} {`);
|
|
57
|
+
lines.push(`${indent} pagePath: '${item.pagePath}',`);
|
|
58
|
+
lines.push(`${indent} text: '${item.text}',`);
|
|
59
|
+
if (item.iconPath) {
|
|
60
|
+
lines.push(`${indent} iconPath: '${item.iconPath}',`);
|
|
61
|
+
}
|
|
62
|
+
if (item.selectedIconPath) {
|
|
63
|
+
lines.push(`${indent} selectedIconPath: '${item.selectedIconPath}',`);
|
|
64
|
+
}
|
|
65
|
+
lines.push(`${indent} }${isLast ? "" : ","}`);
|
|
66
|
+
});
|
|
67
|
+
lines.push(`${indent} ]`);
|
|
68
|
+
lines.push(`${indent}}`);
|
|
69
|
+
return lines.join("\n");
|
|
70
|
+
}
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
generateTabBarConfigContent
|
|
74
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TabBar 相关类型定义
|
|
3
|
+
*/
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
/// <reference types="node" />
|
|
6
|
+
/**
|
|
7
|
+
* TabBar 项源数据(来自 toJson.tabbar)
|
|
8
|
+
*/
|
|
9
|
+
export interface TabBarItemSource {
|
|
10
|
+
scene: {
|
|
11
|
+
id: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
};
|
|
14
|
+
text?: string;
|
|
15
|
+
type?: string;
|
|
16
|
+
normalIconPath?: string;
|
|
17
|
+
selectedIconPath?: string;
|
|
18
|
+
normalTextStyle?: Record<string, any>;
|
|
19
|
+
selectedTextStyle?: Record<string, any>;
|
|
20
|
+
normalIconStyle?: Record<string, any>;
|
|
21
|
+
selectedIconStyle?: Record<string, any>;
|
|
22
|
+
normalBackgroundStyle?: Record<string, any>;
|
|
23
|
+
selectedBackgroundStyle?: Record<string, any>;
|
|
24
|
+
subMenu?: Array<{
|
|
25
|
+
scene: {
|
|
26
|
+
id: string;
|
|
27
|
+
title?: string;
|
|
28
|
+
};
|
|
29
|
+
normalIconPath?: string;
|
|
30
|
+
normalTextStyle?: Record<string, any>;
|
|
31
|
+
normalIconStyle?: Record<string, any>;
|
|
32
|
+
normalBackgroundStyle?: Record<string, any>;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Taro TabBar 项配置
|
|
37
|
+
*/
|
|
38
|
+
export interface TaroTabBarItem {
|
|
39
|
+
pagePath: string;
|
|
40
|
+
text: string;
|
|
41
|
+
iconPath?: string;
|
|
42
|
+
selectedIconPath?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Taro TabBar 配置
|
|
46
|
+
*/
|
|
47
|
+
export interface TaroTabBarConfig {
|
|
48
|
+
color?: string;
|
|
49
|
+
selectedColor?: string;
|
|
50
|
+
backgroundColor?: string;
|
|
51
|
+
borderStyle?: string;
|
|
52
|
+
list: TaroTabBarItem[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* TabBar 验证结果
|
|
56
|
+
*/
|
|
57
|
+
export interface TabBarValidationResult {
|
|
58
|
+
useTabBar: boolean;
|
|
59
|
+
validItems: TabBarItemSource[];
|
|
60
|
+
error?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 图片文件信息
|
|
64
|
+
*/
|
|
65
|
+
export interface ImageFileInfo {
|
|
66
|
+
filePath: string;
|
|
67
|
+
fileContent: Buffer;
|
|
68
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/utils/pageConfig/types.ts
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TabBarItemSource, TabBarValidationResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 验证 TabBar 配置
|
|
4
|
+
* @param tabBar TabBar 项数组(来自 toJson.tabbar)
|
|
5
|
+
* @returns 验证结果
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateTabBar(tabBar: TabBarItemSource[] | undefined | null): TabBarValidationResult;
|
|
8
|
+
/**
|
|
9
|
+
* 判断是否启用 TabBar
|
|
10
|
+
* @param tabBar TabBar 项数组
|
|
11
|
+
* @returns 是否启用
|
|
12
|
+
*/
|
|
13
|
+
export declare function shouldUseTabBar(tabBar: TabBarItemSource[] | undefined | null): boolean;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/pageConfig/validator.ts
|
|
20
|
+
var validator_exports = {};
|
|
21
|
+
__export(validator_exports, {
|
|
22
|
+
shouldUseTabBar: () => shouldUseTabBar,
|
|
23
|
+
validateTabBar: () => validateTabBar
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(validator_exports);
|
|
26
|
+
var MIN_TAB_BAR_ITEMS = 2;
|
|
27
|
+
var MAX_TAB_BAR_ITEMS = 5;
|
|
28
|
+
function validateTabBar(tabBar) {
|
|
29
|
+
if (!Array.isArray(tabBar)) {
|
|
30
|
+
return {
|
|
31
|
+
useTabBar: false,
|
|
32
|
+
validItems: [],
|
|
33
|
+
error: "TabBar 配置不存在或格式错误"
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const validItems = tabBar.filter((item) => {
|
|
37
|
+
var _a;
|
|
38
|
+
return !!((_a = item == null ? void 0 : item.scene) == null ? void 0 : _a.id);
|
|
39
|
+
});
|
|
40
|
+
const itemCount = validItems.length;
|
|
41
|
+
if (itemCount < MIN_TAB_BAR_ITEMS) {
|
|
42
|
+
return {
|
|
43
|
+
useTabBar: false,
|
|
44
|
+
validItems: [],
|
|
45
|
+
error: `TabBar 项数量不足,需要至少 ${MIN_TAB_BAR_ITEMS} 个,当前 ${itemCount} 个`
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (itemCount > MAX_TAB_BAR_ITEMS) {
|
|
49
|
+
return {
|
|
50
|
+
useTabBar: false,
|
|
51
|
+
validItems: [],
|
|
52
|
+
error: `TabBar 项数量过多,最多 ${MAX_TAB_BAR_ITEMS} 个,当前 ${itemCount} 个`
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
useTabBar: true,
|
|
57
|
+
validItems
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function shouldUseTabBar(tabBar) {
|
|
61
|
+
return validateTabBar(tabBar).useTabBar;
|
|
62
|
+
}
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
shouldUseTabBar,
|
|
66
|
+
validateTabBar
|
|
67
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* px 转 rpx 适配方法
|
|
3
|
+
* 用于 Taro/小程序样式转换
|
|
4
|
+
*
|
|
5
|
+
* 转换规则:
|
|
6
|
+
* - 如果 px 值 <= MIN_PX_THRESHOLD,保持为 px(避免 1px 边框等问题)
|
|
7
|
+
* - 否则转换为 rpx(px * 2,基于 375px 设计稿)
|
|
8
|
+
*
|
|
9
|
+
* 注意:Taro 中 rpx 需要作为字符串使用,如 "20rpx"
|
|
10
|
+
*/
|
|
11
|
+
/** 最小 px 阈值,小于等于此值的 px 不转换为 rpx */
|
|
12
|
+
export declare const MIN_PX_THRESHOLD = 1;
|
|
13
|
+
/** rem 基准值,默认 px = 1rem */
|
|
14
|
+
export declare const REM_BASE = 20;
|
|
15
|
+
/**
|
|
16
|
+
* 将 px 值转换为 rpx(用于 Taro 小程序)
|
|
17
|
+
* @param value - 样式值,可以是字符串(如 "10px")或数字(如 10)
|
|
18
|
+
* @returns 转换后的值,字符串类型(如 "20rpx")或数字(如 1,用于小于等于 MIN_PX_THRESHOLD 的情况)
|
|
19
|
+
*/
|
|
20
|
+
export declare function pxToRpx(value: string | number): string | number;
|
|
21
|
+
/**
|
|
22
|
+
* 将 px 值转换为 rem(用于 H5/Web)
|
|
23
|
+
* @param value - 样式值,可以是字符串(如 "16px")或数字(如 16)
|
|
24
|
+
* @returns 转换后的值,字符串类型(如 "1rem")或数字(如 1,用于小于等于 MIN_PX_THRESHOLD 的情况)
|
|
25
|
+
*/
|
|
26
|
+
export declare function pxToRem(value: string | number): string | number;
|
|
27
|
+
declare const pxtransform: (value: string | number, type?: "rpx" | "rem") => string | number;
|
|
28
|
+
export default pxtransform;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/pxtransform.ts
|
|
20
|
+
var pxtransform_exports = {};
|
|
21
|
+
__export(pxtransform_exports, {
|
|
22
|
+
MIN_PX_THRESHOLD: () => MIN_PX_THRESHOLD,
|
|
23
|
+
REM_BASE: () => REM_BASE,
|
|
24
|
+
default: () => pxtransform_default,
|
|
25
|
+
pxToRem: () => pxToRem,
|
|
26
|
+
pxToRpx: () => pxToRpx
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(pxtransform_exports);
|
|
29
|
+
var MIN_PX_THRESHOLD = 1;
|
|
30
|
+
var REM_BASE = 20;
|
|
31
|
+
function isPxValue(value) {
|
|
32
|
+
if (typeof value === "number") {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
if (typeof value === "string") {
|
|
36
|
+
const regex = /^(\d*\.?\d+)px$/;
|
|
37
|
+
return regex.test(value);
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
function pxToRpx(value) {
|
|
42
|
+
if (typeof value === "number") {
|
|
43
|
+
if (value <= MIN_PX_THRESHOLD) {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
return `${value * 2}rpx`;
|
|
47
|
+
}
|
|
48
|
+
if (typeof value === "string") {
|
|
49
|
+
const regex = /^(\d*\.?\d+)px$/;
|
|
50
|
+
const match = value.match(regex);
|
|
51
|
+
if (match) {
|
|
52
|
+
const pxValue = parseFloat(match[1]);
|
|
53
|
+
if (pxValue <= MIN_PX_THRESHOLD) {
|
|
54
|
+
return pxValue;
|
|
55
|
+
}
|
|
56
|
+
return `${pxValue * 2}rpx`;
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
function pxToRem(value) {
|
|
63
|
+
if (typeof value === "number") {
|
|
64
|
+
if (value <= MIN_PX_THRESHOLD) {
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
const remValue = value / REM_BASE;
|
|
68
|
+
return `${remValue}rem`;
|
|
69
|
+
}
|
|
70
|
+
if (typeof value === "string") {
|
|
71
|
+
const regex = /^(\d*\.?\d+)px$/;
|
|
72
|
+
const match = value.match(regex);
|
|
73
|
+
if (match) {
|
|
74
|
+
const pxValue = parseFloat(match[1]);
|
|
75
|
+
if (pxValue <= MIN_PX_THRESHOLD) {
|
|
76
|
+
return pxValue;
|
|
77
|
+
}
|
|
78
|
+
const remValue = pxValue / REM_BASE;
|
|
79
|
+
return `${remValue}rem`;
|
|
80
|
+
}
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
var pxtransform = (value, type = "rpx") => {
|
|
86
|
+
if (isPxValue(value)) {
|
|
87
|
+
if (type === "rpx") {
|
|
88
|
+
return pxToRpx(value);
|
|
89
|
+
} else if (type === "rem") {
|
|
90
|
+
return pxToRem(value);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return value;
|
|
94
|
+
};
|
|
95
|
+
var pxtransform_default = pxtransform;
|
|
96
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
+
0 && (module.exports = {
|
|
98
|
+
MIN_PX_THRESHOLD,
|
|
99
|
+
REM_BASE,
|
|
100
|
+
pxToRem,
|
|
101
|
+
pxToRpx
|
|
102
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ToTaroCodeConfig } from "./toCodeTaro";
|
|
2
|
+
type AbstractEventTypeDefMap = Record<string, {
|
|
3
|
+
eventIds: Set<string>;
|
|
4
|
+
typeDef: {
|
|
5
|
+
var: Record<string, any>;
|
|
6
|
+
input: Record<string, any>;
|
|
7
|
+
output: Record<string, any>;
|
|
8
|
+
};
|
|
9
|
+
}>;
|
|
10
|
+
declare const abstractEventTypeDef: (abstractEventTypeDefMap: AbstractEventTypeDefMap, config: ToTaroCodeConfig) => string;
|
|
11
|
+
export default abstractEventTypeDef;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
|
|
4
|
+
import { indentation } from "./utils";
|
|
5
|
+
var abstractEventTypeDef = function abstractEventTypeDef(abstractEventTypeDefMap, config) {
|
|
6
|
+
var indent = indentation(config.codeStyle.indent);
|
|
7
|
+
var interfaceCode = [];
|
|
8
|
+
var comEvent = [];
|
|
9
|
+
Object.entries(abstractEventTypeDefMap).forEach(function (_ref) {
|
|
10
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
11
|
+
comId = _ref2[0],
|
|
12
|
+
_ref2$ = _ref2[1],
|
|
13
|
+
typeDef = _ref2$.typeDef,
|
|
14
|
+
eventIdMap = _ref2$.eventIdMap;
|
|
15
|
+
var vars = typeDef.vars,
|
|
16
|
+
inputs = typeDef.inputs,
|
|
17
|
+
outputs = typeDef.outputs;
|
|
18
|
+
var statementCode = [];
|
|
19
|
+
var getCode = [];
|
|
20
|
+
var eventCode = [];
|
|
21
|
+
var eventCtxTypeName = "I".concat(comId, "_comEventCtx");
|
|
22
|
+
var comEventTypeName = "I".concat(comId, "_comEvent");
|
|
23
|
+
Object.entries(vars).forEach(function (_ref3) {
|
|
24
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
25
|
+
_ref4$ = _ref4[1],
|
|
26
|
+
title = _ref4$.title,
|
|
27
|
+
schema = _ref4$.schema;
|
|
28
|
+
var typeName = "I".concat(comId, "_var_").concat(title);
|
|
29
|
+
statementCode.push("type ".concat(typeName, " = any;"));
|
|
30
|
+
getCode.push("".concat(indent, "getVar<T = ").concat(typeName, ">(value: \"").concat(title, "\"): GetVarResult<T>"));
|
|
31
|
+
});
|
|
32
|
+
Object.entries(inputs).forEach(function (_ref5) {
|
|
33
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
34
|
+
_ref6$ = _ref6[1],
|
|
35
|
+
title = _ref6$.title,
|
|
36
|
+
schema = _ref6$.schema;
|
|
37
|
+
var typeName = "I".concat(comId, "_input_").concat(title);
|
|
38
|
+
statementCode.push("type ".concat(typeName, " = any;"));
|
|
39
|
+
getCode.push("".concat(indent, "getInput<T = ").concat(typeName, ">(value: \"").concat(title, "\"): GetInputResult<T>"));
|
|
40
|
+
});
|
|
41
|
+
Object.entries(outputs).forEach(function (_ref7) {
|
|
42
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
43
|
+
_ref8$ = _ref8[1],
|
|
44
|
+
title = _ref8$.title,
|
|
45
|
+
schema = _ref8$.schema;
|
|
46
|
+
var typeName = "I".concat(comId, "_output_").concat(title);
|
|
47
|
+
statementCode.push("type ".concat(typeName, " = any;"));
|
|
48
|
+
getCode.push("".concat(indent, "getOutput<T = ").concat(typeName, ">(value: \"").concat(title, "\"): GetOutputResult<T>"));
|
|
49
|
+
});
|
|
50
|
+
Object.entries(eventIdMap).forEach(function (_ref9) {
|
|
51
|
+
var _ref10 = _slicedToArray(_ref9, 2),
|
|
52
|
+
eventId = _ref10[0],
|
|
53
|
+
schema = _ref10[1];
|
|
54
|
+
var typeName = "I".concat(comId, "_").concat(eventId, "_value");
|
|
55
|
+
statementCode.push("type ".concat(typeName, " = any;"));
|
|
56
|
+
eventCode.push("".concat(indent).concat(eventId, "?: (value: ").concat(typeName, ", ctx: ").concat(eventCtxTypeName, ") => void"));
|
|
57
|
+
});
|
|
58
|
+
interfaceCode.push(statementCode.join("\n") + "\ninterface ".concat(eventCtxTypeName, " {") + "\n".concat(getCode.join("\n")) + "\n}" + "\ninterface ".concat(comEventTypeName, " {") + "\n".concat(eventCode.join("\n")) + "\n}");
|
|
59
|
+
comEvent.push("".concat(indent).concat(comId, "?: ").concat(comEventTypeName));
|
|
60
|
+
});
|
|
61
|
+
return "interface GetVarResult<T> {\n getValue: () => T\n setValue: (value: T) => void\n}\ninterface GetOutputResult<T> {\n setValue: (value: T) => void\n}\ninterface GetInputResult<T> {\n getValue: () => T\n}" + (interfaceCode ? "\n".concat(interfaceCode.join("\n")) : "") + "\ninterface ComEvent {" + "\n".concat(comEvent.join("\n")) + "\n}";
|
|
62
|
+
};
|
|
63
|
+
export default abstractEventTypeDef;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Taro from '@tarojs/taro';
|
|
2
|
+
export default (function (context) {
|
|
3
|
+
var _inputs$scan;
|
|
4
|
+
var data = context.data;
|
|
5
|
+
var inputs = context.inputs;
|
|
6
|
+
var outputs = context.outputs;
|
|
7
|
+
inputs === null || inputs === void 0 || (_inputs$scan = inputs.scan) === null || _inputs$scan === void 0 || _inputs$scan.call(inputs, function (val) {
|
|
8
|
+
try {
|
|
9
|
+
var _data$onlyFromCamera;
|
|
10
|
+
var scanType = (data === null || data === void 0 ? void 0 : data.scanType) || ['barCode', 'qrCode'];
|
|
11
|
+
var onlyFromCamera = (_data$onlyFromCamera = data === null || data === void 0 ? void 0 : data.onlyFromCamera) !== null && _data$onlyFromCamera !== void 0 ? _data$onlyFromCamera : false;
|
|
12
|
+
Taro.scanCode({
|
|
13
|
+
onlyFromCamera: onlyFromCamera,
|
|
14
|
+
scanType: scanType,
|
|
15
|
+
success: function success(res) {
|
|
16
|
+
outputs === null || outputs === void 0 || outputs.onSuccess(res.result || res);
|
|
17
|
+
},
|
|
18
|
+
fail: function fail(err) {
|
|
19
|
+
outputs === null || outputs === void 0 || outputs.onFail(err.errMsg || '扫码失败');
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error('扫码失败:', error);
|
|
24
|
+
outputs === null || outputs === void 0 || outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '扫码失败');
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import Taro from '@tarojs/taro';
|
|
2
|
+
export default (function (context) {
|
|
3
|
+
var _inputs$setStorage;
|
|
4
|
+
var data = context.data;
|
|
5
|
+
var inputs = context.inputs;
|
|
6
|
+
var outputs = context.outputs;
|
|
7
|
+
(_inputs$setStorage = inputs.setStorage) === null || _inputs$setStorage === void 0 || _inputs$setStorage.call(inputs, function (val) {
|
|
8
|
+
try {
|
|
9
|
+
var _data$sync;
|
|
10
|
+
// 优先使用动态输入的值,否则使用配置的值
|
|
11
|
+
var key = (val === null || val === void 0 ? void 0 : val.key) || (data === null || data === void 0 ? void 0 : data.key);
|
|
12
|
+
var _value = (val === null || val === void 0 ? void 0 : val.value) !== undefined ? val.value : data === null || data === void 0 ? void 0 : data.value;
|
|
13
|
+
var useSync = (val === null || val === void 0 ? void 0 : val.sync) !== undefined ? val.sync : (_data$sync = data === null || data === void 0 ? void 0 : data.sync) !== null && _data$sync !== void 0 ? _data$sync : false;
|
|
14
|
+
if (!key) {
|
|
15
|
+
outputs === null || outputs === void 0 || outputs.onFail('存储 key 不能为空');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (useSync) {
|
|
19
|
+
// 使用同步方法
|
|
20
|
+
try {
|
|
21
|
+
Taro.setStorageSync(key, _value);
|
|
22
|
+
outputs === null || outputs === void 0 || outputs.onSuccess({
|
|
23
|
+
key: key,
|
|
24
|
+
value: _value
|
|
25
|
+
});
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error('写入本地缓存失败:', error);
|
|
28
|
+
outputs === null || outputs === void 0 || outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '写入本地缓存失败');
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
// 使用异步方法
|
|
32
|
+
Taro.setStorage({
|
|
33
|
+
key: key,
|
|
34
|
+
data: _value,
|
|
35
|
+
success: function success() {
|
|
36
|
+
outputs === null || outputs === void 0 || outputs.onSuccess({
|
|
37
|
+
key: key,
|
|
38
|
+
value: _value
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
fail: function fail(err) {
|
|
42
|
+
console.error('写入本地缓存失败:', err);
|
|
43
|
+
outputs === null || outputs === void 0 || outputs.onFail(err.errMsg || '写入本地缓存失败');
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error('写入本地缓存失败:', error);
|
|
49
|
+
outputs === null || outputs === void 0 || outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '写入本地缓存失败');
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
+
import Taro from '@tarojs/taro';
|
|
3
|
+
export default (function (context) {
|
|
4
|
+
var _inputs$showToast;
|
|
5
|
+
var data = context.data;
|
|
6
|
+
var inputs = context.inputs;
|
|
7
|
+
var outputs = context.outputs;
|
|
8
|
+
(_inputs$showToast = inputs.showToast) === null || _inputs$showToast === void 0 || _inputs$showToast.call(inputs, function (val) {
|
|
9
|
+
if (data !== null && data !== void 0 && data.dynamic) {
|
|
10
|
+
// 动态输入
|
|
11
|
+
try {
|
|
12
|
+
var _ref, _val$duration, _data$duration, _ref2, _val$mask, _data$mask;
|
|
13
|
+
var toastConfig = {
|
|
14
|
+
title: typeof val === 'string' ? val : (val === null || val === void 0 ? void 0 : val.title) || data.title || '',
|
|
15
|
+
duration: Number(val && _typeof(val) === 'object' ? (_ref = (_val$duration = val === null || val === void 0 ? void 0 : val.duration) !== null && _val$duration !== void 0 ? _val$duration : data.duration) !== null && _ref !== void 0 ? _ref : 1000 : (_data$duration = data.duration) !== null && _data$duration !== void 0 ? _data$duration : 1000),
|
|
16
|
+
mask: val && _typeof(val) === 'object' ? (_ref2 = (_val$mask = val === null || val === void 0 ? void 0 : val.mask) !== null && _val$mask !== void 0 ? _val$mask : data.mask) !== null && _ref2 !== void 0 ? _ref2 : false : (_data$mask = data.mask) !== null && _data$mask !== void 0 ? _data$mask : false
|
|
17
|
+
};
|
|
18
|
+
if (val && _typeof(val) === 'object' && val.icon) {
|
|
19
|
+
toastConfig.icon = val.icon;
|
|
20
|
+
} else if (data.icon) {
|
|
21
|
+
toastConfig.icon = data.icon;
|
|
22
|
+
}
|
|
23
|
+
if (val && _typeof(val) === 'object' && val.image) {
|
|
24
|
+
toastConfig.image = val.image;
|
|
25
|
+
} else if (data.image) {
|
|
26
|
+
toastConfig.image = data.image;
|
|
27
|
+
}
|
|
28
|
+
Taro.showToast(toastConfig);
|
|
29
|
+
if (data.asynchronous) {
|
|
30
|
+
var _ref3, _val$duration2, _data$duration2;
|
|
31
|
+
setTimeout(function () {
|
|
32
|
+
outputs.afterShowToast(val);
|
|
33
|
+
}, Number(val && _typeof(val) === 'object' ? (_ref3 = (_val$duration2 = val === null || val === void 0 ? void 0 : val.duration) !== null && _val$duration2 !== void 0 ? _val$duration2 : data.duration) !== null && _ref3 !== void 0 ? _ref3 : 1000 : (_data$duration2 = data.duration) !== null && _data$duration2 !== void 0 ? _data$duration2 : 1000));
|
|
34
|
+
} else {
|
|
35
|
+
outputs.afterShowToast(val);
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error('显示 Toast 失败:', error);
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
// 非动态输入
|
|
42
|
+
try {
|
|
43
|
+
var _data$mask2;
|
|
44
|
+
var _toastConfig = {
|
|
45
|
+
title: data.title || '',
|
|
46
|
+
duration: Number(data.duration || 1000),
|
|
47
|
+
mask: (_data$mask2 = data.mask) !== null && _data$mask2 !== void 0 ? _data$mask2 : false
|
|
48
|
+
};
|
|
49
|
+
if (data.icon) {
|
|
50
|
+
_toastConfig.icon = data.icon;
|
|
51
|
+
}
|
|
52
|
+
if (data.image) {
|
|
53
|
+
_toastConfig.image = data.image;
|
|
54
|
+
}
|
|
55
|
+
Taro.showToast(_toastConfig);
|
|
56
|
+
if (data.asynchronous) {
|
|
57
|
+
setTimeout(function () {
|
|
58
|
+
outputs.afterShowToast(val);
|
|
59
|
+
}, Number(data.duration || 1000));
|
|
60
|
+
} else {
|
|
61
|
+
outputs.afterShowToast(val);
|
|
62
|
+
}
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error('显示 Toast 失败:', error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|