refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范
这个提交包含在:
@@ -0,0 +1,36 @@
|
||||
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
|
||||
const isMP = platformInfo.startsWith('mp')
|
||||
const isWeb = platformInfo.startsWith('web')
|
||||
const isIOS = platformInfo.startsWith('ios')
|
||||
|
||||
describe('ExtApi-GetBatteryInfo', () => {
|
||||
if (isWeb || isIOS || isMP) {
|
||||
it('dummyTest', () => {
|
||||
expect(1).toBe(1)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const PAGE_PATH = '/pages/API/get-battery-info/get-battery-info'
|
||||
let page;
|
||||
let res;
|
||||
|
||||
const numberProperties = [
|
||||
'level'
|
||||
]
|
||||
beforeAll(async () => {
|
||||
page = await program.reLaunch(PAGE_PATH)
|
||||
await page.waitFor(600);
|
||||
res = await page.data('data');
|
||||
});
|
||||
|
||||
it('Check properties', async () => {
|
||||
for (const key in res) {
|
||||
const value = res[key];
|
||||
expect(value).not.toBeNull();
|
||||
if (numberProperties.indexOf(key) != -1) {
|
||||
expect(value).toBeGreaterThanOrEqual(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
<template>
|
||||
<view>
|
||||
<text>当前电量:{{data.level}}%</text>
|
||||
<text>是否充电中:{{data.isCharging}}</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
type DataType = {
|
||||
level: number;
|
||||
isCharging: boolean;
|
||||
}
|
||||
|
||||
const data = reactive({
|
||||
level: 0,
|
||||
isCharging: false
|
||||
} as DataType)
|
||||
|
||||
onLoad(() => {
|
||||
try {
|
||||
uni.getBatteryInfo({
|
||||
success: res => {
|
||||
data.level = res.level;
|
||||
data.isCharging = res.isCharging;
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error((e as Error).message);
|
||||
uni.showModal({
|
||||
content: (e as Error).message,
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
data
|
||||
})
|
||||
</script>
|
||||
在新工单中引用
屏蔽一个用户