refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范
这个提交包含在:
@@ -0,0 +1,23 @@
|
||||
export function getBatteryInfo(options) {
|
||||
if (navigator.getBattery) {
|
||||
navigator.getBattery().then(battery => {
|
||||
const res = {
|
||||
errCode: 0,
|
||||
errSubject: "uni-getBatteryInfo",
|
||||
errMsg: 'getBatteryInfo:ok',
|
||||
level: battery.level * 100,
|
||||
isCharging: battery.charging
|
||||
}
|
||||
options.success && options.success(res)
|
||||
options.complete && options.complete(res)
|
||||
})
|
||||
} else {
|
||||
const res = {
|
||||
errCode: 1002,
|
||||
errSubject: "uni-getBatteryInfo",
|
||||
errMsg: 'getBatteryInfo:fail navigator.getBattery is unsupported'
|
||||
}
|
||||
options.fail && options.fail(res)
|
||||
options.complete && options.complete(res)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { GetBatteryInfo, GetBatteryInfoOptions, GetBatteryInfoSuccess } from '../interface.uts'
|
||||
export const getBatteryInfo: GetBatteryInfo = function (options: GetBatteryInfoOptions) {
|
||||
if ((navigator as any).getBattery) {
|
||||
(navigator as any).getBattery().then(battery => {
|
||||
const res = {
|
||||
errCode: 0,
|
||||
errSubject: "uni-getBatteryInfo",
|
||||
errMsg: 'getBatteryInfo:ok',
|
||||
level: battery.level * 100,
|
||||
isCharging: battery.charging
|
||||
} as GetBatteryInfoSuccess
|
||||
options.success && options.success(res)
|
||||
options.complete && options.complete(res)
|
||||
})
|
||||
} else {
|
||||
const res = new UniError("uni-getBatteryInfo", 1002, "getBatteryInfo:fail navigator.getBattery is unsupported")
|
||||
options.fail && options.fail(res)
|
||||
options.complete && options.complete(res)
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户