@mybricks/to-code-taro 1.1.5 → 1.1.7
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 +43 -3
- 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 +71 -29
- package/dist/cjs/core/utils/index.js +3 -0
- package/dist/cjs/core/utils/pageRouter.js +34 -11
- package/dist/cjs/core/utils/slots.js +55 -9
- package/dist/cjs/core/utils/tabbar.js +56 -0
- package/dist/cjs/core/utils/useContext.js +42 -2
- package/dist/cjs/core/utils/with.js +9 -34
- package/dist/cjs/generate/generateTaroProjectJson.js +3 -18
- package/dist/cjs/generate/utils/appConfig.d.ts +1 -1
- package/dist/cjs/generate/utils/appConfig.js +22 -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 +5 -10
- package/dist/cjs/processors/processScene.js +13 -1
- package/dist/cjs/processors/processSceneLogic.js +2 -6
- package/dist/cjs/taro-template.json +364 -66
- package/dist/cjs/toCodeTaro.d.ts +1 -2
- package/dist/cjs/utils/builder/buildResult.js +1 -2
- package/dist/cjs/utils/common/ImportManager.d.ts +7 -0
- package/dist/cjs/utils/common/ImportManager.js +19 -1
- package/dist/cjs/utils/logic/genJSModules.js +2 -2
- package/dist/cjs/utils/logic/handleProcess.js +59 -13
- package/dist/cjs/utils/templates/index.js +1 -1
- package/dist/cjs/utils/templates/renderManager.js +5 -5
- package/dist/cjs/utils/templates/scene.js +4 -4
- package/dist/esm/core/mybricks/Subject.js +11 -5
- package/dist/esm/core/mybricks/createJSHandle.js +55 -5
- 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 +109 -39
- package/dist/esm/core/utils/index.js +1 -0
- package/dist/esm/core/utils/pageRouter.js +56 -13
- package/dist/esm/core/utils/slots.js +78 -12
- package/dist/esm/core/utils/tabbar.js +47 -0
- package/dist/esm/core/utils/useContext.js +42 -2
- package/dist/esm/core/utils/with.js +19 -53
- package/dist/esm/generate/generateTaroProjectJson.js +2 -20
- package/dist/esm/generate/utils/appConfig.d.ts +1 -1
- package/dist/esm/generate/utils/appConfig.js +28 -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 +7 -12
- package/dist/esm/processors/processScene.js +23 -3
- package/dist/esm/processors/processSceneLogic.js +3 -5
- package/dist/esm/taro-template.json +364 -66
- package/dist/esm/toCodeTaro.d.ts +1 -2
- package/dist/esm/toCodeTaro.js +1 -1
- package/dist/esm/utils/builder/buildResult.js +1 -2
- package/dist/esm/utils/common/ImportManager.d.ts +7 -0
- package/dist/esm/utils/common/ImportManager.js +42 -14
- package/dist/esm/utils/logic/genJSModules.js +2 -2
- package/dist/esm/utils/logic/handleProcess.js +73 -12
- package/dist/esm/utils/templates/index.js +1 -1
- package/dist/esm/utils/templates/renderManager.js +4 -7
- package/dist/esm/utils/templates/scene.js +2 -2
- 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 -79
- 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/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 -77
- 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
|
@@ -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
|
-
});
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
// 检查浏览器是否支持Web Speech API
|
|
2
|
-
var speechSupported = typeof window !== 'undefined' && 'speechSynthesis' in window;
|
|
3
|
-
var currentUtterance = null;
|
|
4
|
-
export default (function (context) {
|
|
5
|
-
var _inputs$speak, _inputs$stop, _inputs$pause, _inputs$resume;
|
|
6
|
-
var data = context.data;
|
|
7
|
-
var inputs = context.inputs;
|
|
8
|
-
var outputs = context.outputs;
|
|
9
|
-
if (!speechSupported) {
|
|
10
|
-
console.warn('当前环境不支持语音合成功能');
|
|
11
|
-
}
|
|
12
|
-
(_inputs$speak = inputs.speak) === null || _inputs$speak === void 0 || _inputs$speak.call(inputs, function (val) {
|
|
13
|
-
try {
|
|
14
|
-
var text = (val === null || val === void 0 ? void 0 : val.text) || data.text;
|
|
15
|
-
var lang = (val === null || val === void 0 ? void 0 : val.lang) || data.lang || 'zh-CN';
|
|
16
|
-
var rate = (val === null || val === void 0 ? void 0 : val.rate) || data.rate || 1;
|
|
17
|
-
var pitch = (val === null || val === void 0 ? void 0 : val.pitch) || data.pitch || 1;
|
|
18
|
-
var volume = (val === null || val === void 0 ? void 0 : val.volume) || data.volume || 1;
|
|
19
|
-
if (!text) {
|
|
20
|
-
outputs.onFail('待合成的文本不能为空');
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
if (!speechSupported) {
|
|
24
|
-
outputs.onFail('当前环境不支持语音合成功能');
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// 如果有正在播放的语音,先停止
|
|
29
|
-
if (currentUtterance && window.speechSynthesis.speaking) {
|
|
30
|
-
window.speechSynthesis.cancel();
|
|
31
|
-
}
|
|
32
|
-
currentUtterance = new SpeechSynthesisUtterance(text);
|
|
33
|
-
currentUtterance.lang = lang;
|
|
34
|
-
currentUtterance.rate = Math.max(0.1, Math.min(10, rate));
|
|
35
|
-
currentUtterance.pitch = Math.max(0, Math.min(2, pitch));
|
|
36
|
-
currentUtterance.volume = Math.max(0, Math.min(1, volume));
|
|
37
|
-
currentUtterance.onstart = function () {
|
|
38
|
-
outputs.onStart({
|
|
39
|
-
text: text,
|
|
40
|
-
lang: lang,
|
|
41
|
-
rate: rate,
|
|
42
|
-
pitch: pitch,
|
|
43
|
-
volume: volume
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
currentUtterance.onend = function () {
|
|
47
|
-
outputs.onEnd({
|
|
48
|
-
text: text,
|
|
49
|
-
lang: lang,
|
|
50
|
-
rate: rate,
|
|
51
|
-
pitch: pitch,
|
|
52
|
-
volume: volume
|
|
53
|
-
});
|
|
54
|
-
currentUtterance = null;
|
|
55
|
-
};
|
|
56
|
-
currentUtterance.onerror = function (event) {
|
|
57
|
-
outputs.onError({
|
|
58
|
-
error: event.error,
|
|
59
|
-
text: text,
|
|
60
|
-
message: '语音合成失败'
|
|
61
|
-
});
|
|
62
|
-
currentUtterance = null;
|
|
63
|
-
};
|
|
64
|
-
window.speechSynthesis.speak(currentUtterance);
|
|
65
|
-
outputs.onSuccess({
|
|
66
|
-
text: text,
|
|
67
|
-
lang: lang,
|
|
68
|
-
rate: rate,
|
|
69
|
-
pitch: pitch,
|
|
70
|
-
volume: volume
|
|
71
|
-
});
|
|
72
|
-
} catch (error) {
|
|
73
|
-
console.error('语音合成失败:', error);
|
|
74
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '语音合成失败');
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
(_inputs$stop = inputs.stop) === null || _inputs$stop === void 0 || _inputs$stop.call(inputs, function () {
|
|
78
|
-
try {
|
|
79
|
-
if (speechSupported && currentUtterance) {
|
|
80
|
-
window.speechSynthesis.cancel();
|
|
81
|
-
currentUtterance = null;
|
|
82
|
-
outputs.onSuccess('已停止语音播放');
|
|
83
|
-
} else {
|
|
84
|
-
outputs.onFail('没有正在播放的语音');
|
|
85
|
-
}
|
|
86
|
-
} catch (error) {
|
|
87
|
-
console.error('停止语音失败:', error);
|
|
88
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '停止语音失败');
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
(_inputs$pause = inputs.pause) === null || _inputs$pause === void 0 || _inputs$pause.call(inputs, function () {
|
|
92
|
-
try {
|
|
93
|
-
if (speechSupported && window.speechSynthesis.pause) {
|
|
94
|
-
window.speechSynthesis.pause();
|
|
95
|
-
outputs.onSuccess('已暂停语音播放');
|
|
96
|
-
} else {
|
|
97
|
-
outputs.onFail('当前环境不支持暂停功能');
|
|
98
|
-
}
|
|
99
|
-
} catch (error) {
|
|
100
|
-
console.error('暂停语音失败:', error);
|
|
101
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '暂停语音失败');
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
(_inputs$resume = inputs.resume) === null || _inputs$resume === void 0 || _inputs$resume.call(inputs, function () {
|
|
105
|
-
try {
|
|
106
|
-
if (speechSupported && window.speechSynthesis.resume) {
|
|
107
|
-
window.speechSynthesis.resume();
|
|
108
|
-
outputs.onSuccess('已恢复语音播放');
|
|
109
|
-
} else {
|
|
110
|
-
outputs.onFail('当前环境不支持恢复功能');
|
|
111
|
-
}
|
|
112
|
-
} catch (error) {
|
|
113
|
-
console.error('恢复语音失败:', error);
|
|
114
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '恢复语音失败');
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
});
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// 防抖函数实现
|
|
2
|
-
function debounce(func, delay) {
|
|
3
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
4
|
-
var timeoutId = null;
|
|
5
|
-
var lastExecTime = 0;
|
|
6
|
-
var _options$leading = options.leading,
|
|
7
|
-
leading = _options$leading === void 0 ? false : _options$leading,
|
|
8
|
-
_options$trailing = options.trailing,
|
|
9
|
-
trailing = _options$trailing === void 0 ? true : _options$trailing;
|
|
10
|
-
return function () {
|
|
11
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
12
|
-
args[_key] = arguments[_key];
|
|
13
|
-
}
|
|
14
|
-
var currentTime = Date.now();
|
|
15
|
-
if (!timeoutId && leading) {
|
|
16
|
-
func.apply(null, args);
|
|
17
|
-
lastExecTime = currentTime;
|
|
18
|
-
}
|
|
19
|
-
if (timeoutId) {
|
|
20
|
-
clearTimeout(timeoutId);
|
|
21
|
-
}
|
|
22
|
-
timeoutId = setTimeout(function () {
|
|
23
|
-
if (trailing && (!leading || currentTime - lastExecTime >= delay)) {
|
|
24
|
-
func.apply(null, args);
|
|
25
|
-
}
|
|
26
|
-
timeoutId = null;
|
|
27
|
-
}, delay);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
export default (function (context) {
|
|
31
|
-
var _inputs$debounce;
|
|
32
|
-
var data = context.data;
|
|
33
|
-
var inputs = context.inputs;
|
|
34
|
-
var outputs = context.outputs;
|
|
35
|
-
var debouncedFn = null;
|
|
36
|
-
(_inputs$debounce = inputs.debounce) === null || _inputs$debounce === void 0 || _inputs$debounce.call(inputs, function (val) {
|
|
37
|
-
try {
|
|
38
|
-
var delay = (val === null || val === void 0 ? void 0 : val.delay) || data.delay || 300;
|
|
39
|
-
var leading = (val === null || val === void 0 ? void 0 : val.leading) !== undefined ? val.leading : data.leading || false;
|
|
40
|
-
var trailing = (val === null || val === void 0 ? void 0 : val.trailing) !== undefined ? val.trailing : data.trailing || true;
|
|
41
|
-
if (!debouncedFn) {
|
|
42
|
-
debouncedFn = debounce(function () {
|
|
43
|
-
outputs.onExecute({
|
|
44
|
-
delay: delay,
|
|
45
|
-
leading: leading,
|
|
46
|
-
trailing: trailing,
|
|
47
|
-
timestamp: Date.now()
|
|
48
|
-
});
|
|
49
|
-
}, delay, {
|
|
50
|
-
leading: leading,
|
|
51
|
-
trailing: trailing
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// 执行防抖函数
|
|
56
|
-
debouncedFn();
|
|
57
|
-
outputs.onComplete({
|
|
58
|
-
delay: delay,
|
|
59
|
-
leading: leading,
|
|
60
|
-
trailing: trailing
|
|
61
|
-
});
|
|
62
|
-
} catch (error) {
|
|
63
|
-
console.error('防抖执行失败:', error);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|