@tarojs/plugin-platform-harmony-cpp 4.1.0 → 4.1.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1237 -0
- package/dist/runtime/apis/apis.ts +20 -0
- package/dist/runtime/apis/base/crypto.ts +4 -0
- package/dist/runtime/apis/base/debug.ts +5 -0
- package/dist/runtime/apis/base/index.ts +13 -0
- package/dist/runtime/apis/base/performance.ts +8 -0
- package/dist/runtime/apis/base/system.ts +181 -0
- package/dist/runtime/apis/base/update.ts +5 -0
- package/dist/runtime/apis/base/weapp/app-event.ts +75 -0
- package/dist/runtime/apis/base/weapp/life-cycle.ts +21 -0
- package/dist/runtime/apis/canvas/index.ts +27 -0
- package/dist/runtime/apis/data-analysis/index.ts +6 -0
- package/dist/runtime/apis/device/accelerometer.ts +79 -0
- package/dist/runtime/apis/device/accessibility.ts +4 -0
- package/dist/runtime/apis/device/battery.ts +24 -0
- package/dist/runtime/apis/device/bluetooth-ble.ts +19 -0
- package/dist/runtime/apis/device/bluetooth-peripheral.ts +6 -0
- package/dist/runtime/apis/device/bluetooth.ts +16 -0
- package/dist/runtime/apis/device/calendar.ts +5 -0
- package/dist/runtime/apis/device/clipboard.ts +85 -0
- package/dist/runtime/apis/device/compass.ts +21 -0
- package/dist/runtime/apis/device/contact.ts +5 -0
- package/dist/runtime/apis/device/crypto.ts +4 -0
- package/dist/runtime/apis/device/gyroscope.ts +77 -0
- package/dist/runtime/apis/device/iBeacon.ts +10 -0
- package/dist/runtime/apis/device/index.ts +24 -0
- package/dist/runtime/apis/device/keyboard.ts +63 -0
- package/dist/runtime/apis/device/memory.ts +11 -0
- package/dist/runtime/apis/device/motion.ts +6 -0
- package/dist/runtime/apis/device/network.ts +123 -0
- package/dist/runtime/apis/device/nfc.ts +10 -0
- package/dist/runtime/apis/device/phone.ts +44 -0
- package/dist/runtime/apis/device/scan.ts +4 -0
- package/dist/runtime/apis/device/screen.ts +80 -0
- package/dist/runtime/apis/device/sms.ts +4 -0
- package/dist/runtime/apis/device/vibrate.ts +32 -0
- package/dist/runtime/apis/device/wifi.ts +15 -0
- package/dist/runtime/apis/ext/index.ts +5 -0
- package/dist/runtime/apis/files/index.ts +136 -0
- package/dist/runtime/apis/files/manager.ts +942 -0
- package/dist/runtime/apis/framework/index.ts +48 -0
- package/dist/runtime/apis/harmony/task-pool.ts +39 -0
- package/dist/runtime/apis/index.ts +61 -0
- package/dist/runtime/apis/location/index.ts +133 -0
- package/dist/runtime/apis/media/EditorContext.ts +32 -0
- package/dist/runtime/apis/media/audio/index.ts +36 -0
- package/dist/runtime/apis/media/background-audio/index.ts +16 -0
- package/dist/runtime/apis/media/camera.ts +16 -0
- package/dist/runtime/apis/media/common.ts +58 -0
- package/dist/runtime/apis/media/image/index.ts +291 -0
- package/dist/runtime/apis/media/index.ts +13 -0
- package/dist/runtime/apis/media/live.ts +5 -0
- package/dist/runtime/apis/media/map.ts +4 -0
- package/dist/runtime/apis/media/media-recorder.ts +4 -0
- package/dist/runtime/apis/media/recorder.ts +6 -0
- package/dist/runtime/apis/media/video/VideoContext.ts +67 -0
- package/dist/runtime/apis/media/video/index.ts +45 -0
- package/dist/runtime/apis/media/video-decoder.ts +4 -0
- package/dist/runtime/apis/media/video-processing.ts +4 -0
- package/dist/runtime/apis/media/voip.ts +19 -0
- package/dist/runtime/apis/navigate/index.ts +8 -0
- package/dist/runtime/apis/network/downloadFile.ts +85 -0
- package/dist/runtime/apis/network/index.ts +7 -0
- package/dist/runtime/apis/network/mdns.ts +13 -0
- package/dist/runtime/apis/network/request.ts +140 -0
- package/dist/runtime/apis/network/tcp.ts +4 -0
- package/dist/runtime/apis/network/udp.ts +4 -0
- package/dist/runtime/apis/network/uploadFile.ts +105 -0
- package/dist/runtime/apis/network/webSocket.ts +126 -0
- package/dist/runtime/apis/open-api/account.ts +4 -0
- package/dist/runtime/apis/open-api/address.ts +4 -0
- package/dist/runtime/apis/open-api/authorize.ts +5 -0
- package/dist/runtime/apis/open-api/card.ts +5 -0
- package/dist/runtime/apis/open-api/channels-live.ts +11 -0
- package/dist/runtime/apis/open-api/customer-service.ts +4 -0
- package/dist/runtime/apis/open-api/device-voip.ts +5 -0
- package/dist/runtime/apis/open-api/facial.ts +7 -0
- package/dist/runtime/apis/open-api/favorites.ts +5 -0
- package/dist/runtime/apis/open-api/group.ts +4 -0
- package/dist/runtime/apis/open-api/index.ts +21 -0
- package/dist/runtime/apis/open-api/invoice.ts +5 -0
- package/dist/runtime/apis/open-api/license-plate.ts +4 -0
- package/dist/runtime/apis/open-api/login.ts +6 -0
- package/dist/runtime/apis/open-api/my-miniprogram.ts +4 -0
- package/dist/runtime/apis/open-api/privacy.ts +7 -0
- package/dist/runtime/apis/open-api/red-package.ts +4 -0
- package/dist/runtime/apis/open-api/settings.ts +5 -0
- package/dist/runtime/apis/open-api/soter.ts +6 -0
- package/dist/runtime/apis/open-api/subscribe-message.ts +6 -0
- package/dist/runtime/apis/open-api/user-info.ts +70 -0
- package/dist/runtime/apis/open-api/werun.ts +5 -0
- package/dist/runtime/apis/payment/index.ts +6 -0
- package/dist/runtime/apis/route/index.ts +88 -0
- package/dist/runtime/apis/share/index.ts +33 -0
- package/dist/runtime/apis/storage/background-fetch.ts +7 -0
- package/dist/runtime/apis/storage/cache-manager.ts +4 -0
- package/dist/runtime/apis/storage/index.ts +203 -0
- package/dist/runtime/apis/ui/animation/animation.ts +264 -0
- package/dist/runtime/apis/ui/animation/index.ts +7 -0
- package/dist/runtime/apis/ui/background.ts +20 -0
- package/dist/runtime/apis/ui/custom-component.ts +1 -0
- package/dist/runtime/apis/ui/fonts.ts +4 -0
- package/dist/runtime/apis/ui/index.ts +12 -0
- package/dist/runtime/apis/ui/interaction/index.ts +198 -0
- package/dist/runtime/apis/ui/menu.ts +4 -0
- package/dist/runtime/apis/ui/navigation-bar/index.ts +72 -0
- package/dist/runtime/apis/ui/pull-down-refresh.ts +47 -0
- package/dist/runtime/apis/ui/scroll/index.ts +82 -0
- package/dist/runtime/apis/ui/sticky.ts +4 -0
- package/dist/runtime/apis/ui/tab-bar.ts +144 -0
- package/dist/runtime/apis/ui/window.ts +20 -0
- package/dist/runtime/apis/utils/constant.ts +1 -0
- package/dist/runtime/apis/utils/handler.ts +117 -0
- package/dist/runtime/apis/utils/index.ts +105 -0
- package/dist/runtime/apis/utils/permissions.ts +6 -0
- package/dist/runtime/apis/utils/types.ts +12 -0
- package/dist/runtime/apis/utils/unit.ts +104 -0
- package/dist/runtime/apis/utils/validate.ts +87 -0
- package/dist/runtime/apis/worker/index.ts +4 -0
- package/dist/runtime/apis/wxml/index.ts +17 -0
- package/dist/runtime/apis/wxml/intersectionObserver.ts +100 -0
- package/dist/runtime/apis/wxml/nodesRef.ts +58 -0
- package/dist/runtime/apis/wxml/selectorQuery.ts +221 -0
- package/dist/runtime/apischunk/index.d.ts +802 -0
- package/dist/runtime/apischunk/index.js +5054 -0
- package/dist/runtime/components/deprecated.ets +43 -0
- package/dist/runtime/components/index.ets +49 -0
- package/dist/runtime/components/innerHtml.ets +16 -0
- package/dist/runtime/components/navigationBar.ets +65 -0
- package/dist/runtime/components/pageMeta.ets +94 -0
- package/dist/runtime/components/richText.ets +24 -0
- package/dist/runtime/components/slider.ets +119 -0
- package/dist/runtime/components/style.ets +286 -0
- package/dist/runtime/components/switch.ets +73 -0
- package/dist/runtime/components/tag.ts +58 -0
- package/dist/runtime/components/utils/AttributeManager.ets +252 -0
- package/dist/runtime/components/utils/DynamicCenter.ts +41 -0
- package/dist/runtime/components/utils/constant/event.ets +25 -0
- package/dist/runtime/components/utils/constant/style.ets +91 -0
- package/dist/runtime/components/utils/events.ts +26 -0
- package/dist/runtime/components/utils/flexManager.ets +49 -0
- package/dist/runtime/components/utils/helper.ets +51 -0
- package/dist/runtime/components/utils/htmlParser/HarmonyHTMLParser.ts +100 -0
- package/dist/runtime/components/utils/htmlParser/index.ts +58 -0
- package/dist/runtime/components/utils/index.ts +77 -0
- package/dist/runtime/components/utils/styles.ets +41 -0
- package/dist/runtime/components/video.ets +119 -0
- package/dist/runtime/components/webView.ets +55 -0
- package/dist/runtime/components/xComponent.ets +89 -0
- package/dist/runtime/framework/app.ts +248 -0
- package/dist/runtime/framework/connect.ts +24 -0
- package/dist/runtime/framework/constant.ts +3 -0
- package/dist/runtime/framework/hooks.ts +99 -0
- package/dist/runtime/framework/index.ts +15 -0
- package/dist/runtime/framework/native-page.ts +511 -0
- package/dist/runtime/framework/page.ts +256 -0
- package/dist/runtime/framework/utils/index.ts +17 -0
- package/dist/runtime/framework/utils/is.ts +26 -0
- package/dist/runtime/framework-reconciler/componentTree.ts +81 -0
- package/dist/runtime/framework-reconciler/constant.ts +86 -0
- package/dist/runtime/framework-reconciler/domInput.ts +90 -0
- package/dist/runtime/framework-reconciler/event.ts +108 -0
- package/dist/runtime/framework-reconciler/index.ts +99 -0
- package/dist/runtime/framework-reconciler/inputValueTracking.ts +106 -0
- package/dist/runtime/framework-reconciler/props.ts +132 -0
- package/dist/runtime/framework-reconciler/reconciler.ts +202 -0
- package/dist/runtime/framework-reconciler/render.ts +139 -0
- package/dist/runtime/framework-reconciler/workTags.ts +53 -0
- package/dist/runtime/runtime-cpp/bom/URL.ts +2 -0
- package/dist/runtime/runtime-cpp/bom/document.ts +45 -0
- package/dist/runtime/runtime-cpp/bom/history.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/location.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/navigator.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/raf.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/window.ts +57 -0
- package/dist/runtime/runtime-cpp/constant.ts +29 -0
- package/dist/runtime/runtime-cpp/current.ts +48 -0
- package/dist/runtime/runtime-cpp/dom/class-list.ts +41 -0
- package/dist/runtime/runtime-cpp/dom/comment.ts +9 -0
- package/dist/runtime/runtime-cpp/dom/dataSource.ts +87 -0
- package/dist/runtime/runtime-cpp/dom/document.ts +113 -0
- package/dist/runtime/runtime-cpp/dom/element/canvas.ts +285 -0
- package/dist/runtime/runtime-cpp/dom/element/element.ts +262 -0
- package/dist/runtime/runtime-cpp/dom/element/form.ts +371 -0
- package/dist/runtime/runtime-cpp/dom/element/index.ts +129 -0
- package/dist/runtime/runtime-cpp/dom/element/movable.ts +250 -0
- package/dist/runtime/runtime-cpp/dom/element/normal.ts +123 -0
- package/dist/runtime/runtime-cpp/dom/element/scroll_view.ts +32 -0
- package/dist/runtime/runtime-cpp/dom/element/text.ts +9 -0
- package/dist/runtime/runtime-cpp/dom/element/video.ts +66 -0
- package/dist/runtime/runtime-cpp/dom/element/web_view.ts +72 -0
- package/dist/runtime/runtime-cpp/dom/event-source.ts +1 -0
- package/dist/runtime/runtime-cpp/dom/event.ts +187 -0
- package/dist/runtime/runtime-cpp/dom/eventTarget.ts +81 -0
- package/dist/runtime/runtime-cpp/dom/node.ts +307 -0
- package/dist/runtime/runtime-cpp/dom/style.ts +44 -0
- package/dist/runtime/runtime-cpp/dom/stylesheet/index.ts +379 -0
- package/dist/runtime/runtime-cpp/dom/stylesheet/type.ts +212 -0
- package/dist/runtime/runtime-cpp/dom/stylesheet/util.ts +186 -0
- package/dist/runtime/runtime-cpp/emitter/emitter.ts +29 -0
- package/dist/runtime/runtime-cpp/env.ts +1 -0
- package/dist/runtime/runtime-cpp/harmony-library.ts +1 -0
- package/dist/runtime/runtime-cpp/index.ts +79 -0
- package/dist/runtime/runtime-cpp/interface/event.ts +10 -0
- package/dist/runtime/runtime-cpp/interface/index.ts +7 -0
- package/dist/runtime/runtime-cpp/next-tick.ts +14 -0
- package/dist/runtime/runtime-cpp/system.ts +213 -0
- package/dist/runtime/runtime-cpp/utils/index.ts +63 -0
- package/dist/runtime/runtime-cpp/utils/info.ts +123 -0
- package/dist/runtime/runtime-cpp/utils/page.ts +12 -0
- package/dist/runtime/runtime-cpp/utils/router.ts +1 -0
- package/dist/runtime/runtime-harmony/apis/helper.ets +33 -0
- package/dist/runtime/runtime-harmony/apis/network/common.ets +41 -0
- package/dist/runtime/runtime-harmony/apis/network/downloadFile.ets +327 -0
- package/dist/runtime/runtime-harmony/apis/network/index.ets +58 -0
- package/dist/runtime/runtime-harmony/apis/network/request.ets +206 -0
- package/dist/runtime/runtime-harmony/apis/network/uploadFile.ets +190 -0
- package/dist/runtime/runtime-harmony/apis/route.ets +110 -0
- package/dist/runtime/runtime-harmony/apis/taskpool.ets +149 -0
- package/dist/runtime/runtime-harmony/index.ets +41 -0
- package/dist/runtime/runtime-harmony/utils.ts +53 -0
- package/package.json +24 -23
- package/LICENSE +0 -174
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './base'
|
|
2
|
+
export * from './canvas'
|
|
3
|
+
export * from './data-analysis'
|
|
4
|
+
export * from './device'
|
|
5
|
+
export * from './ext'
|
|
6
|
+
export * from './files'
|
|
7
|
+
export * from './framework'
|
|
8
|
+
export * from './harmony/task-pool'
|
|
9
|
+
export * from './location'
|
|
10
|
+
export * from './media'
|
|
11
|
+
export * from './navigate'
|
|
12
|
+
export * from './network'
|
|
13
|
+
export * from './open-api'
|
|
14
|
+
export * from './payment'
|
|
15
|
+
export * from './route'
|
|
16
|
+
export * from './share'
|
|
17
|
+
export * from './storage'
|
|
18
|
+
export * from './ui'
|
|
19
|
+
export * from './worker'
|
|
20
|
+
export * from './wxml'
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
export const setEnableDebug = /* @__PURE__ */ temporarilyNotSupport('setEnableDebug')
|
|
4
|
+
export const getRealtimeLogManager = /* @__PURE__ */ temporarilyNotSupport('getRealtimeLogManager')
|
|
5
|
+
export const getLogManager = /* @__PURE__ */ temporarilyNotSupport('getLogManager')
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
export const canIUse = /* @__PURE__ */ temporarilyNotSupport('canIUse')
|
|
4
|
+
export const arrayBufferToBase64 = /* @__PURE__ */ temporarilyNotSupport('arrayBufferToBase64')
|
|
5
|
+
export const base64ToArrayBuffer = /* @__PURE__ */ temporarilyNotSupport('base64ToArrayBuffer')
|
|
6
|
+
|
|
7
|
+
export * from './crypto'
|
|
8
|
+
export * from './debug'
|
|
9
|
+
export * from './performance'
|
|
10
|
+
export * from './system'
|
|
11
|
+
export * from './update'
|
|
12
|
+
export * from './weapp/app-event'
|
|
13
|
+
export * from './weapp/life-cycle'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
// 性能
|
|
4
|
+
export const reportPerformance = /* @__PURE__ */ temporarilyNotSupport('reportPerformance')
|
|
5
|
+
export const getPerformance = /* @__PURE__ */ temporarilyNotSupport('getPerformance')
|
|
6
|
+
export const preloadWebview = /* @__PURE__ */ temporarilyNotSupport('preloadWebview')
|
|
7
|
+
export const preloadSkylineView = /* @__PURE__ */ temporarilyNotSupport('preloadSkylineView')
|
|
8
|
+
export const preloadAssets = /* @__PURE__ */ temporarilyNotSupport('preloadAssets')
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant'
|
|
2
|
+
// 设备信息,从 API Version 6 开始支持
|
|
3
|
+
import deviceInfo from '@ohos.deviceInfo'
|
|
4
|
+
// 显示设备属性,从 API Version 7 开始支持
|
|
5
|
+
import _display from '@ohos.display'
|
|
6
|
+
// 从 API Version 7 开始支持
|
|
7
|
+
import i18n from '@ohos.i18n'
|
|
8
|
+
import { Current, systemContext, systemPromise, TaroWindowUtil } from '@tarojs/runtime'
|
|
9
|
+
|
|
10
|
+
import { MethodHandler } from '../utils'
|
|
11
|
+
|
|
12
|
+
import type Taro from '@tarojs/taro/types'
|
|
13
|
+
|
|
14
|
+
let currentContext
|
|
15
|
+
|
|
16
|
+
Current.contextPromise.then((context) => {
|
|
17
|
+
currentContext = context
|
|
18
|
+
// 监听配置更新
|
|
19
|
+
currentContext.getApplicationContext().on('environment', {
|
|
20
|
+
onConfigurationUpdated(config) {
|
|
21
|
+
AppStorage.setOrCreate('__TARO_APP_CONFIG', config)
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
/** 获取窗口信息 */
|
|
27
|
+
export const getWindowInfo: typeof Taro.getWindowInfo = () => {
|
|
28
|
+
// Note: 获取实时信息,systemContext 值获取更新可能会被业务逻辑卡住
|
|
29
|
+
const display = _display.getDefaultDisplaySync()
|
|
30
|
+
|
|
31
|
+
const info: ReturnType<typeof Taro.getWindowInfo> & any = {
|
|
32
|
+
/** 设备像素比 */
|
|
33
|
+
pixelRatio: systemContext.densityPixels, // 设备像素比,number
|
|
34
|
+
screenWidth: px2vp(display?.width), // 屏幕宽度,单位vp
|
|
35
|
+
screenHeight: px2vp(display?.height), // 屏幕高度,单位vp
|
|
36
|
+
windowWidth: systemContext.windowWidth || px2vp(display?.width), // 可使用窗口高度,单位px
|
|
37
|
+
windowHeight: systemContext.windowHeight || px2vp(display?.height), // 可使用窗口宽度,单位px
|
|
38
|
+
statusBarHeight: systemContext.statusBarHeight, // 状态栏的高度,单位vp
|
|
39
|
+
safeArea: systemContext.safeArea, // 在竖屏正方向下的安全区域 General.SafeAreaResult 单位为vp
|
|
40
|
+
}
|
|
41
|
+
// Note: Harmony 端特定属性
|
|
42
|
+
info.foldDisplayMode = canIUse('SystemCapability.Window.SessionManager') ? _display.getFoldDisplayMode() : 0 // 折叠屏显示模式
|
|
43
|
+
info.isFoldable = _display.isFoldable()
|
|
44
|
+
info.widthBreakpoint = AppStorage.get('widthBreakpoint') ?? 0
|
|
45
|
+
info.heightBreakpoint = AppStorage.get('heightBreakpoint') ?? 0
|
|
46
|
+
return info
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** 获取设备设置 */
|
|
50
|
+
export const getSystemSetting: typeof Taro.getSystemSetting = () => {
|
|
51
|
+
const isLandscape = systemContext.windowWidth >= systemContext.windowHeight
|
|
52
|
+
const info: ReturnType<typeof Taro.getSystemSetting> & any = {
|
|
53
|
+
bluetoothEnabled: null, // 蓝牙的系统开关
|
|
54
|
+
locationEnabled: null, // 地理位置的系统开关
|
|
55
|
+
wifiEnabled: false, // Wi-Fi 的系统开关
|
|
56
|
+
/** 设备方向 */
|
|
57
|
+
deviceOrientation: isLandscape ? 'landscape' : 'portrait',
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return info
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** 获取设备设置 */
|
|
64
|
+
export const getDeviceInfo: typeof Taro.getDeviceInfo = () => {
|
|
65
|
+
const info: ReturnType<typeof Taro.getDeviceInfo> & any = {}
|
|
66
|
+
if (deviceInfo) {
|
|
67
|
+
info.abi = deviceInfo.abiList || '' // 应用二进制接口类型(仅 Android 支持) string
|
|
68
|
+
info.deviceAbi = deviceInfo.abiList || '' // 设备二进制接口类型(仅 Android 支持) string
|
|
69
|
+
info.brand = deviceInfo.brand // 设备品牌 string
|
|
70
|
+
info.model = deviceInfo.deviceType // 设备型号 string
|
|
71
|
+
info.system = deviceInfo.osFullName // 操作系统及版本 string
|
|
72
|
+
|
|
73
|
+
// Note: 鸿蒙专属属性
|
|
74
|
+
info.securityPatchTag = deviceInfo.securityPatchTag
|
|
75
|
+
info.displayVersion = deviceInfo.displayVersion
|
|
76
|
+
info.incrementalVersion = deviceInfo.incrementalVersion
|
|
77
|
+
info.osReleaseType = deviceInfo.osReleaseType
|
|
78
|
+
info.majorVersion = deviceInfo.majorVersion
|
|
79
|
+
info.seniorVersion = deviceInfo.seniorVersion
|
|
80
|
+
info.featureVersion = deviceInfo.featureVersion
|
|
81
|
+
info.buildVersion = deviceInfo.buildVersion
|
|
82
|
+
info.sdkApiVersion = deviceInfo.sdkApiVersion
|
|
83
|
+
info.firstApiVersion = deviceInfo.firstApiVersion
|
|
84
|
+
info.versionId = deviceInfo.versionId
|
|
85
|
+
info.buildType = deviceInfo.buildType
|
|
86
|
+
info.distributionOSName = deviceInfo.distributionOSName
|
|
87
|
+
info.distributionOSVersion = deviceInfo.distributionOSVersion
|
|
88
|
+
info.distributionOSApiVersion = deviceInfo.distributionOSApiVersion
|
|
89
|
+
info.distributionOSReleaseType = deviceInfo.distributionOSReleaseType
|
|
90
|
+
info.udid = deviceInfo.udid
|
|
91
|
+
info.ODID = deviceInfo.ODID
|
|
92
|
+
}
|
|
93
|
+
info.benchmarkLevel = null // 设备性能等级 number
|
|
94
|
+
info.platform = 'harmony' // 客户端平台 string
|
|
95
|
+
info.CPUType = '' // CPU型号 string
|
|
96
|
+
|
|
97
|
+
return info
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** 获取微信APP基础信息 */
|
|
101
|
+
export const getAppBaseInfo: typeof Taro.getAppBaseInfo = () => {
|
|
102
|
+
const info: ReturnType<typeof Taro.getAppBaseInfo> = {
|
|
103
|
+
SDKVersion: deviceInfo && deviceInfo.sdkApiVersion, // 客户端基础库版本 string
|
|
104
|
+
enableDebug: Current.isDebug, // 是否已打开调试 boolean
|
|
105
|
+
host: deviceInfo && deviceInfo.buildHost, // 当前运行的宿主环境
|
|
106
|
+
language: i18n?.System?.getSystemLanguage?.() || i18n?.getSystemLanguage?.(), // 系统语言
|
|
107
|
+
version: deviceInfo?.displayVersion, // 版本号 string
|
|
108
|
+
// Note: 更新配置时才能记录
|
|
109
|
+
theme:
|
|
110
|
+
AppStorage.get('__TARO_APP_CONFIG')?.colorMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK
|
|
111
|
+
? 'dark'
|
|
112
|
+
: 'light', // 系统当前主题,取值为light或dark 'light' | 'dark'
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return info
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** 获取微信APP授权设置 */
|
|
119
|
+
export const getAppAuthorizeSetting: typeof Taro.getAppAuthorizeSetting = () => {
|
|
120
|
+
const info: ReturnType<typeof Taro.getAppAuthorizeSetting> & any = {
|
|
121
|
+
albumAuthorized: false, // 允许使用相册的开关(仅 iOS 有效) boolean
|
|
122
|
+
bluetoothAuthorized: null, // 允许微信使用蓝牙的开关(仅 iOS 有效)
|
|
123
|
+
cameraAuthorized: null, // 允许使用摄像头的开关 boolean
|
|
124
|
+
locationAuthorized: null, // 定位的开关 boolean
|
|
125
|
+
locationReducedAccuracy: false, // 定位准确度 boolean
|
|
126
|
+
microphoneAuthorized: null, // 麦克风的开关 boolean
|
|
127
|
+
notificationAuthorized: null, // 通知的开关 boolean
|
|
128
|
+
notificationAlertAuthorized: false, // 通知带有提醒的开关(仅 iOS 有效) boolean
|
|
129
|
+
notificationBadgeAuthorized: false, // 通知带有标记的开关(仅 iOS 有效) boolean
|
|
130
|
+
notificationSoundAuthorized: false, // 通知带有声音的开关(仅 iOS 有效)boolean
|
|
131
|
+
phoneCalendarAuthorized: null, // 使用日历的开关 boolean
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return info
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* 同步版本 */
|
|
138
|
+
export const getSystemInfoSync: typeof Taro.getSystemInfoSync = function () {
|
|
139
|
+
const res: any = {
|
|
140
|
+
...getWindowInfo(),
|
|
141
|
+
...getSystemSetting(),
|
|
142
|
+
...getDeviceInfo(),
|
|
143
|
+
...getAppBaseInfo(),
|
|
144
|
+
...getAppAuthorizeSetting(),
|
|
145
|
+
}
|
|
146
|
+
res.fontSizeSetting = null // 用户字体大小(单位px) number
|
|
147
|
+
|
|
148
|
+
return res
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* 异步版本 */
|
|
152
|
+
export const getSystemInfo: typeof Taro.getSystemInfo = function (options = {}) {
|
|
153
|
+
const name = 'getSystemInfo'
|
|
154
|
+
const { success, fail, complete } = options
|
|
155
|
+
const handle = new MethodHandler({ name, success, fail, complete })
|
|
156
|
+
return new Promise((resolve, reject) => {
|
|
157
|
+
Promise.all([TaroWindowUtil.resolver, systemPromise.resolver])
|
|
158
|
+
.then(() => {
|
|
159
|
+
try {
|
|
160
|
+
handle.success(getSystemInfoSync(), { resolve, reject })
|
|
161
|
+
} catch (error) {
|
|
162
|
+
handle.fail(
|
|
163
|
+
{
|
|
164
|
+
errMsg: error && error.toString && error.toString(),
|
|
165
|
+
error: error,
|
|
166
|
+
} as any,
|
|
167
|
+
{ resolve, reject }
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
.catch((error) => {
|
|
172
|
+
handle.fail(
|
|
173
|
+
{
|
|
174
|
+
errMsg: error && error.toString && error.toString(),
|
|
175
|
+
error: error,
|
|
176
|
+
} as any,
|
|
177
|
+
{ resolve, reject }
|
|
178
|
+
)
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import errorManager from '@ohos.app.ability.errorManager'
|
|
2
|
+
|
|
3
|
+
import { temporarilyNotSupport } from '../../utils'
|
|
4
|
+
import { CallbackManager } from '../../utils/handler'
|
|
5
|
+
|
|
6
|
+
import type Taro from '@tarojs/taro/types'
|
|
7
|
+
|
|
8
|
+
const unhandledRejectionCallbackManager = new CallbackManager<[Taro.onUnhandledRejection.Result]>()
|
|
9
|
+
const errorCallbackManager = new CallbackManager<Parameters<Taro.onError.Callback>>()
|
|
10
|
+
|
|
11
|
+
const unhandledRejectionListener = (res: PromiseRejectionEvent) => {
|
|
12
|
+
unhandledRejectionCallbackManager.trigger(res)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const errorListener = (res: ErrorEvent) => {
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
errorCallbackManager.trigger(res.stack || res.message || res)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 应用级事件
|
|
21
|
+
export const onUnhandledRejection: typeof Taro.onUnhandledRejection = callback => {
|
|
22
|
+
unhandledRejectionCallbackManager.add(callback)
|
|
23
|
+
if (unhandledRejectionCallbackManager.count() === 1) {
|
|
24
|
+
errorManager.on('error', {
|
|
25
|
+
unhandledRejectionListener
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const onThemeChange = /* @__PURE__ */ temporarilyNotSupport('onThemeChange')
|
|
31
|
+
export const onPageNotFound = /* @__PURE__ */ temporarilyNotSupport('onPageNotFound')
|
|
32
|
+
export const onLazyLoadError = /* @__PURE__ */ temporarilyNotSupport('onLazyLoadError')
|
|
33
|
+
|
|
34
|
+
export const onError: typeof Taro.onError = callback => {
|
|
35
|
+
errorCallbackManager.add(callback)
|
|
36
|
+
if (errorCallbackManager.count() === 1) {
|
|
37
|
+
errorManager.on('error', {
|
|
38
|
+
onException: errorListener
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const onAudioInterruptionEnd = /* @__PURE__ */ temporarilyNotSupport('onAudioInterruptionEnd')
|
|
44
|
+
export const onAudioInterruptionBegin = /* @__PURE__ */ temporarilyNotSupport('onAudioInterruptionBegin')
|
|
45
|
+
|
|
46
|
+
export const onAppShow = /* @__PURE__ */ temporarilyNotSupport('onAppShow')
|
|
47
|
+
export const onAppHide = /* @__PURE__ */ temporarilyNotSupport('onAppHide')
|
|
48
|
+
|
|
49
|
+
export const offUnhandledRejection: typeof Taro.offUnhandledRejection = callback => {
|
|
50
|
+
unhandledRejectionCallbackManager.remove(callback)
|
|
51
|
+
if (unhandledRejectionCallbackManager.count() === 0) {
|
|
52
|
+
errorManager.off('error', {
|
|
53
|
+
unhandledRejectionListener
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const offThemeChange = /* @__PURE__ */ temporarilyNotSupport('offThemeChange')
|
|
59
|
+
export const offPageNotFound = /* @__PURE__ */ temporarilyNotSupport('offPageNotFound')
|
|
60
|
+
export const offLazyLoadError = /* @__PURE__ */ temporarilyNotSupport('offLazyLoadError')
|
|
61
|
+
|
|
62
|
+
export const offError: typeof Taro.offError = callback => {
|
|
63
|
+
errorCallbackManager.remove(callback)
|
|
64
|
+
if (errorCallbackManager.count() === 0) {
|
|
65
|
+
errorManager.off('error', {
|
|
66
|
+
onException: errorListener
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const offAudioInterruptionEnd = /* @__PURE__ */ temporarilyNotSupport('offAudioInterruptionEnd')
|
|
72
|
+
export const offAudioInterruptionBegin = /* @__PURE__ */ temporarilyNotSupport('offAudioInterruptionBegin')
|
|
73
|
+
|
|
74
|
+
export const offAppShow = /* @__PURE__ */ temporarilyNotSupport('offAppShow')
|
|
75
|
+
export const offAppHide = /* @__PURE__ */ temporarilyNotSupport('offAppHide')
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { eventCenter } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import type Taro from '@tarojs/taro/types'
|
|
4
|
+
|
|
5
|
+
const launchOptions: Taro.getLaunchOptionsSync.LaunchOptions = {
|
|
6
|
+
path: '',
|
|
7
|
+
query: {},
|
|
8
|
+
scene: 0,
|
|
9
|
+
shareTicket: '',
|
|
10
|
+
referrerInfo: {}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function initLaunchOptions (options = {}) {
|
|
14
|
+
Object.assign(launchOptions, options)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
eventCenter.once('__taroRouterLaunch', initLaunchOptions)
|
|
18
|
+
|
|
19
|
+
// 生命周期
|
|
20
|
+
export const getLaunchOptionsSync: typeof Taro.getLaunchOptionsSync = () => launchOptions
|
|
21
|
+
export const getEnterOptionsSync: typeof Taro.getEnterOptionsSync = () => launchOptions
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { eventSource } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import { temporarilyNotSupport } from '../utils'
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import type { TaroCanvasElement } from '@tarojs/runtime'
|
|
7
|
+
// 画布
|
|
8
|
+
|
|
9
|
+
/** 创建离屏 canvas 实例 */
|
|
10
|
+
export const createOffscreenCanvas = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
|
|
11
|
+
|
|
12
|
+
/** 创建 canvas 的绘图上下文 CanvasContext 对象 */
|
|
13
|
+
// export const createCanvasContext = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
|
|
14
|
+
export const createCanvasContext = (canvasId: string) => {
|
|
15
|
+
const dom = eventSource.get(`canvasId-${canvasId}`)
|
|
16
|
+
// return dom as TaroCanvasElement
|
|
17
|
+
if (dom) return (dom as unknown as TaroCanvasElement).context
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** 把当前画布指定区域的内容导出生成指定大小的图片 */
|
|
21
|
+
export const canvasToTempFilePath = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
|
|
22
|
+
|
|
23
|
+
/** 将像素数据绘制到画布 */
|
|
24
|
+
export const canvasPutImageData = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
|
|
25
|
+
|
|
26
|
+
/** 获取 canvas 区域隐含的像素数据 */
|
|
27
|
+
export const canvasGetImageData = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
export const reportMonitor = /* @__PURE__ */ temporarilyNotSupport('reportMonitor')
|
|
4
|
+
export const reportAnalytics = /* @__PURE__ */ temporarilyNotSupport('reportAnalytics')
|
|
5
|
+
export const reportEvent = /* @__PURE__ */ temporarilyNotSupport('reportEvent')
|
|
6
|
+
export const getExptInfoSync = /* @__PURE__ */ temporarilyNotSupport('getExptInfoSync')
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import sensor from '@ohos.sensor'
|
|
2
|
+
|
|
3
|
+
import { CallbackManager, MethodHandler } from '../utils/handler'
|
|
4
|
+
|
|
5
|
+
import type Taro from '@tarojs/taro/types'
|
|
6
|
+
|
|
7
|
+
const callbackManager = new CallbackManager()
|
|
8
|
+
let devicemotionListener
|
|
9
|
+
|
|
10
|
+
const GRAVITY_CONSTANT = 9.8 // 1g = 9.8m/s²
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 停止监听加速度数据。
|
|
14
|
+
*/
|
|
15
|
+
export const stopAccelerometer: typeof Taro.stopAccelerometer = ({ success, fail, complete } = {}) => {
|
|
16
|
+
const res: Partial<TaroGeneral.CallbackResult> = {}
|
|
17
|
+
const handle = new MethodHandler({ name: 'stopAccelerometer', success, fail, complete })
|
|
18
|
+
try {
|
|
19
|
+
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, devicemotionListener)
|
|
20
|
+
return handle.success(res)
|
|
21
|
+
} catch (e) {
|
|
22
|
+
res.errMsg = e.message
|
|
23
|
+
return handle.fail(res)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const INTERVAL_MAP = {
|
|
28
|
+
game: {
|
|
29
|
+
interval: 20 * 1000 * 1000,
|
|
30
|
+
frequency: 50
|
|
31
|
+
},
|
|
32
|
+
ui: {
|
|
33
|
+
interval: 60 * 1000 * 1000,
|
|
34
|
+
frequency: 16.67
|
|
35
|
+
},
|
|
36
|
+
normal: {
|
|
37
|
+
interval: 200 * 1000 * 1000,
|
|
38
|
+
frequency: 5
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 开始监听加速度数据。
|
|
44
|
+
*/
|
|
45
|
+
export const startAccelerometer: typeof Taro.startAccelerometer = ({ interval = 'normal', success, fail, complete } = {}) => {
|
|
46
|
+
const handle = new MethodHandler({ name: 'startAccelerometer', success, fail, complete })
|
|
47
|
+
try {
|
|
48
|
+
const intervalObj = INTERVAL_MAP[interval]
|
|
49
|
+
if (devicemotionListener) {
|
|
50
|
+
stopAccelerometer()
|
|
51
|
+
}
|
|
52
|
+
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, (data) => {
|
|
53
|
+
callbackManager.trigger({
|
|
54
|
+
x: data?.x / GRAVITY_CONSTANT || 0,
|
|
55
|
+
y: data?.y / GRAVITY_CONSTANT || 0,
|
|
56
|
+
z: data?.z / GRAVITY_CONSTANT || 0
|
|
57
|
+
})
|
|
58
|
+
}, {
|
|
59
|
+
interval: intervalObj.interval,
|
|
60
|
+
})
|
|
61
|
+
return handle.success()
|
|
62
|
+
} catch (e) {
|
|
63
|
+
return handle.fail({ errMsg: e.message })
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 监听加速度数据事件。频率根据 Taro.startAccelerometer() 的 interval 参数。可使用 Taro.stopAccelerometer() 停止监听。
|
|
69
|
+
*/
|
|
70
|
+
export const onAccelerometerChange: typeof Taro.onAccelerometerChange = callback => {
|
|
71
|
+
callbackManager.add(callback)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 取消监听加速度数据事件,参数为空,则取消所有的事件监听
|
|
76
|
+
*/
|
|
77
|
+
export const offAccelerometerChange: typeof Taro.offAccelerometerChange = callback => {
|
|
78
|
+
callbackManager.remove(callback)
|
|
79
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import batteryInfo, { BatteryChargeState } from '@ohos.batteryInfo'
|
|
2
|
+
|
|
3
|
+
import { MethodHandler } from '../utils/handler'
|
|
4
|
+
|
|
5
|
+
import type Taro from '@tarojs/taro/types'
|
|
6
|
+
|
|
7
|
+
// 电量
|
|
8
|
+
|
|
9
|
+
export const getBatteryInfoSync: typeof Taro.getBatteryInfoSync = () => ({
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
isCharging: [BatteryChargeState.ENABLE, BatteryChargeState.FULL].includes(batteryInfo.chargingStatus),
|
|
12
|
+
level: batteryInfo.batterySOC
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export const getBatteryInfo: typeof Taro.getBatteryInfo = async ({ success, fail, complete } = {}) => {
|
|
16
|
+
const handle = new MethodHandler<Taro.getBatteryInfo.SuccessCallbackResult>({ name: 'getBatteryInfo', success, fail, complete })
|
|
17
|
+
try {
|
|
18
|
+
return handle.success(getBatteryInfoSync())
|
|
19
|
+
} catch (error) {
|
|
20
|
+
return handle.fail({
|
|
21
|
+
errMsg: error?.message || error
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
// 蓝牙-低功耗中心设备
|
|
4
|
+
export const writeBLECharacteristicValue = /* @__PURE__ */ temporarilyNotSupport('writeBLECharacteristicValue')
|
|
5
|
+
export const setBLEMTU = /* @__PURE__ */ temporarilyNotSupport('setBLEMTU')
|
|
6
|
+
export const readBLECharacteristicValue = /* @__PURE__ */ temporarilyNotSupport('readBLECharacteristicValue')
|
|
7
|
+
export const onBLEMTUChange = /* @__PURE__ */ temporarilyNotSupport('onBLEMTUChange')
|
|
8
|
+
export const onBLEConnectionStateChange = /* @__PURE__ */ temporarilyNotSupport('onBLEConnectionStateChange')
|
|
9
|
+
export const onBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('onBLECharacteristicValueChange')
|
|
10
|
+
export const offBLEMTUChange = /* @__PURE__ */ temporarilyNotSupport('offBLEMTUChange')
|
|
11
|
+
export const offBLEConnectionStateChange = /* @__PURE__ */ temporarilyNotSupport('offBLEConnectionStateChange')
|
|
12
|
+
export const offBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('offBLECharacteristicValueChange')
|
|
13
|
+
export const notifyBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('notifyBLECharacteristicValueChange')
|
|
14
|
+
export const getBLEMTU = /* @__PURE__ */ temporarilyNotSupport('getBLEMTU')
|
|
15
|
+
export const getBLEDeviceServices = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceServices')
|
|
16
|
+
export const getBLEDeviceRSSI = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceRSSI')
|
|
17
|
+
export const getBLEDeviceCharacteristics = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceCharacteristics')
|
|
18
|
+
export const createBLEConnection = /* @__PURE__ */ temporarilyNotSupport('createBLEConnection')
|
|
19
|
+
export const closeBLEConnection = /* @__PURE__ */ temporarilyNotSupport('closeBLEConnection')
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
// 蓝牙-低功耗外围设备
|
|
4
|
+
export const onBLEPeripheralConnectionStateChanged = /* @__PURE__ */ temporarilyNotSupport('onBLEPeripheralConnectionStateChanged')
|
|
5
|
+
export const offBLEPeripheralConnectionStateChanged = /* @__PURE__ */ temporarilyNotSupport('offBLEPeripheralConnectionStateChanged')
|
|
6
|
+
export const createBLEPeripheralServer = /* @__PURE__ */ temporarilyNotSupport('createBLEPeripheralServer')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
// 蓝牙-通用
|
|
4
|
+
export const stopBluetoothDevicesDiscovery = /* @__PURE__ */ temporarilyNotSupport('stopBluetoothDevicesDiscovery')
|
|
5
|
+
export const startBluetoothDevicesDiscovery = /* @__PURE__ */ temporarilyNotSupport('startBluetoothDevicesDiscovery')
|
|
6
|
+
export const openBluetoothAdapter = /* @__PURE__ */ temporarilyNotSupport('openBluetoothAdapter')
|
|
7
|
+
export const onBluetoothDeviceFound = /* @__PURE__ */ temporarilyNotSupport('onBluetoothDeviceFound')
|
|
8
|
+
export const onBluetoothAdapterStateChange = /* @__PURE__ */ temporarilyNotSupport('onBluetoothAdapterStateChange')
|
|
9
|
+
export const offBluetoothDeviceFound = /* @__PURE__ */ temporarilyNotSupport('offBluetoothDeviceFound')
|
|
10
|
+
export const offBluetoothAdapterStateChange = /* @__PURE__ */ temporarilyNotSupport('offBluetoothAdapterStateChange')
|
|
11
|
+
export const makeBluetoothPair = /* @__PURE__ */ temporarilyNotSupport('makeBluetoothPair')
|
|
12
|
+
export const isBluetoothDevicePaired = /* @__PURE__ */ temporarilyNotSupport('isBluetoothDevicePaired')
|
|
13
|
+
export const getConnectedBluetoothDevices = /* @__PURE__ */ temporarilyNotSupport('getConnectedBluetoothDevices')
|
|
14
|
+
export const getBluetoothDevices = /* @__PURE__ */ temporarilyNotSupport('getBluetoothDevices')
|
|
15
|
+
export const getBluetoothAdapterState = /* @__PURE__ */ temporarilyNotSupport('getBluetoothAdapterState')
|
|
16
|
+
export const closeBluetoothAdapter = /* @__PURE__ */ temporarilyNotSupport('closeBluetoothAdapter')
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// 从 API Version 6 开始支持
|
|
2
|
+
import pasteboard from '@ohos.pasteboard'
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { Current } from '@tarojs/runtime'
|
|
5
|
+
import { isString } from '@tarojs/shared'
|
|
6
|
+
|
|
7
|
+
import {} from '../'
|
|
8
|
+
import { callAsyncFail, getParameterError, object2String } from '../utils'
|
|
9
|
+
import { MethodHandler } from '../utils/handler'
|
|
10
|
+
|
|
11
|
+
import type Taro from '@tarojs/taro/types'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 设置系统剪贴板的内容
|
|
15
|
+
*/
|
|
16
|
+
export const setClipboardData: typeof Taro.setClipboardData = function (options) {
|
|
17
|
+
const { data, success, fail, complete } = options
|
|
18
|
+
const handle = new MethodHandler<{ data: string }>({ name: 'setClipboardData', success, fail, complete })
|
|
19
|
+
let res = {}
|
|
20
|
+
|
|
21
|
+
if (!isString(data)) {
|
|
22
|
+
return handle.fail({
|
|
23
|
+
errMsg: getParameterError({
|
|
24
|
+
para: 'data',
|
|
25
|
+
correct: 'String',
|
|
26
|
+
wrong: data
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
const systemPasteboard = pasteboard.getSystemPasteboard()
|
|
33
|
+
const pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, data)
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
systemPasteboard.setDataSync(pasteData)
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
const uiContext = Current?.page?.getUIContext?.()
|
|
39
|
+
|
|
40
|
+
if (!uiContext) return
|
|
41
|
+
|
|
42
|
+
uiContext.getPromptAction().showToast({
|
|
43
|
+
message: '内容已复制',
|
|
44
|
+
duration: 1500,
|
|
45
|
+
bottom: '50%',
|
|
46
|
+
showMode: 1 // 设置弹窗显示模式,显示在应用之上。
|
|
47
|
+
})
|
|
48
|
+
return handle.success({
|
|
49
|
+
data,
|
|
50
|
+
}, { resolve, reject })
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if (error) {
|
|
53
|
+
console.error('Failed to set PasteData. Cause: ' + JSON.stringify(error))
|
|
54
|
+
res = {
|
|
55
|
+
errMsg: 'setClipboardData:fail,error: ' + object2String(error),
|
|
56
|
+
error: error
|
|
57
|
+
}
|
|
58
|
+
callAsyncFail(reject, res, options)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 获取系统剪贴板的内容
|
|
66
|
+
*/
|
|
67
|
+
export const getClipboardData: typeof Taro.getClipboardData = function (options) {
|
|
68
|
+
const { success, fail, complete } = options || {}
|
|
69
|
+
const handle = new MethodHandler({ name: 'getClipboardData', success, fail, complete })
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
const systemPasteboard = pasteboard.getSystemPasteboard()
|
|
72
|
+
systemPasteboard.getData((error, pasteData) => { // callback 形式调用异步接口
|
|
73
|
+
if (error) {
|
|
74
|
+
console.error('Failed to obtain PasteData. Cause: ' + JSON.stringify(error))
|
|
75
|
+
return handle.fail({
|
|
76
|
+
errMsg: object2String(error),
|
|
77
|
+
}, { resolve, reject })
|
|
78
|
+
} else {
|
|
79
|
+
return handle.success({
|
|
80
|
+
data: pasteData.getPrimaryText(),
|
|
81
|
+
}, { resolve, reject })
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 停止监听罗盘数据
|
|
5
|
+
*/
|
|
6
|
+
export const stopCompass = temporarilyNotSupport('stopCompass')
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 开始监听罗盘数据
|
|
10
|
+
*/
|
|
11
|
+
export const startCompass = temporarilyNotSupport('startCompass')
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 监听罗盘数据变化事件。频率:5 次/秒,接口调用后会自动开始监听,可使用 wx.stopCompass 停止监听。
|
|
15
|
+
*/
|
|
16
|
+
export const onCompassChange = temporarilyNotSupport('onCompassChange')
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。
|
|
20
|
+
*/
|
|
21
|
+
export const offCompassChange = temporarilyNotSupport('offCompassChange')
|