@mybricks/to-code-taro 1.1.4 → 1.1.6
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/core/mybricks/Subject.js +9 -5
- package/dist/cjs/core/mybricks/createJSHandle.js +45 -4
- package/dist/cjs/core/utils/comRefResolver.js +112 -0
- package/dist/cjs/core/utils/event.js +53 -0
- package/dist/cjs/core/utils/hooks.js +76 -39
- package/dist/cjs/core/utils/index.js +6 -0
- package/dist/cjs/core/utils/pageRouter.js +34 -11
- package/dist/cjs/core/utils/pool.js +63 -0
- package/dist/cjs/core/utils/slots.js +59 -13
- package/dist/cjs/core/utils/tabbar.js +56 -0
- package/dist/cjs/core/utils/useContext.js +46 -4
- package/dist/cjs/core/utils/with.js +9 -34
- package/dist/cjs/generate/generateTaroProjectJson.js +11 -18
- package/dist/cjs/generate/utils/appConfig.d.ts +1 -1
- package/dist/cjs/generate/utils/appConfig.js +23 -12
- package/dist/cjs/generate/utils/commonDir.js +9 -0
- package/dist/cjs/generate/utils/customTabBar.d.ts +11 -0
- package/dist/cjs/generate/utils/customTabBar.js +73 -0
- package/dist/cjs/generate/utils/fileNode.d.ts +4 -0
- package/dist/cjs/generate/utils/fileNode.js +12 -2
- package/dist/cjs/handleCom.js +15 -16
- package/dist/cjs/handleGlobal.d.ts +1 -1
- package/dist/cjs/handleGlobal.js +6 -0
- package/dist/cjs/handleSlot.js +4 -9
- package/dist/cjs/processors/processScene.js +13 -1
- package/dist/cjs/processors/processSceneLogic.js +2 -6
- package/dist/cjs/taro-template.json +1318 -1016
- package/dist/cjs/toCodeTaro.d.ts +1 -2
- package/dist/cjs/toCodeTaro.js +2 -0
- package/dist/cjs/utils/builder/buildResult.d.ts +1 -0
- package/dist/cjs/utils/builder/buildResult.js +54 -2
- package/dist/cjs/utils/common/ImportManager.d.ts +7 -0
- package/dist/cjs/utils/common/ImportManager.js +19 -1
- package/dist/cjs/utils/context/buildContext.d.ts +7 -0
- package/dist/cjs/utils/context/buildContext.js +11 -0
- package/dist/cjs/utils/logic/genJSModules.js +2 -2
- package/dist/cjs/utils/logic/handleProcess.js +54 -12
- package/dist/cjs/utils/templates/renderManager.js +4 -2
- package/dist/esm/core/mybricks/Subject.js +11 -5
- package/dist/esm/core/mybricks/createJSHandle.js +57 -6
- package/dist/esm/core/utils/comRefResolver.js +134 -0
- package/dist/esm/core/utils/event.js +32 -0
- package/dist/esm/core/utils/hooks.js +114 -51
- package/dist/esm/core/utils/index.js +2 -0
- package/dist/esm/core/utils/pageRouter.js +56 -13
- package/dist/esm/core/utils/pool.js +52 -0
- package/dist/esm/core/utils/slots.js +82 -16
- package/dist/esm/core/utils/tabbar.js +47 -0
- package/dist/esm/core/utils/useContext.js +53 -4
- package/dist/esm/core/utils/with.js +19 -53
- package/dist/esm/generate/generateTaroProjectJson.js +14 -20
- package/dist/esm/generate/utils/appConfig.d.ts +1 -1
- package/dist/esm/generate/utils/appConfig.js +29 -9
- package/dist/esm/generate/utils/commonDir.js +13 -0
- package/dist/esm/generate/utils/customTabBar.d.ts +11 -0
- package/dist/esm/generate/utils/customTabBar.js +52 -0
- package/dist/esm/generate/utils/fileNode.d.ts +4 -0
- package/dist/esm/generate/utils/fileNode.js +13 -0
- package/dist/esm/handleCom.js +24 -21
- package/dist/esm/handleGlobal.d.ts +1 -1
- package/dist/esm/handleGlobal.js +6 -1
- package/dist/esm/handleSlot.js +6 -11
- package/dist/esm/processors/processScene.js +23 -3
- package/dist/esm/processors/processSceneLogic.js +3 -5
- package/dist/esm/taro-template.json +1318 -1016
- package/dist/esm/toCodeTaro.d.ts +1 -2
- package/dist/esm/toCodeTaro.js +4 -2
- package/dist/esm/utils/builder/buildResult.d.ts +1 -0
- package/dist/esm/utils/builder/buildResult.js +42 -3
- package/dist/esm/utils/common/ImportManager.d.ts +7 -0
- package/dist/esm/utils/common/ImportManager.js +42 -14
- package/dist/esm/utils/context/buildContext.d.ts +7 -0
- package/dist/esm/utils/context/buildContext.js +12 -0
- package/dist/esm/utils/logic/genJSModules.js +2 -2
- package/dist/esm/utils/logic/handleProcess.js +66 -12
- package/dist/esm/utils/templates/renderManager.js +4 -4
- package/package.json +1 -1
- package/dist/cjs/core/comlib/Index.js +0 -114
- package/dist/cjs/core/comlib/_AesEncode.js +0 -115
- package/dist/cjs/core/comlib/_BackTo.js +0 -80
- package/dist/cjs/core/comlib/_CallPhone.js +0 -58
- package/dist/cjs/core/comlib/_ChooseFile.js +0 -103
- package/dist/cjs/core/comlib/_ChooseMedia.js +0 -70
- package/dist/cjs/core/comlib/_Connector.js +0 -92
- package/dist/cjs/core/comlib/_ConnectorGlobalHeaders.js +0 -79
- package/dist/cjs/core/comlib/_Format.js +0 -123
- package/dist/cjs/core/comlib/_GetLocation.js +0 -60
- package/dist/cjs/core/comlib/_GetStorage.js +0 -68
- package/dist/cjs/core/comlib/_GetSystemInfo.js +0 -62
- package/dist/cjs/core/comlib/_Modal.js +0 -68
- package/dist/cjs/core/comlib/_OpenCamera.js +0 -73
- package/dist/cjs/core/comlib/_OpenPetalMap.js +0 -49
- package/dist/cjs/core/comlib/_OpenUrl.js +0 -62
- package/dist/cjs/core/comlib/_RemoveStorage.js +0 -68
- package/dist/cjs/core/comlib/_Router.js +0 -100
- package/dist/cjs/core/comlib/_ScanQrcode.js +0 -59
- package/dist/cjs/core/comlib/_SetStorage.js +0 -67
- package/dist/cjs/core/comlib/_Share.js +0 -58
- package/dist/cjs/core/comlib/_ShowToast.js +0 -69
- package/dist/cjs/core/comlib/_TextToSpeech.js +0 -120
- package/dist/cjs/core/comlib/_TimerDebounce.js +0 -72
- package/dist/cjs/core/comlib/_TimerDelay.js +0 -88
- package/dist/cjs/core/comlib/_TimerThrottle.js +0 -75
- package/dist/cjs/core/comlib/_Vibrate.js +0 -60
- package/dist/esm/abstractEventTypeDef.d.ts.map +0 -1
- package/dist/esm/core/comlib/Index.js +0 -39
- package/dist/esm/core/comlib/_AesEncode.js +0 -85
- package/dist/esm/core/comlib/_BackTo.js +0 -66
- package/dist/esm/core/comlib/_CallPhone.js +0 -30
- package/dist/esm/core/comlib/_ChooseFile.js +0 -81
- package/dist/esm/core/comlib/_ChooseMedia.js +0 -38
- package/dist/esm/core/comlib/_Connector.js +0 -60
- package/dist/esm/core/comlib/_ConnectorGlobalHeaders.js +0 -56
- package/dist/esm/core/comlib/_Format.js +0 -102
- package/dist/esm/core/comlib/_GetLocation.js +0 -26
- package/dist/esm/core/comlib/_GetStorage.js +0 -44
- package/dist/esm/core/comlib/_GetSystemInfo.js +0 -32
- package/dist/esm/core/comlib/_Modal.js +0 -51
- package/dist/esm/core/comlib/_OpenCamera.js +0 -44
- package/dist/esm/core/comlib/_OpenPetalMap.js +0 -28
- package/dist/esm/core/comlib/_OpenUrl.js +0 -36
- package/dist/esm/core/comlib/_RemoveStorage.js +0 -42
- package/dist/esm/core/comlib/_Router.js +0 -113
- package/dist/esm/core/comlib/_ScanQrcode.js +0 -26
- package/dist/esm/core/comlib/_SetStorage.js +0 -40
- package/dist/esm/core/comlib/_Share.js +0 -28
- package/dist/esm/core/comlib/_ShowToast.js +0 -45
- package/dist/esm/core/comlib/_TextToSpeech.js +0 -117
- package/dist/esm/core/comlib/_TimerDebounce.js +0 -66
- package/dist/esm/core/comlib/_TimerDelay.js +0 -79
- package/dist/esm/core/comlib/_TimerThrottle.js +0 -69
- package/dist/esm/core/comlib/_Vibrate.js +0 -34
- package/dist/esm/generate/generateTaroTempalteJson.d.ts.map +0 -1
- package/dist/esm/generate/utils/appConfig.d.ts.map +0 -1
- package/dist/esm/generate/utils/fileNode.d.ts.map +0 -1
- package/dist/esm/generate/utils/index.d.ts.map +0 -1
- package/dist/esm/generate/utils/pageImages.d.ts.map +0 -1
- package/dist/esm/generate/utils/tabBarImages.d.ts.map +0 -1
- package/dist/esm/handleExtension.d.ts.map +0 -1
- package/dist/esm/handleModule.d.ts.map +0 -1
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/processors/processComEvents.d.ts.map +0 -1
- package/dist/esm/processors/processModule.d.ts.map +0 -1
- package/dist/esm/processors/processScene.d.ts.map +0 -1
- package/dist/esm/processors/processSceneLogic.d.ts.map +0 -1
- package/dist/esm/toCodeTaro.d.ts.map +0 -1
- package/dist/esm/utils/builder/buildResult.d.ts.map +0 -1
- package/dist/esm/utils/common/ImportManager.d.ts.map +0 -1
- package/dist/esm/utils/common/helper.d.ts.map +0 -1
- package/dist/esm/utils/common/object.d.ts.map +0 -1
- package/dist/esm/utils/common/string.d.ts.map +0 -1
- package/dist/esm/utils/config/content/index.d.ts.map +0 -1
- package/dist/esm/utils/config/content/types.d.ts.map +0 -1
- package/dist/esm/utils/config/content/validator.d.ts.map +0 -1
- package/dist/esm/utils/config/handlePageConfig.d.ts.map +0 -1
- package/dist/esm/utils/context/buildContext.d.ts.map +0 -1
- package/dist/esm/utils/context/buildFrameMap.d.ts.map +0 -1
- package/dist/esm/utils/context/buildGlobalData.d.ts.map +0 -1
- package/dist/esm/utils/context/collectJSModules.d.ts.map +0 -1
- package/dist/esm/utils/context/createEventQueries.d.ts.map +0 -1
- package/dist/esm/utils/context/createProvider.d.ts.map +0 -1
- package/dist/esm/utils/index.d.ts.map +0 -1
- package/dist/esm/utils/logic/convertNamespace.d.ts.map +0 -1
- package/dist/esm/utils/logic/genJSModules.d.ts.map +0 -1
- package/dist/esm/utils/style/color.d.ts.map +0 -1
- package/dist/esm/utils/style/getComponentClassName.d.ts.map +0 -1
- package/dist/esm/utils/style/pxtransform.d.ts.map +0 -1
- package/dist/esm/utils/style/types.d.ts.map +0 -1
- package/dist/esm/utils/templates/component.d.ts.map +0 -1
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
export default (function (context) {
|
|
2
|
-
var _inputs$format;
|
|
3
|
-
var data = context.data;
|
|
4
|
-
var inputs = context.inputs;
|
|
5
|
-
var outputs = context.outputs;
|
|
6
|
-
(_inputs$format = inputs.format) === null || _inputs$format === void 0 || _inputs$format.call(inputs, function (val) {
|
|
7
|
-
try {
|
|
8
|
-
var input = (val === null || val === void 0 ? void 0 : val.input) !== undefined ? val.input : data.input;
|
|
9
|
-
var format = (val === null || val === void 0 ? void 0 : val.format) || data.format || 'string';
|
|
10
|
-
var options = (val === null || val === void 0 ? void 0 : val.options) || data.options || {};
|
|
11
|
-
if (input === undefined || input === null) {
|
|
12
|
-
outputs.onFail('输入值不能为空');
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
var result;
|
|
16
|
-
switch (format) {
|
|
17
|
-
case 'json':
|
|
18
|
-
if (typeof input === 'string') {
|
|
19
|
-
try {
|
|
20
|
-
result = JSON.parse(input);
|
|
21
|
-
} catch (error) {
|
|
22
|
-
outputs.onFail('JSON解析失败');
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
} else {
|
|
26
|
-
result = JSON.stringify(input, null, 2);
|
|
27
|
-
}
|
|
28
|
-
break;
|
|
29
|
-
case 'string':
|
|
30
|
-
result = String(input);
|
|
31
|
-
break;
|
|
32
|
-
case 'number':
|
|
33
|
-
var num = Number(input);
|
|
34
|
-
if (isNaN(num)) {
|
|
35
|
-
outputs.onFail('无法转换为有效数字');
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
result = options.precision !== undefined ? Number(num.toFixed(options.precision)) : num;
|
|
39
|
-
break;
|
|
40
|
-
case 'boolean':
|
|
41
|
-
result = Boolean(input);
|
|
42
|
-
break;
|
|
43
|
-
case 'date':
|
|
44
|
-
var date = new Date(input);
|
|
45
|
-
if (isNaN(date.getTime())) {
|
|
46
|
-
outputs.onFail('无效的日期格式');
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (options.dateFormat) {
|
|
50
|
-
// 简单的日期格式化
|
|
51
|
-
var year = date.getFullYear();
|
|
52
|
-
var month = String(date.getMonth() + 1).padStart(2, '0');
|
|
53
|
-
var day = String(date.getDate()).padStart(2, '0');
|
|
54
|
-
var hours = String(date.getHours()).padStart(2, '0');
|
|
55
|
-
var minutes = String(date.getMinutes()).padStart(2, '0');
|
|
56
|
-
var seconds = String(date.getSeconds()).padStart(2, '0');
|
|
57
|
-
result = options.dateFormat.replace('YYYY', year.toString()).replace('MM', month).replace('DD', day).replace('HH', hours).replace('mm', minutes).replace('ss', seconds);
|
|
58
|
-
} else {
|
|
59
|
-
result = date.toISOString();
|
|
60
|
-
}
|
|
61
|
-
break;
|
|
62
|
-
case 'base64':
|
|
63
|
-
if (typeof input === 'string') {
|
|
64
|
-
try {
|
|
65
|
-
// 尝试解码Base64
|
|
66
|
-
result = decodeURIComponent(escape(atob(input)));
|
|
67
|
-
} catch (_unused) {
|
|
68
|
-
// 如果解码失败,则编码为Base64
|
|
69
|
-
result = btoa(unescape(encodeURIComponent(input)));
|
|
70
|
-
}
|
|
71
|
-
} else {
|
|
72
|
-
outputs.onFail('Base64转换需要字符串输入');
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
break;
|
|
76
|
-
case 'urlEncode':
|
|
77
|
-
result = encodeURIComponent(String(input));
|
|
78
|
-
break;
|
|
79
|
-
case 'urlDecode':
|
|
80
|
-
try {
|
|
81
|
-
result = decodeURIComponent(String(input));
|
|
82
|
-
} catch (error) {
|
|
83
|
-
outputs.onFail('URL解码失败');
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
break;
|
|
87
|
-
default:
|
|
88
|
-
outputs.onFail("\u4E0D\u652F\u6301\u7684\u683C\u5F0F\u7C7B\u578B: ".concat(format));
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
outputs.onSuccess({
|
|
92
|
-
input: input,
|
|
93
|
-
output: result,
|
|
94
|
-
format: format,
|
|
95
|
-
options: options
|
|
96
|
-
});
|
|
97
|
-
} catch (error) {
|
|
98
|
-
console.error('格式化失败:', error);
|
|
99
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '格式化失败');
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro';
|
|
2
|
-
export default (function (context) {
|
|
3
|
-
var _inputs$getLocation;
|
|
4
|
-
var data = context.data;
|
|
5
|
-
var inputs = context.inputs;
|
|
6
|
-
var outputs = context.outputs;
|
|
7
|
-
(_inputs$getLocation = inputs.getLocation) === null || _inputs$getLocation === void 0 || _inputs$getLocation.call(inputs, function (val) {
|
|
8
|
-
try {
|
|
9
|
-
var locationConfig = {
|
|
10
|
-
type: (val === null || val === void 0 ? void 0 : val.type) || data.type || 'wgs84',
|
|
11
|
-
altitude: (val === null || val === void 0 ? void 0 : val.altitude) !== undefined ? val.altitude : data.altitude || false,
|
|
12
|
-
timeout: (val === null || val === void 0 ? void 0 : val.timeout) || data.timeout || 30000,
|
|
13
|
-
success: function success(res) {
|
|
14
|
-
outputs.onSuccess(res);
|
|
15
|
-
},
|
|
16
|
-
fail: function fail(err) {
|
|
17
|
-
outputs.onFail(err.errMsg || '获取地理位置失败');
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
Taro.getLocation(locationConfig);
|
|
21
|
-
} catch (error) {
|
|
22
|
-
console.error('获取地理位置失败:', error);
|
|
23
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '获取地理位置失败');
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro';
|
|
2
|
-
export default (function (context) {
|
|
3
|
-
var _inputs$getStorage;
|
|
4
|
-
var data = context.data;
|
|
5
|
-
var inputs = context.inputs;
|
|
6
|
-
var outputs = context.outputs;
|
|
7
|
-
(_inputs$getStorage = inputs.getStorage) === null || _inputs$getStorage === void 0 || _inputs$getStorage.call(inputs, function (val) {
|
|
8
|
-
try {
|
|
9
|
-
var key = (val === null || val === void 0 ? void 0 : val.key) || data.key;
|
|
10
|
-
var useSync = (val === null || val === void 0 ? void 0 : val.sync) !== undefined ? val.sync : data.sync || false;
|
|
11
|
-
if (!key) {
|
|
12
|
-
outputs.onFail('存储 key 不能为空');
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (useSync) {
|
|
16
|
-
try {
|
|
17
|
-
var _value = Taro.getStorageSync(key);
|
|
18
|
-
outputs.onSuccess({
|
|
19
|
-
key: key,
|
|
20
|
-
value: _value
|
|
21
|
-
});
|
|
22
|
-
} catch (error) {
|
|
23
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '读取本地缓存失败');
|
|
24
|
-
}
|
|
25
|
-
} else {
|
|
26
|
-
Taro.getStorage({
|
|
27
|
-
key: key,
|
|
28
|
-
success: function success(res) {
|
|
29
|
-
return outputs.onSuccess({
|
|
30
|
-
key: key,
|
|
31
|
-
value: res.data
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
fail: function fail(err) {
|
|
35
|
-
return outputs.onFail(err.errMsg || '读取本地缓存失败');
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
} catch (error) {
|
|
40
|
-
console.error('读取本地缓存失败:', error);
|
|
41
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '读取本地缓存失败');
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro';
|
|
2
|
-
export default (function (context) {
|
|
3
|
-
var _inputs$getSystemInfo;
|
|
4
|
-
var data = context.data;
|
|
5
|
-
var inputs = context.inputs;
|
|
6
|
-
var outputs = context.outputs;
|
|
7
|
-
(_inputs$getSystemInfo = inputs.getSystemInfo) === null || _inputs$getSystemInfo === void 0 || _inputs$getSystemInfo.call(inputs, function (val) {
|
|
8
|
-
try {
|
|
9
|
-
var useSync = (val === null || val === void 0 ? void 0 : val.sync) !== undefined ? val.sync : data.sync || false;
|
|
10
|
-
if (useSync) {
|
|
11
|
-
try {
|
|
12
|
-
var systemInfo = Taro.getSystemInfoSync();
|
|
13
|
-
outputs.onSuccess(systemInfo);
|
|
14
|
-
} catch (error) {
|
|
15
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '获取系统信息失败');
|
|
16
|
-
}
|
|
17
|
-
} else {
|
|
18
|
-
Taro.getSystemInfo({
|
|
19
|
-
success: function success(res) {
|
|
20
|
-
return outputs.onSuccess(res);
|
|
21
|
-
},
|
|
22
|
-
fail: function fail(err) {
|
|
23
|
-
return outputs.onFail(err.errMsg || '获取系统信息失败');
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
} catch (error) {
|
|
28
|
-
console.error('获取系统信息失败:', error);
|
|
29
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '获取系统信息失败');
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
-
import Taro from '@tarojs/taro';
|
|
4
|
-
export default (function (context) {
|
|
5
|
-
var _inputs$show;
|
|
6
|
-
var data = context.data;
|
|
7
|
-
var inputs = context.inputs;
|
|
8
|
-
var outputs = context.outputs;
|
|
9
|
-
(_inputs$show = inputs.show) === null || _inputs$show === void 0 || _inputs$show.call(inputs, /*#__PURE__*/function () {
|
|
10
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(val) {
|
|
11
|
-
var _ref2, _cfg$title, _ref3, _cfg$content, _ref4, _cfg$showCancel, _ref5, _cfg$cancelText, _cfg$cancelColor, _ref6, _cfg$confirmText, _cfg$confirmColor, _outputs$onConfirm, _outputs$onCancel, cfg, modalConfig, res, _outputs$onCancel2;
|
|
12
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13
|
-
while (1) switch (_context.prev = _context.next) {
|
|
14
|
-
case 0:
|
|
15
|
-
_context.prev = 0;
|
|
16
|
-
cfg = typeof val === 'string' ? {
|
|
17
|
-
content: val
|
|
18
|
-
} : val || {};
|
|
19
|
-
modalConfig = {
|
|
20
|
-
title: (_ref2 = (_cfg$title = cfg.title) !== null && _cfg$title !== void 0 ? _cfg$title : data.title) !== null && _ref2 !== void 0 ? _ref2 : '',
|
|
21
|
-
content: (_ref3 = (_cfg$content = cfg.content) !== null && _cfg$content !== void 0 ? _cfg$content : data.content) !== null && _ref3 !== void 0 ? _ref3 : '',
|
|
22
|
-
showCancel: (_ref4 = (_cfg$showCancel = cfg.showCancel) !== null && _cfg$showCancel !== void 0 ? _cfg$showCancel : data.showCancel) !== null && _ref4 !== void 0 ? _ref4 : true,
|
|
23
|
-
cancelText: (_ref5 = (_cfg$cancelText = cfg.cancelText) !== null && _cfg$cancelText !== void 0 ? _cfg$cancelText : data.cancelText) !== null && _ref5 !== void 0 ? _ref5 : '取消',
|
|
24
|
-
cancelColor: (_cfg$cancelColor = cfg.cancelColor) !== null && _cfg$cancelColor !== void 0 ? _cfg$cancelColor : data.cancelColor,
|
|
25
|
-
confirmText: (_ref6 = (_cfg$confirmText = cfg.confirmText) !== null && _cfg$confirmText !== void 0 ? _cfg$confirmText : data.confirmText) !== null && _ref6 !== void 0 ? _ref6 : '确认',
|
|
26
|
-
confirmColor: (_cfg$confirmColor = cfg.confirmColor) !== null && _cfg$confirmColor !== void 0 ? _cfg$confirmColor : data.confirmColor
|
|
27
|
-
}; // editable 不是所有端都支持,按存在即传
|
|
28
|
-
if (cfg.editable !== undefined) modalConfig.editable = cfg.editable;else if (data.editable !== undefined) modalConfig.editable = data.editable;
|
|
29
|
-
_context.next = 6;
|
|
30
|
-
return Taro.showModal(modalConfig);
|
|
31
|
-
case 6:
|
|
32
|
-
res = _context.sent;
|
|
33
|
-
if (res !== null && res !== void 0 && res.confirm) (_outputs$onConfirm = outputs.onConfirm) === null || _outputs$onConfirm === void 0 || _outputs$onConfirm.call(outputs, res);else (_outputs$onCancel = outputs.onCancel) === null || _outputs$onCancel === void 0 || _outputs$onCancel.call(outputs, res);
|
|
34
|
-
_context.next = 14;
|
|
35
|
-
break;
|
|
36
|
-
case 10:
|
|
37
|
-
_context.prev = 10;
|
|
38
|
-
_context.t0 = _context["catch"](0);
|
|
39
|
-
console.error('显示 Modal 失败:', _context.t0);
|
|
40
|
-
(_outputs$onCancel2 = outputs.onCancel) === null || _outputs$onCancel2 === void 0 || _outputs$onCancel2.call(outputs, _context.t0);
|
|
41
|
-
case 14:
|
|
42
|
-
case "end":
|
|
43
|
-
return _context.stop();
|
|
44
|
-
}
|
|
45
|
-
}, _callee, null, [[0, 10]]);
|
|
46
|
-
}));
|
|
47
|
-
return function (_x) {
|
|
48
|
-
return _ref.apply(this, arguments);
|
|
49
|
-
};
|
|
50
|
-
}());
|
|
51
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro';
|
|
2
|
-
export default (function (context) {
|
|
3
|
-
var _inputs$openCamera;
|
|
4
|
-
var data = context.data;
|
|
5
|
-
var inputs = context.inputs;
|
|
6
|
-
var outputs = context.outputs;
|
|
7
|
-
(_inputs$openCamera = inputs.openCamera) === null || _inputs$openCamera === void 0 || _inputs$openCamera.call(inputs, function (val) {
|
|
8
|
-
try {
|
|
9
|
-
var _config = {
|
|
10
|
-
camera: (val === null || val === void 0 ? void 0 : val.camera) || data.camera || 'back',
|
|
11
|
-
flash: (val === null || val === void 0 ? void 0 : val.flash) || data.flash || 'auto',
|
|
12
|
-
quality: (val === null || val === void 0 ? void 0 : val.quality) || data.quality || 'normal'
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// Taro没有直接的打开相机API,我们可以:
|
|
16
|
-
// 1. 使用chooseImage并设置sourceType为camera
|
|
17
|
-
// 2. 或者提示用户使用系统相机
|
|
18
|
-
|
|
19
|
-
Taro.chooseImage({
|
|
20
|
-
count: 1,
|
|
21
|
-
sourceType: ['camera'],
|
|
22
|
-
success: function success(res) {
|
|
23
|
-
outputs.onSuccess({
|
|
24
|
-
type: 'camera',
|
|
25
|
-
tempFilePath: res.tempFilePaths[0],
|
|
26
|
-
tempFile: res.tempFiles[0],
|
|
27
|
-
config: _config
|
|
28
|
-
});
|
|
29
|
-
},
|
|
30
|
-
fail: function fail(err) {
|
|
31
|
-
var _err$errMsg;
|
|
32
|
-
if ((_err$errMsg = err.errMsg) !== null && _err$errMsg !== void 0 && _err$errMsg.includes('cancel')) {
|
|
33
|
-
outputs.onFail('用户取消拍照');
|
|
34
|
-
} else {
|
|
35
|
-
outputs.onFail(err.errMsg || '打开相机失败');
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
} catch (error) {
|
|
40
|
-
console.error('打开相机失败:', error);
|
|
41
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '打开相机失败');
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export default (function (context) {
|
|
2
|
-
var _inputs$openMap;
|
|
3
|
-
var data = context.data;
|
|
4
|
-
var inputs = context.inputs;
|
|
5
|
-
var outputs = context.outputs;
|
|
6
|
-
(_inputs$openMap = inputs.openMap) === null || _inputs$openMap === void 0 || _inputs$openMap.call(inputs, function (val) {
|
|
7
|
-
try {
|
|
8
|
-
var _config = {
|
|
9
|
-
latitude: (val === null || val === void 0 ? void 0 : val.latitude) || data.latitude || 39.9093,
|
|
10
|
-
longitude: (val === null || val === void 0 ? void 0 : val.longitude) || data.longitude || 116.3974,
|
|
11
|
-
scale: (val === null || val === void 0 ? void 0 : val.scale) || data.scale || 16,
|
|
12
|
-
markers: (val === null || val === void 0 ? void 0 : val.markers) || data.markers || [],
|
|
13
|
-
showLocation: (val === null || val === void 0 ? void 0 : val.showLocation) !== undefined ? val.showLocation : data.showLocation || true
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// 小程序环境下,使用Taro的地图组件
|
|
17
|
-
// 这里可以导航到地图页面或直接显示地图
|
|
18
|
-
outputs.onSuccess({
|
|
19
|
-
type: 'map',
|
|
20
|
-
config: _config,
|
|
21
|
-
message: '地图配置已准备就绪,请在页面中使用Map组件显示'
|
|
22
|
-
});
|
|
23
|
-
} catch (error) {
|
|
24
|
-
console.error('打开地图失败:', error);
|
|
25
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '打开地图失败');
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro';
|
|
2
|
-
export default (function (context) {
|
|
3
|
-
var _inputs$openUrl;
|
|
4
|
-
var data = context.data;
|
|
5
|
-
var inputs = context.inputs;
|
|
6
|
-
var outputs = context.outputs;
|
|
7
|
-
(_inputs$openUrl = inputs.openUrl) === null || _inputs$openUrl === void 0 || _inputs$openUrl.call(inputs, function (val) {
|
|
8
|
-
try {
|
|
9
|
-
var url = typeof val === 'string' ? val : (val === null || val === void 0 ? void 0 : val.url) || data.url;
|
|
10
|
-
if (!url) {
|
|
11
|
-
outputs.onFail('URL 地址不能为空');
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// 检查是否为有效的 URL
|
|
16
|
-
if (!/^https?:\/\//.test(url)) {
|
|
17
|
-
outputs.onFail('URL 格式不正确,请以 http:// 或 https:// 开头');
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
Taro.navigateTo({
|
|
21
|
-
url: "/pages/webview/index?url=".concat(encodeURIComponent(url)),
|
|
22
|
-
success: function success() {
|
|
23
|
-
return outputs.onSuccess({
|
|
24
|
-
url: url
|
|
25
|
-
});
|
|
26
|
-
},
|
|
27
|
-
fail: function fail(err) {
|
|
28
|
-
return outputs.onFail(err.errMsg || '打开链接失败');
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
} catch (error) {
|
|
32
|
-
console.error('打开链接失败:', error);
|
|
33
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '打开链接失败');
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro';
|
|
2
|
-
export default (function (context) {
|
|
3
|
-
var _inputs$removeStorage;
|
|
4
|
-
var data = context.data;
|
|
5
|
-
var inputs = context.inputs;
|
|
6
|
-
var outputs = context.outputs;
|
|
7
|
-
(_inputs$removeStorage = inputs.removeStorage) === null || _inputs$removeStorage === void 0 || _inputs$removeStorage.call(inputs, function (val) {
|
|
8
|
-
try {
|
|
9
|
-
var key = (val === null || val === void 0 ? void 0 : val.key) || data.key;
|
|
10
|
-
var useSync = (val === null || val === void 0 ? void 0 : val.sync) !== undefined ? val.sync : data.sync || false;
|
|
11
|
-
if (!key) {
|
|
12
|
-
outputs.onFail('存储 key 不能为空');
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (useSync) {
|
|
16
|
-
try {
|
|
17
|
-
Taro.removeStorageSync(key);
|
|
18
|
-
outputs.onSuccess({
|
|
19
|
-
key: key
|
|
20
|
-
});
|
|
21
|
-
} catch (error) {
|
|
22
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '移除本地缓存失败');
|
|
23
|
-
}
|
|
24
|
-
} else {
|
|
25
|
-
Taro.removeStorage({
|
|
26
|
-
key: key,
|
|
27
|
-
success: function success() {
|
|
28
|
-
return outputs.onSuccess({
|
|
29
|
-
key: key
|
|
30
|
-
});
|
|
31
|
-
},
|
|
32
|
-
fail: function fail(err) {
|
|
33
|
-
return outputs.onFail(err.errMsg || '移除本地缓存失败');
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
} catch (error) {
|
|
38
|
-
console.error('移除本地缓存失败:', error);
|
|
39
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '移除本地缓存失败');
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import Taro from '@tarojs/taro';
|
|
3
|
-
export default (function (context) {
|
|
4
|
-
var _inputs$navigate;
|
|
5
|
-
var data = context.data;
|
|
6
|
-
var inputs = context.inputs;
|
|
7
|
-
var outputs = context.outputs;
|
|
8
|
-
(_inputs$navigate = inputs.navigate) === null || _inputs$navigate === void 0 || _inputs$navigate.call(inputs, function (val) {
|
|
9
|
-
try {
|
|
10
|
-
var type = (val === null || val === void 0 ? void 0 : val.type) || data.type || 'navigateTo';
|
|
11
|
-
var path = (val === null || val === void 0 ? void 0 : val.path) || data.path;
|
|
12
|
-
var params = (val === null || val === void 0 ? void 0 : val.params) || data.params || {};
|
|
13
|
-
var delta = (val === null || val === void 0 ? void 0 : val.delta) || data.delta || 1;
|
|
14
|
-
if (!path && type !== 'navigateBack') {
|
|
15
|
-
outputs.onFail('路由路径不能为空');
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// 构建完整的URL
|
|
20
|
-
var url = path;
|
|
21
|
-
if (params && Object.keys(params).length > 0) {
|
|
22
|
-
var queryString = Object.entries(params).map(function (_ref) {
|
|
23
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
24
|
-
key = _ref2[0],
|
|
25
|
-
value = _ref2[1];
|
|
26
|
-
return "".concat(key, "=").concat(encodeURIComponent(String(value)));
|
|
27
|
-
}).join('&');
|
|
28
|
-
url += (url.includes('?') ? '&' : '?') + queryString;
|
|
29
|
-
}
|
|
30
|
-
switch (type) {
|
|
31
|
-
case 'navigateTo':
|
|
32
|
-
Taro.navigateTo({
|
|
33
|
-
url: url,
|
|
34
|
-
success: function success() {
|
|
35
|
-
return outputs.onSuccess({
|
|
36
|
-
type: type,
|
|
37
|
-
path: url,
|
|
38
|
-
params: params
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
fail: function fail(err) {
|
|
42
|
-
return outputs.onFail(err.errMsg || '页面跳转失败');
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
break;
|
|
46
|
-
case 'redirectTo':
|
|
47
|
-
Taro.redirectTo({
|
|
48
|
-
url: url,
|
|
49
|
-
success: function success() {
|
|
50
|
-
return outputs.onSuccess({
|
|
51
|
-
type: type,
|
|
52
|
-
path: url,
|
|
53
|
-
params: params
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
fail: function fail(err) {
|
|
57
|
-
return outputs.onFail(err.errMsg || '页面重定向失败');
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
break;
|
|
61
|
-
case 'switchTab':
|
|
62
|
-
Taro.switchTab({
|
|
63
|
-
url: url,
|
|
64
|
-
success: function success() {
|
|
65
|
-
return outputs.onSuccess({
|
|
66
|
-
type: type,
|
|
67
|
-
path: url,
|
|
68
|
-
params: params
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
fail: function fail(err) {
|
|
72
|
-
return outputs.onFail(err.errMsg || '切换Tab失败');
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
break;
|
|
76
|
-
case 'reLaunch':
|
|
77
|
-
Taro.reLaunch({
|
|
78
|
-
url: url,
|
|
79
|
-
success: function success() {
|
|
80
|
-
return outputs.onSuccess({
|
|
81
|
-
type: type,
|
|
82
|
-
path: url,
|
|
83
|
-
params: params
|
|
84
|
-
});
|
|
85
|
-
},
|
|
86
|
-
fail: function fail(err) {
|
|
87
|
-
return outputs.onFail(err.errMsg || '重启应用失败');
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
break;
|
|
91
|
-
case 'navigateBack':
|
|
92
|
-
Taro.navigateBack({
|
|
93
|
-
delta: delta,
|
|
94
|
-
success: function success() {
|
|
95
|
-
return outputs.onSuccess({
|
|
96
|
-
type: type,
|
|
97
|
-
delta: delta
|
|
98
|
-
});
|
|
99
|
-
},
|
|
100
|
-
fail: function fail(err) {
|
|
101
|
-
return outputs.onFail(err.errMsg || '返回失败');
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
break;
|
|
105
|
-
default:
|
|
106
|
-
outputs.onFail("\u4E0D\u652F\u6301\u7684\u8DEF\u7531\u7C7B\u578B: ".concat(type));
|
|
107
|
-
}
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.error('路由跳转失败:', error);
|
|
110
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '路由跳转失败');
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
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$scan = inputs.scan) === null || _inputs$scan === void 0 || _inputs$scan.call(inputs, function (val) {
|
|
8
|
-
try {
|
|
9
|
-
var _ref, _val$onlyFromCamera, _ref2, _val$scanType;
|
|
10
|
-
var scanConfig = {
|
|
11
|
-
onlyFromCamera: (_ref = (_val$onlyFromCamera = val === null || val === void 0 ? void 0 : val.onlyFromCamera) !== null && _val$onlyFromCamera !== void 0 ? _val$onlyFromCamera : data.onlyFromCamera) !== null && _ref !== void 0 ? _ref : false,
|
|
12
|
-
scanType: (_ref2 = (_val$scanType = val === null || val === void 0 ? void 0 : val.scanType) !== null && _val$scanType !== void 0 ? _val$scanType : data.scanType) !== null && _ref2 !== void 0 ? _ref2 : ['barCode', 'qrCode'],
|
|
13
|
-
success: function success(res) {
|
|
14
|
-
outputs.onSuccess(res.result || res);
|
|
15
|
-
},
|
|
16
|
-
fail: function fail(err) {
|
|
17
|
-
outputs.onFail(err.errMsg || '扫码失败');
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
Taro.scanCode(scanConfig);
|
|
21
|
-
} catch (error) {
|
|
22
|
-
console.error('扫码失败:', error);
|
|
23
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '扫码失败');
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
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 key = (val === null || val === void 0 ? void 0 : val.key) || data.key;
|
|
10
|
-
var _value = (val === null || val === void 0 ? void 0 : val.value) !== undefined ? val.value : data.value;
|
|
11
|
-
var useSync = (val === null || val === void 0 ? void 0 : val.sync) !== undefined ? val.sync : data.sync || false;
|
|
12
|
-
if (!key) {
|
|
13
|
-
outputs.onFail('存储 key 不能为空');
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
var result = {
|
|
17
|
-
key: key,
|
|
18
|
-
value: _value
|
|
19
|
-
};
|
|
20
|
-
if (useSync) {
|
|
21
|
-
Taro.setStorageSync(key, _value);
|
|
22
|
-
outputs.onSuccess(result);
|
|
23
|
-
} else {
|
|
24
|
-
Taro.setStorage({
|
|
25
|
-
key: key,
|
|
26
|
-
data: _value,
|
|
27
|
-
success: function success() {
|
|
28
|
-
return outputs.onSuccess(result);
|
|
29
|
-
},
|
|
30
|
-
fail: function fail(err) {
|
|
31
|
-
return outputs.onFail(err.errMsg || '写入本地缓存失败');
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
} catch (error) {
|
|
36
|
-
console.error('写入本地缓存失败:', error);
|
|
37
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '写入本地缓存失败');
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro';
|
|
2
|
-
export default (function (context) {
|
|
3
|
-
var _inputs$share;
|
|
4
|
-
var data = context.data;
|
|
5
|
-
var inputs = context.inputs;
|
|
6
|
-
var outputs = context.outputs;
|
|
7
|
-
(_inputs$share = inputs.share) === null || _inputs$share === void 0 || _inputs$share.call(inputs, function (val) {
|
|
8
|
-
try {
|
|
9
|
-
var shareData = {
|
|
10
|
-
title: (val === null || val === void 0 ? void 0 : val.title) || data.title || '分享',
|
|
11
|
-
path: (val === null || val === void 0 ? void 0 : val.path) || data.path || '/pages/index/index',
|
|
12
|
-
imageUrl: (val === null || val === void 0 ? void 0 : val.imageUrl) || data.imageUrl
|
|
13
|
-
};
|
|
14
|
-
Taro.showShareMenu({
|
|
15
|
-
withShareTicket: true,
|
|
16
|
-
success: function success() {
|
|
17
|
-
return outputs.onSuccess(shareData);
|
|
18
|
-
},
|
|
19
|
-
fail: function fail(err) {
|
|
20
|
-
return outputs.onFail(err.errMsg || '分享失败');
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
} catch (error) {
|
|
24
|
-
console.error('分享失败:', error);
|
|
25
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '分享失败');
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
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
|
-
try {
|
|
10
|
-
// 构建 Toast 配置
|
|
11
|
-
var toastConfig = {
|
|
12
|
-
title: typeof val === 'string' ? val : (val === null || val === void 0 ? void 0 : val.title) || data.title || '',
|
|
13
|
-
duration: Number(_typeof(val) === 'object' && val !== null && val !== void 0 && val.duration ? val.duration : data.duration || 1000),
|
|
14
|
-
mask: _typeof(val) === 'object' && (val === null || val === void 0 ? void 0 : val.mask) !== undefined ? val.mask : data.mask || false
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// 图标配置
|
|
18
|
-
if (_typeof(val) === 'object' && val !== null && val !== void 0 && val.icon) {
|
|
19
|
-
toastConfig.icon = val.icon;
|
|
20
|
-
} else if (data.icon) {
|
|
21
|
-
toastConfig.icon = data.icon;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// 图片配置
|
|
25
|
-
if (_typeof(val) === 'object' && val !== null && val !== void 0 && val.image) {
|
|
26
|
-
toastConfig.image = val.image;
|
|
27
|
-
} else if (data.image) {
|
|
28
|
-
toastConfig.image = data.image;
|
|
29
|
-
}
|
|
30
|
-
Taro.showToast(toastConfig);
|
|
31
|
-
|
|
32
|
-
// 处理输出回调
|
|
33
|
-
var triggerOutput = function triggerOutput() {
|
|
34
|
-
return outputs.afterShowToast(val);
|
|
35
|
-
};
|
|
36
|
-
if (data.asynchronous) {
|
|
37
|
-
setTimeout(triggerOutput, toastConfig.duration);
|
|
38
|
-
} else {
|
|
39
|
-
triggerOutput();
|
|
40
|
-
}
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.error('显示 Toast 失败:', error);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|