refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范
这个提交包含在:
@@ -0,0 +1,38 @@
|
||||
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
|
||||
const isMP = platformInfo.startsWith('mp')
|
||||
|
||||
describe('ExtApi-GetDeviceInfo', () => {
|
||||
if (isMP) {
|
||||
it('skip', () => {
|
||||
expect(1).toBe(1)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const PAGE_PATH = '/pages/API/get-device-info/get-device-info'
|
||||
let page;
|
||||
let res;
|
||||
const stringProperties = [
|
||||
'brand', 'deviceBrand', 'deviceId', 'model', 'deviceModel',
|
||||
'deviceType', 'devicePixelRatio', 'system', 'platform', 'uniRuntimeVersion',
|
||||
'osName', 'osVersion', 'osLanguage', 'osTheme', 'romName', 'romVersion'
|
||||
]
|
||||
beforeAll(async () => {
|
||||
page = await program.reLaunch(PAGE_PATH)
|
||||
await page.waitFor(600);
|
||||
res = await uni.getDeviceInfo();
|
||||
});
|
||||
it('Check properties', async () => {
|
||||
for (const key in res) {
|
||||
const value = res[key];
|
||||
if (stringProperties.indexOf(key) != -1) {
|
||||
expect(value).not.toBeNull();
|
||||
expect(value).not.toBe("");
|
||||
}
|
||||
if (key == 'deviceOrientation') {
|
||||
expect(value).not.toBeNull();
|
||||
expect(['portrait', 'landscape']).toContain(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,83 @@
|
||||
<template>
|
||||
<!-- #ifdef APP -->
|
||||
<scroll-view class="page-scroll-view">
|
||||
<!-- #endif -->
|
||||
<view>
|
||||
<page-head :title="title"></page-head>
|
||||
<view class="uni-common-mt">
|
||||
<view class="uni-list">
|
||||
<view class="uni-list">
|
||||
<view class="uni-list-cell" v-for="(item, _) in data.items" style="align-items: center">
|
||||
<view class="uni-pd">
|
||||
<view class="uni-label" style="width: 180px">{{
|
||||
item.label
|
||||
}}</view>
|
||||
</view>
|
||||
<view class="uni-list-cell-db">
|
||||
<text class="uni-list-cell-db-text">{{
|
||||
item.value == "" ? "未获取" : item.value
|
||||
}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="uni-padding-wrap">
|
||||
<view class="uni-btn-v">
|
||||
<button type="primary" @tap="getDeviceInfo">获取设备信息</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- #ifdef APP -->
|
||||
</scroll-view>
|
||||
<!-- #endif -->
|
||||
</template>
|
||||
<script setup lang="uts">
|
||||
import { setDevicePixelRatio } from '@/store/index.uts'
|
||||
|
||||
type Item = {
|
||||
label : string,
|
||||
value : string,
|
||||
}
|
||||
|
||||
type DataType = {
|
||||
items: Item[];
|
||||
}
|
||||
|
||||
const title = ref('getDeviceInfo')
|
||||
const data = reactive({
|
||||
items: [] as Item[],
|
||||
} as DataType)
|
||||
|
||||
const getDeviceInfo = () => {
|
||||
const res = uni.getDeviceInfo();
|
||||
// 获取像素比, 供截图对比使用
|
||||
setDevicePixelRatio(res.devicePixelRatio !== null ? res.devicePixelRatio! : 1)
|
||||
data.items = [] as Item[];
|
||||
|
||||
const res_str = JSON.stringify(res);
|
||||
const res_obj = JSON.parseObject(res_str);
|
||||
const res_map = res_obj!.toMap();
|
||||
let keys = [] as string[]
|
||||
res_map.forEach((_, key) => {
|
||||
keys.push(key);
|
||||
});
|
||||
keys.sort().forEach(key => {
|
||||
const value = res[key];
|
||||
if (value != null) {
|
||||
const item = {
|
||||
label: key,
|
||||
value: "" + ((typeof value == "object") ? JSON.stringify(value) : value)
|
||||
} as Item;
|
||||
data.items.push(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.uni-pd {
|
||||
padding-left: 15px;
|
||||
}
|
||||
</style>
|
||||
在新工单中引用
屏蔽一个用户