refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范

这个提交包含在:
wikiboss
2026-09-20 17:05:22 +08:00
父节点 de3cf8b870
当前提交 9fa1d1fbd0
共有 1679 个文件被更改,包括 204798 次插入 和 16817 次删除

查看文件

@@ -0,0 +1,44 @@
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isMP = platformInfo.startsWith('mp')
describe('ExtApi-GetWindowInfo', () => {
if ( isMP) {
it('skip', async () => {
expect(1).toBe(1);
});
return;
}
const PAGE_PATH = '/pages/API/get-window-info/get-window-info'
let page;
let res;
const numberProperties = [
'pixelRatio', 'screenWidth', 'screenHeight', 'statusBarHeight',
'windowWidth',
'windowHeight', 'windowTop', 'windowBottom', 'screenTop'
]
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(600);
res = await program.callUniMethod('getWindowInfo');
});
it('Check GetWindowInfo', async () => {
for (const key in res) {
const value = res[key];
expect(value).not.toBeNull();
if (numberProperties.indexOf(key) != -1) {
expect(value).toBeGreaterThanOrEqual(0);
}
}
if (isAndroid) {
if (res.safeAreaInsets.bottom > 0) {
expect(res.safeAreaInsets.top + 44 + res.windowHeight).toBe(res.screenHeight);
} else {
expect(res.safeAreaInsets.top + 44 + res.windowHeight).toBe(res.safeArea.bottom);
}
}
});
});

查看文件

@@ -0,0 +1,102 @@
<template>
<page-head :title="title"></page-head>
<view class="uni-common-mt">
<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 class="uni-padding-wrap">
<view class="uni-btn-v">
<button type="primary" @tap="getWindowInfo">获取窗口信息</button>
</view>
<view class="uni-btn-v">
<navigator url="/pages/API/get-window-info/window-area">
<button type="primary">窗口各区域示例</button>
</navigator>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { setStatusBarHeight, setSafeArea } from '@/store/index.uts'
// #ifdef APP-ANDROID
import type { SafeArea } from '@/store/index.uts'
// #endif
type Item = {
label : string,
value : string,
}
type DataType = {
items: Item[];
}
const title = ref('getWindowInfo')
const data = reactive({
items: [] as Item[],
} as DataType)
const getWindowInfo = () => {
const res = uni.getWindowInfo();
// 获取状态栏高度, 供截图对比使用
setStatusBarHeight(res.statusBarHeight);
// 获取安全区信息,供截图使用
// #ifdef APP-ANDROID
setSafeArea({
top: res.safeArea.top,
left: res.safeArea.left,
right: res.safeArea.right,
bottom: res.safeArea.bottom,
width: res.safeArea.width,
height: res.safeArea.height,
} as SafeArea);
// #endif
// #ifdef APP-IOS
setSafeArea({
top: res.safeArea.top,
left: res.safeArea.left,
right: res.safeArea.right,
bottom: res.safeArea.bottom,
width: res.safeArea.width,
height: res.safeArea.height,
});
// #endif
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);
}
});
}
onReady(() => {
getWindowInfo()
})
</script>
<style>
.uni-pd {
padding-left: 15px;
}
</style>

查看文件

@@ -0,0 +1,149 @@
<template>
<view style="flex:1;">
<view id="statusBar" class="statusBar" v-if="statusBarArea.width > 0 && statusBarArea.height > 0"
:style="{'width': statusBarArea.width,'height': statusBarArea.height}">
</view>
<view id="cutoutArea" class="cutoutArea" v-if="cutoutArea.length > 0" v-for="(item, _) in cutoutArea"
:style="{'top': item.top,'left': item.left,'width': item.width,'height': item.height}"></view>
<view id="safeArea" class="safeArea"
:style="{'top': safeArea.top,'left': safeArea.left,'width': safeArea.width,'height': safeArea.height}"></view>
<view id="bottomNavigationIndicator" class="bottomNavigationIndicator"
v-if="bottomNavigationIndicatorArea.width > 0 && bottomNavigationIndicatorArea.height > 0"
:style="{'width': bottomNavigationIndicatorArea.width,'height': bottomNavigationIndicatorArea.height}"></view>
<view style="flex: 1;justify-content: center;align-items: center;">
<view v-if="statusBarArea.width > 0 && statusBarArea.height > 0" style="margin: 5px 0;">
<text style="color: red;">系统状态栏区域</text>
</view>
<view v-if="cutoutArea.length > 0" style="margin: 5px 0;">
<text style="color: orange;">摄像头区域</text>
</view>
<view style="margin: 5px 0;">
<text style="color: green;">安全区域</text>
</view>
<view v-if="bottomNavigationIndicatorArea.width > 0 && bottomNavigationIndicatorArea.height > 0"
style="margin: 5px 0;">
<text style="color: blue;">系统导航栏区域</text>
</view>
<!-- <view style="flex-direction: row;align-items: center;margin: 5px 0">
<text>显示系统状态栏</text>
<switch :checked="isStatusBarShow" @change="statusBarChange"></switch>
</view>
<view style="flex-direction: row;align-items: center;margin: 5px 0">
<text>显示系统导航栏</text>
<switch :checked="isBottomNavigationIndicatorShow" @change="bottomNavigationIndicatorChange"></switch>
</view> -->
</view>
</view>
</template>
<script setup>
type StatusBarArea = {
width : number,
height : number
}
type CutoutArea = {
top : number,
left : number,
width : number,
height : number
}
type SafeArea = {
top : number,
left : number,
width : number,
height : number
}
type BottomNavigationIndicatorArea = {
width : number,
height : number
}
const statusBarArea = ref({ width: 0, height: 0 } as StatusBarArea);
const cutoutArea = ref([] as CutoutArea[]);
const safeArea = ref({ top: 0, left: 0, width: 0, height: 0 } as SafeArea);
const bottomNavigationIndicatorArea = ref({ width: 0, height: 0 } as BottomNavigationIndicatorArea);
const isStatusBarShow = ref(false);
const isBottomNavigationIndicatorShow = ref(false);
const getWindowInfo = () => {
const info = uni.getWindowInfo();
statusBarArea.value.width = info.windowWidth;
statusBarArea.value.height = info.safeAreaInsets.top;
cutoutArea.value.length = 0;
(info.cutoutArea ?? []).forEach((item) => {
cutoutArea.value.push({
top: item.top,
left: item.left,
width: item.right - item.left,
height: item.bottom - item.top
} as CutoutArea);
})
safeArea.value.top = info.safeArea.top;
safeArea.value.left = info.safeArea.left;
safeArea.value.width = info.safeArea.width;
safeArea.value.height = info.safeArea.height;
bottomNavigationIndicatorArea.value.width = info.windowWidth;
bottomNavigationIndicatorArea.value.height = info.safeAreaInsets.bottom;
};
const statusBarChange = (e : UniSwitchChangeEvent) => {
const pages = getCurrentPages();
pages[pages.length - 1].setPageStyle({
'hideStatusBar': !e.detail.value,
});
};
const bottomNavigationIndicatorChange = (e : UniSwitchChangeEvent) => {
const pages = getCurrentPages();
pages[pages.length - 1].setPageStyle({
'hideBottomNavigationIndicator': !e.detail.value,
});
};
onReady(() => {
const pages = getCurrentPages();
// #ifndef MP
isStatusBarShow.value = !(pages[pages.length - 1].getPageStyle()['hideStatusBar'] as boolean);
isBottomNavigationIndicatorShow.value = !(pages[pages.length - 1].getPageStyle()['hideBottomNavigationIndicator'] as boolean);
// #endif
getWindowInfo();
});
onResize((_ : OnResizeOptions) => {
getWindowInfo();
});
</script>
<style>
.statusBar {
position: absolute;
border-style: solid;
border-color: red;
border-width: 4px;
}
.cutoutArea {
position: absolute;
border-style: solid;
border-color: orange;
border-width: 4px;
}
.safeArea {
position: absolute;
border-style: solid;
border-color: green;
border-width: 4px;
}
.bottomNavigationIndicator {
position: absolute;
bottom: 0;
border-style: solid;
border-color: blue;
border-width: 4px;
}
</style>