@mybricks/to-code-taro 1.1.5 → 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 +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 +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 +1312 -1018
- 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 +54 -12
- package/dist/cjs/utils/templates/renderManager.js +5 -1
- 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 +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 +1312 -1018
- 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 +66 -12
- package/dist/esm/utils/templates/renderManager.js +4 -5
- 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,30 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro';
|
|
2
|
-
export default (function (context) {
|
|
3
|
-
var _inputs$callPhone;
|
|
4
|
-
var data = context.data;
|
|
5
|
-
var inputs = context.inputs;
|
|
6
|
-
var outputs = context.outputs;
|
|
7
|
-
(_inputs$callPhone = inputs.callPhone) === null || _inputs$callPhone === void 0 || _inputs$callPhone.call(inputs, function (val) {
|
|
8
|
-
try {
|
|
9
|
-
var phoneNumber = typeof val === 'string' ? val : (val === null || val === void 0 ? void 0 : val.phoneNumber) || data.phoneNumber;
|
|
10
|
-
if (!phoneNumber) {
|
|
11
|
-
outputs.onFail('电话号码不能为空');
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
Taro.makePhoneCall({
|
|
15
|
-
phoneNumber: phoneNumber,
|
|
16
|
-
success: function success() {
|
|
17
|
-
return outputs.onSuccess({
|
|
18
|
-
phoneNumber: phoneNumber
|
|
19
|
-
});
|
|
20
|
-
},
|
|
21
|
-
fail: function fail(err) {
|
|
22
|
-
return outputs.onFail(err.errMsg || '拨打电话失败');
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
} catch (error) {
|
|
26
|
-
console.error('拨打电话失败:', error);
|
|
27
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '拨打电话失败');
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro';
|
|
2
|
-
export default (function (context) {
|
|
3
|
-
var _inputs$chooseFile;
|
|
4
|
-
var data = context.data;
|
|
5
|
-
var inputs = context.inputs;
|
|
6
|
-
var outputs = context.outputs;
|
|
7
|
-
(_inputs$chooseFile = inputs.chooseFile) === null || _inputs$chooseFile === void 0 || _inputs$chooseFile.call(inputs, function (val) {
|
|
8
|
-
try {
|
|
9
|
-
var _config$accept, _config$accept2, _config$accept3;
|
|
10
|
-
var _config = {
|
|
11
|
-
accept: (val === null || val === void 0 ? void 0 : val.accept) || data.accept || 'image/*',
|
|
12
|
-
multiple: (val === null || val === void 0 ? void 0 : val.multiple) !== undefined ? val.multiple : data.multiple || false,
|
|
13
|
-
capture: (val === null || val === void 0 ? void 0 : val.capture) || data.capture,
|
|
14
|
-
compressed: (val === null || val === void 0 ? void 0 : val.compressed) !== undefined ? val.compressed : data.compressed,
|
|
15
|
-
maxDuration: (val === null || val === void 0 ? void 0 : val.maxDuration) || data.maxDuration,
|
|
16
|
-
camera: (val === null || val === void 0 ? void 0 : val.camera) || data.camera
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// 根据文件类型选择不同的API
|
|
20
|
-
if ((_config$accept = _config.accept) !== null && _config$accept !== void 0 && _config$accept.startsWith('image/')) {
|
|
21
|
-
// 选择图片
|
|
22
|
-
Taro.chooseImage({
|
|
23
|
-
count: _config.multiple ? 9 : 1,
|
|
24
|
-
sourceType: _config.capture === 'album' ? ['album'] : _config.capture === 'camera' ? ['camera'] : ['album', 'camera'],
|
|
25
|
-
success: function success(res) {
|
|
26
|
-
outputs.onSuccess({
|
|
27
|
-
type: 'image',
|
|
28
|
-
files: res.tempFiles,
|
|
29
|
-
tempFilePaths: res.tempFilePaths
|
|
30
|
-
});
|
|
31
|
-
},
|
|
32
|
-
fail: function fail(err) {
|
|
33
|
-
return outputs.onFail(err.errMsg || '选择图片失败');
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
} else if ((_config$accept2 = _config.accept) !== null && _config$accept2 !== void 0 && _config$accept2.startsWith('video/')) {
|
|
37
|
-
// 选择视频
|
|
38
|
-
Taro.chooseVideo({
|
|
39
|
-
sourceType: _config.capture === 'album' ? ['album'] : _config.capture === 'camera' ? ['camera'] : ['album', 'camera'],
|
|
40
|
-
compressed: _config.compressed,
|
|
41
|
-
maxDuration: _config.maxDuration,
|
|
42
|
-
camera: _config.camera,
|
|
43
|
-
success: function success(res) {
|
|
44
|
-
outputs.onSuccess({
|
|
45
|
-
type: 'video',
|
|
46
|
-
file: res
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
fail: function fail(err) {
|
|
50
|
-
return outputs.onFail(err.errMsg || '选择视频失败');
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
} else if ((_config$accept3 = _config.accept) !== null && _config$accept3 !== void 0 && _config$accept3.startsWith('audio/')) {
|
|
54
|
-
// 选择音频(小程序暂不支持直接选择音频文件,这里返回提示)
|
|
55
|
-
outputs.onFail('小程序暂不支持直接选择音频文件');
|
|
56
|
-
} else {
|
|
57
|
-
// 其他文件类型,使用文件选择器(如果支持)
|
|
58
|
-
if (Taro.chooseMessageFile) {
|
|
59
|
-
Taro.chooseMessageFile({
|
|
60
|
-
count: _config.multiple ? 10 : 1,
|
|
61
|
-
type: 'file',
|
|
62
|
-
success: function success(res) {
|
|
63
|
-
outputs.onSuccess({
|
|
64
|
-
type: 'file',
|
|
65
|
-
files: res.tempFiles
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
fail: function fail(err) {
|
|
69
|
-
return outputs.onFail(err.errMsg || '选择文件失败');
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
} else {
|
|
73
|
-
outputs.onFail('当前环境不支持文件选择');
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
} catch (error) {
|
|
77
|
-
console.error('文件选择失败:', error);
|
|
78
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '文件选择失败');
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import Taro from '@tarojs/taro';
|
|
3
|
-
export default (function (context) {
|
|
4
|
-
var _inputs$chooseMedia;
|
|
5
|
-
var data = context.data;
|
|
6
|
-
var inputs = context.inputs;
|
|
7
|
-
var outputs = context.outputs;
|
|
8
|
-
(_inputs$chooseMedia = inputs.chooseMedia) === null || _inputs$chooseMedia === void 0 || _inputs$chooseMedia.call(inputs, function (val) {
|
|
9
|
-
try {
|
|
10
|
-
var _config = {
|
|
11
|
-
mediaType: (val === null || val === void 0 ? void 0 : val.mediaType) || data.mediaType || ['image', 'video'],
|
|
12
|
-
sourceType: (val === null || val === void 0 ? void 0 : val.sourceType) || data.sourceType || ['album', 'camera'],
|
|
13
|
-
count: (val === null || val === void 0 ? void 0 : val.count) || data.count || 9,
|
|
14
|
-
sizeType: (val === null || val === void 0 ? void 0 : val.sizeType) || data.sizeType || ['original', 'compressed'],
|
|
15
|
-
maxDuration: (val === null || val === void 0 ? void 0 : val.maxDuration) || data.maxDuration || 10,
|
|
16
|
-
camera: (val === null || val === void 0 ? void 0 : val.camera) || data.camera
|
|
17
|
-
};
|
|
18
|
-
Taro.chooseMedia(_objectSpread(_objectSpread({}, _config), {}, {
|
|
19
|
-
success: function success(res) {
|
|
20
|
-
var _res$tempFiles;
|
|
21
|
-
outputs.onSuccess({
|
|
22
|
-
type: res.type,
|
|
23
|
-
tempFiles: res.tempFiles,
|
|
24
|
-
tempFilePaths: res.tempFilePaths || ((_res$tempFiles = res.tempFiles) === null || _res$tempFiles === void 0 ? void 0 : _res$tempFiles.map(function (file) {
|
|
25
|
-
return file.tempFilePath;
|
|
26
|
-
}))
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
fail: function fail(err) {
|
|
30
|
-
outputs.onFail(err.errMsg || '选择媒体失败');
|
|
31
|
-
}
|
|
32
|
-
}));
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error('选择媒体失败:', error);
|
|
35
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '选择媒体失败');
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
-
function callCon(_ref) {
|
|
4
|
-
var env = _ref.env,
|
|
5
|
-
data = _ref.data,
|
|
6
|
-
inputs = _ref.inputs,
|
|
7
|
-
outputs = _ref.outputs,
|
|
8
|
-
onError = _ref.onError;
|
|
9
|
-
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
10
|
-
if (data.connector || data.dynamicConfig) {
|
|
11
|
-
try {
|
|
12
|
-
var _finnalConnector;
|
|
13
|
-
var finnalConnector = _objectSpread(_objectSpread({}, data.connector || {}), {}, {
|
|
14
|
-
outputSchema: data.outputSchema
|
|
15
|
-
});
|
|
16
|
-
if (data.dynamicConfig) {
|
|
17
|
-
finnalConnector = data.dynamicConfig;
|
|
18
|
-
}
|
|
19
|
-
if (data.timeout) {
|
|
20
|
-
finnalConnector.timeout = data.timeout;
|
|
21
|
-
}
|
|
22
|
-
env.request(finnalConnector, params, _objectSpread(_objectSpread({}, data.connectorConfig || {}), {}, {
|
|
23
|
-
outputSchema: (_finnalConnector = finnalConnector) === null || _finnalConnector === void 0 ? void 0 : _finnalConnector.outputSchema,
|
|
24
|
-
isMultipleOutputs: true
|
|
25
|
-
})).then(function (val) {
|
|
26
|
-
var _val$__OUTPUT_ID__, _val$__ORIGIN_RESPONS;
|
|
27
|
-
outputs[(_val$__OUTPUT_ID__ = val === null || val === void 0 ? void 0 : val.__OUTPUT_ID__) !== null && _val$__OUTPUT_ID__ !== void 0 ? _val$__OUTPUT_ID__ : "then"]((_val$__ORIGIN_RESPONS = val === null || val === void 0 ? void 0 : val.__ORIGIN_RESPONSE__) !== null && _val$__ORIGIN_RESPONS !== void 0 ? _val$__ORIGIN_RESPONS : val);
|
|
28
|
-
}).catch(function (err) {
|
|
29
|
-
outputs["catch"](err);
|
|
30
|
-
});
|
|
31
|
-
} catch (ex) {
|
|
32
|
-
console.error(ex);
|
|
33
|
-
outputs["catch"]("\u6267\u884C\u9519\u8BEF ".concat(ex.message || ex));
|
|
34
|
-
//onError(ex.message)
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
outputs["catch"]("\u6CA1\u6709\u9009\u62E9\u63A5\u53E3");
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function isPlainObject(value) {
|
|
41
|
-
if (_typeof(value) !== "object" || value === null) return false;
|
|
42
|
-
var proto = Object.getPrototypeOf(value);
|
|
43
|
-
if (proto === null) return true; // 没有原型的对象也视为普通对象
|
|
44
|
-
|
|
45
|
-
// 检查对象是否是由Object构造函数创建的
|
|
46
|
-
return proto === Object.prototype;
|
|
47
|
-
}
|
|
48
|
-
export default function (_ref2) {
|
|
49
|
-
var env = _ref2.env,
|
|
50
|
-
data = _ref2.data,
|
|
51
|
-
inputs = _ref2.inputs,
|
|
52
|
-
outputs = _ref2.outputs,
|
|
53
|
-
onError = _ref2.onError;
|
|
54
|
-
if (!env.runtime) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (data.immediate) {
|
|
58
|
-
callCon({
|
|
59
|
-
env: env,
|
|
60
|
-
data: data,
|
|
61
|
-
outputs: outputs
|
|
62
|
-
});
|
|
63
|
-
} else {
|
|
64
|
-
inputs["call"](function (params) {
|
|
65
|
-
// 如果 params 不是 对象,则转换为空对象
|
|
66
|
-
if (!isPlainObject(params)) {
|
|
67
|
-
params = {};
|
|
68
|
-
}
|
|
69
|
-
callCon({
|
|
70
|
-
env: env,
|
|
71
|
-
data: data,
|
|
72
|
-
outputs: outputs,
|
|
73
|
-
onError: onError
|
|
74
|
-
}, params);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
// 全局请求头存储
|
|
3
|
-
var globalHeaders = {};
|
|
4
|
-
export default (function (context) {
|
|
5
|
-
var _inputs$setGlobalHead, _inputs$getGlobalHead, _inputs$clearGlobalHe;
|
|
6
|
-
var data = context.data;
|
|
7
|
-
var inputs = context.inputs;
|
|
8
|
-
var outputs = context.outputs;
|
|
9
|
-
(_inputs$setGlobalHead = inputs.setGlobalHeaders) === null || _inputs$setGlobalHead === void 0 || _inputs$setGlobalHead.call(inputs, function (val) {
|
|
10
|
-
try {
|
|
11
|
-
var headers = (val === null || val === void 0 ? void 0 : val.headers) || data.headers || {};
|
|
12
|
-
if (Object.keys(headers).length === 0) {
|
|
13
|
-
outputs.onFail('请求头不能为空');
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// 合并到全局请求头
|
|
18
|
-
globalHeaders = _objectSpread(_objectSpread({}, globalHeaders), headers);
|
|
19
|
-
outputs.onSuccess({
|
|
20
|
-
globalHeaders: _objectSpread({}, globalHeaders),
|
|
21
|
-
addedHeaders: headers
|
|
22
|
-
});
|
|
23
|
-
} catch (error) {
|
|
24
|
-
console.error('设置全局请求头失败:', error);
|
|
25
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '设置全局请求头失败');
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
(_inputs$getGlobalHead = inputs.getGlobalHeaders) === null || _inputs$getGlobalHead === void 0 || _inputs$getGlobalHead.call(inputs, function () {
|
|
29
|
-
try {
|
|
30
|
-
outputs.onSuccess({
|
|
31
|
-
globalHeaders: _objectSpread({}, globalHeaders)
|
|
32
|
-
});
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error('获取全局请求头失败:', error);
|
|
35
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '获取全局请求头失败');
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
(_inputs$clearGlobalHe = inputs.clearGlobalHeaders) === null || _inputs$clearGlobalHe === void 0 || _inputs$clearGlobalHe.call(inputs, function () {
|
|
39
|
-
try {
|
|
40
|
-
var oldHeaders = _objectSpread({}, globalHeaders);
|
|
41
|
-
globalHeaders = {};
|
|
42
|
-
outputs.onSuccess({
|
|
43
|
-
clearedHeaders: oldHeaders,
|
|
44
|
-
globalHeaders: {}
|
|
45
|
-
});
|
|
46
|
-
} catch (error) {
|
|
47
|
-
console.error('清除全局请求头失败:', error);
|
|
48
|
-
outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '清除全局请求头失败');
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// 导出一个工具函数,用于在其他组件中获取全局请求头
|
|
54
|
-
export var getGlobalHeaders = function getGlobalHeaders() {
|
|
55
|
-
return _objectSpread({}, globalHeaders);
|
|
56
|
-
};
|
|
@@ -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
|
-
});
|