@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27
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/LICENSE +160 -0
- package/dist/apis/apis.ts +15 -0
- package/dist/apis/base/index.ts +5 -0
- package/dist/apis/base/system.ts +77 -0
- package/dist/apis/device/accelerometer.ts +76 -0
- package/dist/apis/device/battery.ts +24 -0
- package/dist/apis/device/clipboard.ts +70 -0
- package/dist/apis/device/index.ts +9 -0
- package/dist/apis/device/keyboard.ts +62 -0
- package/dist/apis/device/memory.ts +4 -0
- package/dist/apis/device/network.ts +72 -0
- package/dist/apis/device/phone.ts +43 -0
- package/dist/apis/device/screen.ts +79 -0
- package/dist/apis/device/vibrate.ts +24 -0
- package/dist/apis/files/index.ts +135 -0
- package/dist/apis/files/manager.ts +941 -0
- package/dist/apis/framework/index.ts +32 -0
- package/dist/apis/index.ts +124 -0
- package/dist/apis/location/index.ts +133 -0
- package/dist/apis/media/common.ts +74 -0
- package/dist/apis/media/image.ts +122 -0
- package/dist/apis/media/index.ts +3 -0
- package/dist/apis/media/video.ts +86 -0
- package/dist/apis/navigate/index.ts +8 -0
- package/dist/apis/network/downloadFile.ts +113 -0
- package/dist/apis/network/index.ts +4 -0
- package/dist/apis/network/request.ts +113 -0
- package/dist/apis/network/uploadFile.ts +158 -0
- package/dist/apis/network/webSocket.ts +130 -0
- package/dist/apis/open-api/index.ts +7 -0
- package/dist/apis/open-api/user-info/index.ts +85 -0
- package/dist/apis/page/index.ts +92 -0
- package/dist/apis/route/index.ts +138 -0
- package/dist/apis/storage/index.ts +133 -0
- package/dist/apis/tabbar/index.ts +147 -0
- package/dist/apis/ui/animation.ts +222 -0
- package/dist/apis/ui/background.ts +35 -0
- package/dist/apis/ui/index.ts +14 -0
- package/dist/apis/ui/interaction/index.ts +195 -0
- package/dist/apis/ui/navigation-bar/index.ts +33 -0
- package/dist/apis/ui/pull-down-refresh.ts +41 -0
- package/dist/apis/utils/handler.ts +116 -0
- package/dist/apis/utils/index.ts +85 -0
- package/dist/apis/utils/types.ts +12 -0
- package/dist/apis/utils/validate.ts +87 -0
- package/dist/apis/wxml/IntersectionObserver.ts +119 -0
- package/dist/apis/wxml/index.ts +12 -0
- package/dist/apis/wxml/nodesRef.ts +56 -0
- package/dist/apis/wxml/selectorQuery.ts +287 -0
- package/dist/components/components-react.js +51 -0
- package/dist/components/components-react.js.map +1 -0
- package/dist/components-harmony/button/index.css +109 -0
- package/dist/components-harmony/button/index.hml +31 -0
- package/dist/components-harmony/button/index.js +105 -0
- package/dist/components-harmony/camera/index.hml +6 -0
- package/dist/components-harmony/camera/index.js +12 -0
- package/dist/components-harmony/checkbox/index.hml +11 -0
- package/dist/components-harmony/checkbox/index.js +60 -0
- package/dist/components-harmony/checkbox-group/index.hml +3 -0
- package/dist/components-harmony/checkbox-group/index.js +22 -0
- package/dist/components-harmony/cover-image/index.css +4 -0
- package/dist/components-harmony/cover-image/index.hml +9 -0
- package/dist/components-harmony/cover-image/index.js +15 -0
- package/dist/components-harmony/form/index.hml +10 -0
- package/dist/components-harmony/form/index.js +11 -0
- package/dist/components-harmony/icon/index.css +27 -0
- package/dist/components-harmony/icon/index.hml +54 -0
- package/dist/components-harmony/icon/index.js +17 -0
- package/dist/components-harmony/image/index.css +5 -0
- package/dist/components-harmony/image/index.hml +11 -0
- package/dist/components-harmony/image/index.js +28 -0
- package/dist/components-harmony/input/index.hml +21 -0
- package/dist/components-harmony/input/index.js +98 -0
- package/dist/components-harmony/label/index.hml +3 -0
- package/dist/components-harmony/label/index.js +6 -0
- package/dist/components-harmony/navbar/index.css +56 -0
- package/dist/components-harmony/navbar/index.hml +9 -0
- package/dist/components-harmony/navbar/index.js +30 -0
- package/dist/components-harmony/navigator/index.css +8 -0
- package/dist/components-harmony/navigator/index.hml +9 -0
- package/dist/components-harmony/navigator/index.js +104 -0
- package/dist/components-harmony/picker/index.hml +25 -0
- package/dist/components-harmony/picker/index.js +132 -0
- package/dist/components-harmony/picker-view/index.hml +23 -0
- package/dist/components-harmony/picker-view/index.js +161 -0
- package/dist/components-harmony/picker-view-column/index.hml +3 -0
- package/dist/components-harmony/picker-view-column/index.js +3 -0
- package/dist/components-harmony/progress/index.css +4 -0
- package/dist/components-harmony/progress/index.hml +28 -0
- package/dist/components-harmony/progress/index.js +23 -0
- package/dist/components-harmony/radio/index.hml +11 -0
- package/dist/components-harmony/radio/index.js +41 -0
- package/dist/components-harmony/radio-group/index.hml +3 -0
- package/dist/components-harmony/radio-group/index.js +11 -0
- package/dist/components-harmony/rich-text/index.hml +5 -0
- package/dist/components-harmony/rich-text/index.js +16 -0
- package/dist/components-harmony/scroll-view/index.css +5 -0
- package/dist/components-harmony/scroll-view/index.hml +12 -0
- package/dist/components-harmony/scroll-view/index.js +65 -0
- package/dist/components-harmony/slider/index.hml +16 -0
- package/dist/components-harmony/slider/index.js +53 -0
- package/dist/components-harmony/swiper/index.css +3 -0
- package/dist/components-harmony/swiper/index.hml +14 -0
- package/dist/components-harmony/swiper/index.js +19 -0
- package/dist/components-harmony/switch/index.hml +7 -0
- package/dist/components-harmony/switch/index.js +16 -0
- package/dist/components-harmony/tabbar/index.css +7 -0
- package/dist/components-harmony/tabbar/index.hml +26 -0
- package/dist/components-harmony/tabbar/index.js +42 -0
- package/dist/components-harmony/textarea/index.hml +24 -0
- package/dist/components-harmony/textarea/index.js +92 -0
- package/dist/components-harmony/utils/index.js +41 -0
- package/dist/components-harmony/video/index.hml +7 -0
- package/dist/components-harmony/video/index.js +73 -0
- package/dist/components-harmony/web-view/index.hml +8 -0
- package/dist/components-harmony/web-view/index.js +22 -0
- package/dist/components-harmony-ets/base.ets +63 -0
- package/dist/components-harmony-ets/button.ets +119 -0
- package/dist/components-harmony-ets/checkbox.ets +219 -0
- package/dist/components-harmony-ets/element.ets +223 -0
- package/dist/components-harmony-ets/form.ets +149 -0
- package/dist/components-harmony-ets/icon.ets +84 -0
- package/dist/components-harmony-ets/image.ets +85 -0
- package/dist/components-harmony-ets/index.ts +49 -0
- package/dist/components-harmony-ets/innerHtml.ets +79 -0
- package/dist/components-harmony-ets/input.ets +195 -0
- package/dist/components-harmony-ets/label.ets +111 -0
- package/dist/components-harmony-ets/picker.ets +370 -0
- package/dist/components-harmony-ets/radio.ets +225 -0
- package/dist/components-harmony-ets/richText.ets +97 -0
- package/dist/components-harmony-ets/scrollView.ets +199 -0
- package/dist/components-harmony-ets/slider.ets +159 -0
- package/dist/components-harmony-ets/swiper.ets +204 -0
- package/dist/components-harmony-ets/switch.ets +113 -0
- package/dist/components-harmony-ets/text.ets +97 -0
- package/dist/components-harmony-ets/textArea.ets +169 -0
- package/dist/components-harmony-ets/utils/AttributeManager.ets +250 -0
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +48 -0
- package/dist/components-harmony-ets/utils/constant/event.ets +25 -0
- package/dist/components-harmony-ets/utils/constant/icon.ts +19 -0
- package/dist/components-harmony-ets/utils/constant/style.ets +88 -0
- package/dist/components-harmony-ets/utils/events.ts +24 -0
- package/dist/components-harmony-ets/utils/flexManager.ets +107 -0
- package/dist/components-harmony-ets/utils/helper.ets +99 -0
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +103 -0
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +56 -0
- package/dist/components-harmony-ets/utils/index.ts +83 -0
- package/dist/components-harmony-ets/utils/styles.ets +91 -0
- package/dist/components-harmony-ets/video.ets +161 -0
- package/dist/components-harmony-ets/view.ets +79 -0
- package/dist/index.js +1183 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime-ets/bom/document.ts +38 -0
- package/dist/runtime-ets/bom/getComputedStyle.ts +5 -0
- package/dist/runtime-ets/bom/navigator.ts +21 -0
- package/dist/runtime-ets/bom/raf.ts +37 -0
- package/dist/runtime-ets/bom/window.ts +44 -0
- package/dist/runtime-ets/constant.ts +29 -0
- package/dist/runtime-ets/current.ts +16 -0
- package/dist/runtime-ets/dom/class-list.ts +117 -0
- package/dist/runtime-ets/dom/comment.ts +10 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +105 -0
- package/dist/runtime-ets/dom/document.ts +108 -0
- package/dist/runtime-ets/dom/element.ts +457 -0
- package/dist/runtime-ets/dom/event.ts +164 -0
- package/dist/runtime-ets/dom/eventTarget.ts +98 -0
- package/dist/runtime-ets/dom/node.ts +215 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +687 -0
- package/dist/runtime-ets/dom/stylesheet/type.ts +136 -0
- package/dist/runtime-ets/dom/stylesheet/util.ts +134 -0
- package/dist/runtime-ets/dom/text.ts +19 -0
- package/dist/runtime-ets/index.ts +19 -0
- package/dist/runtime-ets/interface/event.ts +9 -0
- package/dist/runtime-ets/interface/index.ts +1 -0
- package/dist/runtime-ets/utils/bind.ts +35 -0
- package/dist/runtime-ets/utils/index.ts +135 -0
- package/dist/runtime-ets/utils/info.ts +128 -0
- package/dist/runtime-framework/react/app.ts +256 -0
- package/dist/runtime-framework/react/connect.ts +24 -0
- package/dist/runtime-framework/react/constant.ts +5 -0
- package/dist/runtime-framework/react/hooks.ts +101 -0
- package/dist/runtime-framework/react/index.ts +16 -0
- package/dist/runtime-framework/react/page.ts +263 -0
- package/dist/runtime-framework/react/utils/index.ts +25 -0
- package/dist/runtime-framework/react/utils/is.ts +46 -0
- package/dist/runtime-framework/solid/README.md +99 -0
- package/dist/runtime-framework/solid/app.ts +200 -0
- package/dist/runtime-framework/solid/connect.ts +11 -0
- package/dist/runtime-framework/solid/contant.ts +5 -0
- package/dist/runtime-framework/solid/hooks.ts +88 -0
- package/dist/runtime-framework/solid/index.ts +10 -0
- package/dist/runtime-framework/solid/page.ts +202 -0
- package/dist/runtime-framework/solid/reconciler/h.ts +132 -0
- package/dist/runtime-framework/solid/reconciler/index.ts +3 -0
- package/dist/runtime-framework/solid/reconciler/props.ts +151 -0
- package/dist/runtime-framework/solid/reconciler/render.ts +61 -0
- package/dist/runtime-framework/solid/reconciler/use.ts +8 -0
- package/dist/runtime-framework/solid/utils/index.ts +49 -0
- package/dist/runtime-framework/solid/utils/is.ts +46 -0
- package/dist/runtime-utils.js +4149 -0
- package/dist/runtime-utils.js.map +1 -0
- package/dist/runtime.js +4150 -0
- package/dist/runtime.js.map +1 -0
- package/dist/template/container.js +7 -0
- package/index.js +4 -0
- package/package.json +54 -0
- package/types/api.d.ts +4 -0
- package/types/component.d.ts +4 -0
- package/types/harmony.d.ts +11 -0
- package/types/runtime.d.ts +15 -0
- package/types/taro.d.ts +7 -0
- package/types/webpack-sources.d.ts +108 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// 从API Version 7 开始,该接口不再维护,推荐使用新接口'@ohos.brightness'
|
|
2
|
+
// 但是 新接口 @ohos.brightness 没有 getValue
|
|
3
|
+
import brightness from '@system.brightness'
|
|
4
|
+
import { isNumber } from '@tarojs/shared'
|
|
5
|
+
import Taro from '@tarojs/taro'
|
|
6
|
+
|
|
7
|
+
import { getParameterError, shouldBeObject, temporarilyNotSupport } from '../utils'
|
|
8
|
+
import { MethodHandler } from '../utils/handler'
|
|
9
|
+
|
|
10
|
+
// 屏幕
|
|
11
|
+
export const setVisualEffectOnCapture = /* @__PURE__ */ temporarilyNotSupport('setVisualEffectOnCapture')
|
|
12
|
+
|
|
13
|
+
export const setScreenBrightness: typeof Taro.setScreenBrightness = function (options) {
|
|
14
|
+
// options must be an Object
|
|
15
|
+
const isObject = shouldBeObject(options)
|
|
16
|
+
if (!isObject.flag) {
|
|
17
|
+
const res = { errMsg: `setScreenBrightness:fail ${isObject.msg}` }
|
|
18
|
+
console.error(res.errMsg)
|
|
19
|
+
return Promise.reject(res)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { value, success, fail, complete } = options
|
|
23
|
+
const handle = new MethodHandler<{ code: unknown }>({ name: 'setScreenBrightness', success, fail, complete })
|
|
24
|
+
|
|
25
|
+
if (!isNumber(value)) {
|
|
26
|
+
return handle.fail({
|
|
27
|
+
errMsg: getParameterError({
|
|
28
|
+
para: 'value',
|
|
29
|
+
correct: 'Number',
|
|
30
|
+
wrong: value
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
brightness.setValue({
|
|
37
|
+
// FIXME 不生效
|
|
38
|
+
value: value >= 0 && value <= 1 ? value * 255 : value,
|
|
39
|
+
success: function () {
|
|
40
|
+
return handle.success({}, { resolve, reject })
|
|
41
|
+
},
|
|
42
|
+
fail: function (data, code) {
|
|
43
|
+
return handle.fail({
|
|
44
|
+
errMsg: data || '',
|
|
45
|
+
code
|
|
46
|
+
}, { resolve, reject })
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const setKeepScreenOn = /* @__PURE__ */ temporarilyNotSupport('setKeepScreenOn')
|
|
53
|
+
export const onUserCaptureScreen = /* @__PURE__ */ temporarilyNotSupport('onUserCaptureScreen')
|
|
54
|
+
export const offUserCaptureScreen = /* @__PURE__ */ temporarilyNotSupport('offUserCaptureScreen')
|
|
55
|
+
|
|
56
|
+
export const getScreenBrightness: typeof Taro.getScreenBrightness = function (options) {
|
|
57
|
+
const { success, fail, complete } = options || {}
|
|
58
|
+
const handle = new MethodHandler<Taro.getScreenBrightness.SuccessCallbackOption & { code: unknown }>({ name: 'getScreenBrightness', success, fail, complete })
|
|
59
|
+
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
brightness.getValue({
|
|
62
|
+
success: function (data) {
|
|
63
|
+
return handle.success({
|
|
64
|
+
value: data.value
|
|
65
|
+
}, { resolve, reject })
|
|
66
|
+
},
|
|
67
|
+
fail: function (data, code) {
|
|
68
|
+
return handle.fail({
|
|
69
|
+
errMsg: data || '',
|
|
70
|
+
code
|
|
71
|
+
}, { resolve, reject })
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const onScreenRecordingStateChanged = /* @__PURE__ */ temporarilyNotSupport('onScreenRecordingStateChanged')
|
|
78
|
+
export const offScreenRecordingStateChanged = /* @__PURE__ */ temporarilyNotSupport('offScreenRecordingStateChanged')
|
|
79
|
+
export const getScreenRecordingState = /* @__PURE__ */ temporarilyNotSupport('getScreenRecordingState')
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import vibrator from '@ohos.vibrator'
|
|
2
|
+
|
|
3
|
+
import { callAsyncFail, callAsyncSuccess } from '../utils'
|
|
4
|
+
import { IAsyncParams } from '../utils/types'
|
|
5
|
+
|
|
6
|
+
const VIBRATOR_LONG_TIME = 400
|
|
7
|
+
const VIBRATOR_SHORT_TIME = 15
|
|
8
|
+
|
|
9
|
+
function vibrateBaseGenerator (time: number) {
|
|
10
|
+
return (options: IAsyncParams) => {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
vibrator.vibrate(time).then(() => {
|
|
13
|
+
const res = { errMsg: 'vibrateShort:ok' }
|
|
14
|
+
callAsyncSuccess(resolve, res, options)
|
|
15
|
+
}, (error) => {
|
|
16
|
+
const res = { errMsg: 'vibrateShort:fail' + error }
|
|
17
|
+
callAsyncFail(reject, res, options)
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const vibrateLong = vibrateBaseGenerator(VIBRATOR_LONG_TIME)
|
|
24
|
+
export const vibrateShort = vibrateBaseGenerator(VIBRATOR_SHORT_TIME)
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HarmonyOS 文档:
|
|
3
|
+
* https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-fileio-0000001168366687
|
|
4
|
+
*
|
|
5
|
+
* WX 文档:
|
|
6
|
+
* https://developers.weixin.qq.com/miniprogram/dev/api/file/wx.saveFileToDisk.html
|
|
7
|
+
*
|
|
8
|
+
* Taro.js 文档
|
|
9
|
+
* https://taro-docs.jd.com/taro/docs/apis/files/saveFileToDisk
|
|
10
|
+
*
|
|
11
|
+
* HarmonyOS 不支持接口:
|
|
12
|
+
* saveFileToDisk
|
|
13
|
+
*
|
|
14
|
+
* HarmonyOS 差异性接口:
|
|
15
|
+
* openDocument:showMenu、type 选项无效
|
|
16
|
+
* getSavedFileList:返回值 fileList 中的每一项不包含 createTime 属性
|
|
17
|
+
* getSavedFileInfo:返回值不包含 createTime 属性
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import document from '@ohos.document'
|
|
21
|
+
import fileio from '@ohos.fileio'
|
|
22
|
+
import Taro from '@tarojs/taro'
|
|
23
|
+
|
|
24
|
+
import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../utils'
|
|
25
|
+
import { getFileSystemManager, validateSavedFilePath } from './manager'
|
|
26
|
+
|
|
27
|
+
const filePathSchema = {
|
|
28
|
+
filePath: 'String'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const saveFileToDisk = temporarilyNotSupport('saveFileToDisk')
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* HarmonyOS 不支持 showMenu 选项,并且 type 目前仅支持 *,详情参见:
|
|
35
|
+
* https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-document-0000001168936589#section9616125953711
|
|
36
|
+
*/
|
|
37
|
+
export function openDocument (option: Taro.openDocument.Option): Promise<any> {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
try {
|
|
40
|
+
validateParams('access', option, filePathSchema)
|
|
41
|
+
} catch (error) {
|
|
42
|
+
const res = { errMsg: error.message }
|
|
43
|
+
return callAsyncFail(reject, res, option)
|
|
44
|
+
}
|
|
45
|
+
document.show(option.filePath, '*', (error) => {
|
|
46
|
+
if (error) {
|
|
47
|
+
const res = { errMsg: error.message ? error.message : error }
|
|
48
|
+
return callAsyncFail(reject, res, option)
|
|
49
|
+
} else {
|
|
50
|
+
callAsyncSuccess(resolve, undefined, option)
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function saveFile (option: Taro.saveFile.Option): Promise<any> {
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
const fileSystemManager = getFileSystemManager()
|
|
59
|
+
fileSystemManager.saveFile({
|
|
60
|
+
tempFilePath: option.tempFilePath,
|
|
61
|
+
filePath: option.filePath,
|
|
62
|
+
success: (res) => {
|
|
63
|
+
callAsyncSuccess(resolve, res, option)
|
|
64
|
+
},
|
|
65
|
+
fail: (res) => {
|
|
66
|
+
callAsyncFail(reject, res, option)
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function removeSavedFile (option: Taro.removeSavedFile.Option): Promise<any> {
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
const fileSystemManager = getFileSystemManager()
|
|
75
|
+
fileSystemManager.removeSavedFile({
|
|
76
|
+
filePath: option.filePath,
|
|
77
|
+
success: (res) => {
|
|
78
|
+
callAsyncSuccess(resolve, res, option)
|
|
79
|
+
},
|
|
80
|
+
fail: (res) => {
|
|
81
|
+
callAsyncFail(reject, res, option)
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function getFileInfo (option: Taro.getFileInfo.Option): Promise<Taro.getFileInfo.SuccessCallbackResult | Taro.getFileInfo.FailCallbackResult> {
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
const fileSystemManager = getFileSystemManager()
|
|
90
|
+
fileSystemManager.getFileInfo({
|
|
91
|
+
filePath: option.filePath,
|
|
92
|
+
success: ({ size }) => {
|
|
93
|
+
fileio.hash(option.filePath, option.digestAlgorithm ?? 'md5').then((digest) => {
|
|
94
|
+
callAsyncSuccess(resolve, { size, digest }, option)
|
|
95
|
+
}).catch((error) => {
|
|
96
|
+
const res = { errMsg: error.message ? error.message : error }
|
|
97
|
+
callAsyncFail(reject, res, option)
|
|
98
|
+
})
|
|
99
|
+
},
|
|
100
|
+
fail: (res) => {
|
|
101
|
+
callAsyncFail(reject, res, option)
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function getSavedFileList (option?: Taro.getSavedFileList.Option): Promise<Taro.getSavedFileList.SuccessCallbackResult> {
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
109
|
+
const fileSystemManager = getFileSystemManager()
|
|
110
|
+
fileSystemManager.getSavedFileList({
|
|
111
|
+
success: (res) => callAsyncSuccess(resolve, res, option),
|
|
112
|
+
fail: (res) => callAsyncFail(reject, res, option)
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function getSavedFileInfo (option: Taro.getSavedFileInfo.Option): Promise<Taro.getSavedFileInfo.SuccessCallbackResult> {
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
try {
|
|
120
|
+
validateParams('getSavedFileInfo', option, filePathSchema)
|
|
121
|
+
validateSavedFilePath(option.filePath)
|
|
122
|
+
} catch (error) {
|
|
123
|
+
const res = { errMsg: error.message }
|
|
124
|
+
return callAsyncFail(reject, res, option)
|
|
125
|
+
}
|
|
126
|
+
const fileSystemManager = getFileSystemManager()
|
|
127
|
+
fileSystemManager.getFileInfo({
|
|
128
|
+
filePath: option.filePath,
|
|
129
|
+
success: ({ size }) => callAsyncSuccess(resolve, { size }, option),
|
|
130
|
+
fail: (res) => callAsyncFail(reject, res, option)
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export { getFileSystemManager }
|