refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范
这个提交包含在:
@@ -0,0 +1,123 @@
|
||||
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
|
||||
const isAndroid = platformInfo.startsWith('android')
|
||||
const isIos = platformInfo.startsWith('ios')
|
||||
const isHarmony = platformInfo.startsWith('harmony')
|
||||
const isApp = isAndroid || isIos || isHarmony
|
||||
const isAppWebView = process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true'
|
||||
|
||||
const CURRENT_PAGE_PATH = "/pages/template/keyboard-adjust/keyboard-adjust";
|
||||
|
||||
describe("setCustomNavigationBarColor", () => {
|
||||
if (isAppWebView) {
|
||||
it('skip not support', () => {
|
||||
expect(1).toBe(1)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
let page;
|
||||
let originLifeCycleNum;
|
||||
let screenShotArea = {
|
||||
x: 342,
|
||||
y:18,
|
||||
width: 40,
|
||||
height: 20
|
||||
};
|
||||
if (isIos) {
|
||||
screenShotArea.x = 310
|
||||
screenShotArea.y = 20
|
||||
screenShotArea.width = 40
|
||||
screenShotArea.height = 20
|
||||
} else if (platformInfo.startsWith('android 6')) {
|
||||
screenShotArea.x = 204
|
||||
screenShotArea.width = 34
|
||||
screenShotArea.height = 16
|
||||
} else if (platformInfo.startsWith('android 12')) {
|
||||
screenShotArea.x = 336
|
||||
screenShotArea.y = 3
|
||||
screenShotArea.width = 50
|
||||
screenShotArea.height = 20
|
||||
} else if (isHarmony) {
|
||||
screenShotArea.x = 295
|
||||
screenShotArea.y = 14
|
||||
screenShotArea.width = 40
|
||||
screenShotArea.height = 20
|
||||
}
|
||||
beforeAll(async () => {
|
||||
page = await program.navigateTo(CURRENT_PAGE_PATH);
|
||||
await page.waitFor('view');
|
||||
originLifeCycleNum = await page.callMethod("getLifeCycleNum");
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await page.callMethod("setLifeCycleNum", originLifeCycleNum);
|
||||
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
|
||||
expect(lifeCycleNum).toBe(originLifeCycleNum);
|
||||
});
|
||||
|
||||
it("setNavigationBarColor-black", async () => {
|
||||
await page.callMethod("setNavigationBarColor2");
|
||||
await page.waitFor(1000);
|
||||
if (isApp) {
|
||||
const image = await program.screenshot({
|
||||
deviceShot: true,
|
||||
area: screenShotArea,
|
||||
});
|
||||
expect(image).toSaveImageSnapshot();
|
||||
}
|
||||
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
|
||||
expect(lifeCycleNum - originLifeCycleNum).toBe(2);
|
||||
});
|
||||
|
||||
it("setNavigationBarColor-white", async () => {
|
||||
await page.callMethod("setNavigationBarColor1");
|
||||
await page.waitFor(1000);
|
||||
if (isApp) {
|
||||
const image = await program.screenshot({
|
||||
deviceShot: true,
|
||||
area: screenShotArea,
|
||||
});
|
||||
expect(image).toSaveImageSnapshot();
|
||||
}
|
||||
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
|
||||
expect(lifeCycleNum - originLifeCycleNum).toBe(4);
|
||||
});
|
||||
|
||||
if (isApp) {
|
||||
it("input-in-scroll-view-focus", async () => {
|
||||
const windowInfo = await program.callUniMethod('getWindowInfo');
|
||||
let topSafeArea = windowInfo.statusBarHeight;
|
||||
screenShotArea = {
|
||||
x: 0,
|
||||
y: topSafeArea
|
||||
}
|
||||
await page.setData({ data: { indexView: 2 } });
|
||||
await page.waitFor(1000);
|
||||
await page.setData({ data: { indexView: 0 } });
|
||||
await page.waitFor(1000);
|
||||
await page.setData({ data: { scrollViewInputFocus: true } });
|
||||
await page.waitFor(1000);
|
||||
const image = await program.screenshot({
|
||||
deviceShot: true,
|
||||
area: screenShotArea,
|
||||
});
|
||||
expect(image).toSaveImageSnapshot();
|
||||
await page.setData({ data: { scrollViewInputFocus: false } });
|
||||
await page.waitFor(1000);
|
||||
});
|
||||
|
||||
it("input-in-list-view-focus", async () => {
|
||||
await page.setData({ data: { indexView: 1 } });
|
||||
await page.waitFor(1000);
|
||||
await page.setData({ data: { listViewInputFocus: true } });
|
||||
await page.waitFor(1000);
|
||||
const image = await program.screenshot({
|
||||
deviceShot: true,
|
||||
area: screenShotArea,
|
||||
});
|
||||
expect(image).toSaveImageSnapshot();
|
||||
await page.setData({ data: { listViewInputFocus: false } });
|
||||
await page.waitFor(1000);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,169 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<uni-nav-bar :title="title" :navigationBarTextStyle="navigationBarTextColor"></uni-nav-bar>
|
||||
<view style="align-items: center;height: 60px;">
|
||||
<text>输入框上推示例</text>
|
||||
<radio-group @change="ChangeView" style="flex-direction: row;">
|
||||
<radio value="0" :checked="true"><text>scroll-view</text></radio>
|
||||
<radio value="1"><text>list-view</text></radio>
|
||||
<!-- #ifndef MP -->
|
||||
<radio value="2"><text>web-view</text></radio>
|
||||
<!-- #endif -->
|
||||
</radio-group>
|
||||
</view>
|
||||
<scroll-view v-if="data.indexView==0" class="scroll-view" :refresher-enabled="false">
|
||||
<view class="content-item" v-for="item in 10">
|
||||
<view class="cell-item">
|
||||
<text class="text">内容:{{item}}</text>
|
||||
<input class="text" style="margin-top: 8px;" placeholder="备注输入框:" :id="`input-in-scroll-view-${item}`" :focus="item == 5 ? data.scrollViewInputFocus : false" />
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<list-view v-if="data.indexView==1" class="scroll-view">
|
||||
<list-item class="content-item" v-for="item in 10" :key="item">
|
||||
<view class="cell-item">
|
||||
<text class="text">列表项内容:{{item}}</text>
|
||||
<input class="text" style="margin-top: 8px;" placeholder="备注输入框:" :id="`input-in-list-view-${item}`" :focus="item == 5 ? data.listViewInputFocus : false" />
|
||||
</view>
|
||||
</list-item>
|
||||
</list-view>
|
||||
<web-view v-if="data.indexView==2" src="/hybrid/html/local.html" id="webv" class="scroll-view"></web-view>
|
||||
<view class="bottomInput" :style="{bottom: inputBottom}">
|
||||
<input id="input" style="background-color: white;" placeholder="滚动视图外底部输入框,焦点时手动控制显示位置" :adjust-position="false" @blur="onInputBlur" @keyboardheightchange="onInputKeyboardChange" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
/**
|
||||
* @description: 演示软键盘弹起时,scroll-view、list-view、web-view 等容器中的输入框避让与底部输入框位置调整效果。
|
||||
* @logic: 页面通过切换不同容器场景,对比输入框获取焦点后的页面表现,并在底部输入框中监听键盘高度变化实现手动避让。
|
||||
* @optimization: 统一复用键盘高度变化处理逻辑,并在 iOS 与 HarmonyOS 平台扣除安全区高度,减少不同场景下的重复适配。
|
||||
*/
|
||||
const currentPage = getCurrentInstance()?.proxy?.$page
|
||||
|
||||
import { state, setLifeCycleNum as setLifeCycleNumStore } from '@/store/index.uts'
|
||||
|
||||
const title = ref('输入框上推示例')
|
||||
const navigationBarTextColor = ref('#000')
|
||||
const data = reactive({
|
||||
indexView: 0,
|
||||
scrollViewInputFocus: false,
|
||||
listViewInputFocus: false,
|
||||
})
|
||||
const inputBottom = ref('0px')
|
||||
|
||||
// 自动化测试
|
||||
function setLifeCycleNum(num : number) {
|
||||
setLifeCycleNumStore(num)
|
||||
}
|
||||
|
||||
function setNavigationBarColor1() {
|
||||
uni.setNavigationBarColor({
|
||||
frontColor: '#ffffff',
|
||||
backgroundColor: '#0000',
|
||||
success: () => {
|
||||
navigationBarTextColor.value = '#fff'
|
||||
console.log('setNavigationBarColor success')
|
||||
setLifeCycleNum(state.lifeCycleNum + 1)
|
||||
},
|
||||
fail: () => {
|
||||
console.log('setNavigationBarColor fail')
|
||||
setLifeCycleNum(state.lifeCycleNum - 1)
|
||||
},
|
||||
complete: () => {
|
||||
console.log('setNavigationBarColor complete')
|
||||
setLifeCycleNum(state.lifeCycleNum + 1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function setNavigationBarColor2() {
|
||||
uni.setNavigationBarColor({
|
||||
frontColor: '#000000',
|
||||
backgroundColor: '#0000',
|
||||
success: () => {
|
||||
navigationBarTextColor.value = '#000'
|
||||
console.log('setNavigationBarColor success')
|
||||
setLifeCycleNum(state.lifeCycleNum + 1)
|
||||
},
|
||||
fail: () => {
|
||||
console.log('setNavigationBarColor fail')
|
||||
setLifeCycleNum(state.lifeCycleNum - 1)
|
||||
},
|
||||
complete: () => {
|
||||
console.log('setNavigationBarColor complete')
|
||||
setLifeCycleNum(state.lifeCycleNum + 1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function ChangeView(e:UniRadioGroupChangeEvent){
|
||||
data.indexView = parseInt(e.detail.value)
|
||||
}
|
||||
|
||||
function onInputBlur(event:UniInputBlurEvent) {
|
||||
inputBottom.value = '0px';
|
||||
}
|
||||
|
||||
function onInputKeyboardChange(e:UniInputKeyboardHeightChangeEvent) {
|
||||
let height = e.detail.height;
|
||||
// #ifdef APP-IOS || APP-HARMONY
|
||||
if(height>0 && currentPage != null){ //iOS与HarmonyOS平台软键盘的高度已经包含了安全区域高度,这里需要减掉
|
||||
height -= currentPage.safeAreaInsets.bottom;
|
||||
}
|
||||
// #endif
|
||||
inputBottom.value = `${height}px`;
|
||||
}
|
||||
|
||||
// 自动化测试
|
||||
function getLifeCycleNum() : number {
|
||||
return state.lifeCycleNum
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
getLifeCycleNum,
|
||||
setLifeCycleNum,
|
||||
setNavigationBarColor1,
|
||||
setNavigationBarColor2,
|
||||
data
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.scroll-view {
|
||||
flex: 1;
|
||||
background-color: #f5f5f5;
|
||||
padding: 5px 0;
|
||||
}
|
||||
|
||||
.content-item {
|
||||
}
|
||||
|
||||
.cell-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 15px;
|
||||
margin: 5px 10px;
|
||||
background-color: #fff;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.text {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.bottomInput {
|
||||
position: relative;
|
||||
z-index: 1000;
|
||||
padding: 0 5px;
|
||||
margin-bottom: var(--uni-safe-area-inset-bottom);
|
||||
}
|
||||
</style>
|
||||
在新工单中引用
屏蔽一个用户