refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范
这个提交包含在:
@@ -0,0 +1,35 @@
|
||||
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
|
||||
const isMP = platformInfo.startsWith('mp')
|
||||
const isHarmony = platformInfo.startsWith('harmony')
|
||||
const isWeb = platformInfo.startsWith('web')
|
||||
const isAppWebView = process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true'
|
||||
const isDom2 = process.env.UNI_APP_X_DOM2 === "true"
|
||||
|
||||
describe('component-native-sticky-section', () => {
|
||||
if (isMP || isWeb || (!isDom2 && isHarmony)) {
|
||||
it('skip', () => {
|
||||
expect(1).toBe(1)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
let page
|
||||
beforeAll(async () => {
|
||||
page = await program.reLaunch('/pages/component/sticky-section/sticky-section-push-pinned-header')
|
||||
await page.waitFor('view')
|
||||
await page.waitFor(1000);
|
||||
})
|
||||
|
||||
it('check_push_pinned_header', async () => {
|
||||
// 滚动到B,期望headerB在headerA之下
|
||||
await page.callMethod('testScroll')
|
||||
await page.waitFor(1000)
|
||||
const image1 = await program.screenshot({fullPage: true});
|
||||
expect(image1).toSaveImageSnapshot();
|
||||
// 滚动到C,期望headerC在headerA之下,且将headerB顶出可视区,因为headerB对应的section的push-pinned-header为true
|
||||
await page.callMethod('testScroll')
|
||||
await page.waitFor(1000)
|
||||
const image2 = await program.screenshot({fullPage: true});
|
||||
expect(image2).toSaveImageSnapshot();
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<view style="flex: 1;">
|
||||
<button @click="testScroll">滚动测试</button>
|
||||
<list-view style="flex: 1;" :scroll-top="scrollTop" :scroll-with-animation="true">
|
||||
<sticky-section :push-pinned-header="false">
|
||||
<sticky-header>
|
||||
<text class="header">A</text>
|
||||
</sticky-header>
|
||||
<list-item v-for="item in 20" :key="item">
|
||||
<text class="item">item-{{item}}</text>
|
||||
</list-item>
|
||||
</sticky-section>
|
||||
<sticky-section>
|
||||
<sticky-header>
|
||||
<text class="header">B</text>
|
||||
</sticky-header>
|
||||
<list-item v-for="item in 20" :key="item">
|
||||
<text class="item">item-{{item}}</text>
|
||||
</list-item>
|
||||
</sticky-section>
|
||||
<sticky-section :push-pinned-header="false">
|
||||
<sticky-header>
|
||||
<text class="header">C</text>
|
||||
</sticky-header>
|
||||
<list-item v-for="item in 20" :key="item">
|
||||
<text class="item">item-{{item}}</text>
|
||||
</list-item>
|
||||
</sticky-section>
|
||||
<sticky-section>
|
||||
<sticky-header>
|
||||
<text class="header">D</text>
|
||||
</sticky-header>
|
||||
<list-item v-for="item in 20" :key="item">
|
||||
<text class="item">item-{{item}}</text>
|
||||
</list-item>
|
||||
</sticky-section>
|
||||
<sticky-section>
|
||||
<sticky-header>
|
||||
<text class="header">E</text>
|
||||
</sticky-header>
|
||||
<list-item v-for="item in 20" :key="item">
|
||||
<text class="item">item-{{item}}</text>
|
||||
</list-item>
|
||||
</sticky-section>
|
||||
</list-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
const scrollTop = ref(0)
|
||||
const sectionHeight = 30 * 20 + 40;
|
||||
const sectionCount = 5
|
||||
let currentSection = 0
|
||||
function testScroll() {
|
||||
currentSection++
|
||||
if (currentSection > sectionCount) {
|
||||
currentSection = 0
|
||||
}
|
||||
scrollTop.value = currentSection * sectionHeight;
|
||||
}
|
||||
defineExpose({
|
||||
testScroll
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.header {
|
||||
background-color: #cccccc;
|
||||
font-size: 18px;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.item {
|
||||
font-size: 14px;
|
||||
line-height: 30px;
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,90 @@
|
||||
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
|
||||
const isMP = platformInfo.startsWith('mp')
|
||||
const isHarmony = platformInfo.startsWith('harmony')
|
||||
const isWeb = platformInfo.startsWith('web')
|
||||
const isAppWebView = process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true'
|
||||
const isDom2 = process.env.UNI_APP_X_DOM2 === "true"
|
||||
|
||||
describe('component-native-sticky-section', () => {
|
||||
if (isMP) {
|
||||
it('skip', () => {
|
||||
expect(1).toBe(1)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
let page
|
||||
beforeAll(async () => {
|
||||
page = await program.reLaunch('/pages/component/sticky-section/sticky-section')
|
||||
await page.waitFor('sticky-section')
|
||||
await page.waitFor(2000); // 等待页面加载完成
|
||||
})
|
||||
|
||||
if (!isWeb && isDom2) {
|
||||
it('check_preload', async () => {
|
||||
const isPreloaded = await page.callMethod('jest_checkPreload');
|
||||
expect(isPreloaded).toBe(true);
|
||||
});
|
||||
}
|
||||
|
||||
it('check_delete_and_refresher', async () => {
|
||||
await page.callMethod('deleteSection')
|
||||
await page.waitFor(400)
|
||||
await page.setData({
|
||||
pageData:{refresherTriggered: true}
|
||||
})
|
||||
await page.waitFor(500)
|
||||
await page.setData({
|
||||
pageData:{refresherTriggered: false}
|
||||
})
|
||||
await page.waitFor(2000)
|
||||
const image = await program.screenshot({fullPage: true});
|
||||
expect(image).toSaveImageSnapshot();
|
||||
})
|
||||
|
||||
//检测吸顶上推效果
|
||||
it('check_sticky_section', async () => {
|
||||
await page.waitFor(async () => {
|
||||
return await page.data('pageData.isReady') === true;
|
||||
});
|
||||
page.waitFor(600)
|
||||
await page.callMethod('listViewScrollByY', 1000)
|
||||
await page.waitFor(1000)
|
||||
const image = await program.screenshot({fullPage: true});
|
||||
expect(image).toSaveImageSnapshot();
|
||||
})
|
||||
|
||||
if (isWeb || isAppWebView) {
|
||||
return
|
||||
}
|
||||
|
||||
it('check_goto_sticky_header', async () => {
|
||||
//滚动回顶部
|
||||
await page.callMethod('toTop')
|
||||
page.waitFor(100)
|
||||
await page.setData({
|
||||
pageData:{scrolling: true}
|
||||
})
|
||||
if (!isAppWebView) {
|
||||
//跳转到id为C的StickyHeader位置
|
||||
await page.callMethod('gotoStickyHeader', 'C')
|
||||
}
|
||||
await page.waitFor(async () => {
|
||||
return await page.data('pageData.scrolling') === false;
|
||||
});
|
||||
const image = await program.screenshot({fullPage: true});
|
||||
expect(image).toSaveImageSnapshot();
|
||||
})
|
||||
|
||||
//检测吸顶上推效果
|
||||
it('check_sticky_section_with_list_footer', async () => {
|
||||
await page.waitFor(async () => {
|
||||
return await page.data('pageData.isReady') === true;
|
||||
});
|
||||
page.waitFor(600)
|
||||
await page.callMethod('listViewScrollByY', 100000)
|
||||
await page.waitFor(1000)
|
||||
const image = await program.screenshot({fullPage: true});
|
||||
expect(image).toSaveImageSnapshot();
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,196 @@
|
||||
<template>
|
||||
<page-head title="sticky-section"></page-head>
|
||||
<list-view id="list-view" ref="listViewRef" show-scrollbar=false class="page" :scroll-into-view="pageData.scrollIntoView"
|
||||
@scroll="onScroll" @scrollend="onScrollEnd" bounces="false" refresher-enabled="true" :refresher-triggered="pageData.refresherTriggered" @refresherrefresh="onRefresherrefresh">
|
||||
<list-item style="padding: 10px; margin: 5px 0;align-items: center;" :type=20>
|
||||
<button @click="gotoStickyHeader('C')" size="mini">跳转到id为C的sticky-header位置上</button>
|
||||
</list-item>
|
||||
<list-item style="padding: 10px; margin: 5px 0;align-items: center;" :type=20>
|
||||
<button @click="appendSectionItem(0)" size="mini">第一组 section 新增5条内容</button>
|
||||
</list-item>
|
||||
<list-item style="padding: 10px; margin: 5px 0;align-items: center;" :type=20>
|
||||
<button @click="deleteSection()" size="mini">删除第一组 section</button>
|
||||
</list-item>
|
||||
<sticky-section class="content-section" ref="sectionRefs" style="align-items: stretch; align-content: stretch;" v-for="(section) in pageData.sectionArray" :key="section.name"
|
||||
<!-- #ifndef APP && VUE3-VAPOR -->
|
||||
:padding="pageData.sectionPadding"
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef APP && VUE3-VAPOR -->
|
||||
:preload="true"
|
||||
<!-- #endif -->
|
||||
:push-pinned-header="true">
|
||||
<sticky-header :id="section.name">
|
||||
<text class="sticky-header-text">{{section.name}}</text>
|
||||
</sticky-header>
|
||||
<list-item v-for="(list) in section.list" :key="list.text" :name="list.text" class="content-item" :type=10>
|
||||
<text class="content-item-text">{{list.text}}</text>
|
||||
</list-item>
|
||||
</sticky-section>
|
||||
<list-item v-if="pageData.sectionArray.length > 0" style="padding: 10px; margin: 5px 0;align-items: center;" :type=30>
|
||||
<!-- <text style="color: #aaa">到底了</text> -->
|
||||
<button @click="toTop" size="mini">回到顶部</button>
|
||||
</list-item>
|
||||
<list-item>
|
||||
<navigator url="/pages/component/sticky-section/sticky-section-push-pinned-header">
|
||||
<button>push-pinned-header属性测试</button>
|
||||
</navigator>
|
||||
</list-item>
|
||||
</list-view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
export type sectionData = {
|
||||
name : string,
|
||||
list : sectionListItem[]
|
||||
}
|
||||
export type sectionListItem = {
|
||||
text : string
|
||||
}
|
||||
type DataType = {
|
||||
data: string[];
|
||||
sectionPadding: number[];
|
||||
scrollIntoView: string;
|
||||
scrolling: boolean;
|
||||
sectionArray: sectionData[];
|
||||
appendId: number;
|
||||
refresherTriggered: boolean;
|
||||
isReady: boolean;
|
||||
}
|
||||
|
||||
const pageData = reactive({
|
||||
data: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N'],
|
||||
sectionPadding: [0, 10, 0, 10],
|
||||
scrollIntoView: "",
|
||||
scrolling: false,
|
||||
sectionArray: [],
|
||||
appendId: 0,
|
||||
refresherTriggered: false,
|
||||
isReady: false//自动化测试使用
|
||||
} as DataType)
|
||||
|
||||
const listViewRef = ref<UniElement | null>(null)
|
||||
const sectionRefs = ref<UniElement[] | null>(null)
|
||||
|
||||
const initSectionArray = () => {
|
||||
pageData.sectionArray = []
|
||||
console.log("initSectionArray start", pageData.sectionArray.length)
|
||||
pageData.data.forEach((key, index) => {
|
||||
const list = [] as sectionListItem[]
|
||||
const count = index === pageData.data.length - 1 ? 30 : 11
|
||||
for (let i = 1; i < count; i++) {
|
||||
const item = { text: key + "--item--content----" + i } as sectionListItem
|
||||
list.push(item)
|
||||
}
|
||||
const sectionDataItem = { name: key, list: list } as sectionData
|
||||
pageData.sectionArray.push(sectionDataItem)
|
||||
}
|
||||
)
|
||||
console.log("initSectionArray end", pageData.sectionArray[0].name)
|
||||
}
|
||||
|
||||
onReady(() => {
|
||||
//延迟onReady再加载数据 校验issues:14705 bug
|
||||
initSectionArray()
|
||||
pageData.isReady = true
|
||||
})
|
||||
|
||||
const toTop = () => {
|
||||
pageData.scrollIntoView = ""
|
||||
uni.getElementById("list-view")!.scrollTop = 0
|
||||
}
|
||||
|
||||
//用于自动化测试
|
||||
const listViewScrollByY = (y : number) => {
|
||||
const listview = listViewRef.value as UniElement
|
||||
// listview.scrollBy(0, y)
|
||||
listview.scrollTop = y
|
||||
}
|
||||
|
||||
const gotoStickyHeader = (id : string) => {
|
||||
// #ifdef APP || WEB
|
||||
pageData.scrollIntoView = id
|
||||
// #endif
|
||||
}
|
||||
|
||||
const onScroll = () => {
|
||||
pageData.scrolling = true
|
||||
}
|
||||
|
||||
const onScrollEnd = () => {
|
||||
pageData.scrolling = false
|
||||
//滚动后重置scrollIntoView = ""
|
||||
if (pageData.scrollIntoView != "") {
|
||||
pageData.scrollIntoView = ""
|
||||
}
|
||||
}
|
||||
|
||||
const appendSectionItem = (index : number) => {
|
||||
const sectionDataItem = pageData.sectionArray[index]
|
||||
pageData.appendId++
|
||||
const list = [
|
||||
{ text: sectionDataItem.name + "--item--content----new1--" + pageData.appendId } as sectionListItem,
|
||||
{ text: sectionDataItem.name + "--item--content----new2--" + pageData.appendId } as sectionListItem,
|
||||
{ text: sectionDataItem.name + "--item--content----new3--" + pageData.appendId } as sectionListItem,
|
||||
{ text: sectionDataItem.name + "--item--content----new4--" + pageData.appendId } as sectionListItem,
|
||||
{ text: sectionDataItem.name + "--item--content----new5--" + pageData.appendId } as sectionListItem
|
||||
] as sectionListItem[]
|
||||
sectionDataItem.list.unshift(...list)
|
||||
}
|
||||
|
||||
const deleteSection = () => {
|
||||
pageData.sectionArray.shift()
|
||||
}
|
||||
|
||||
const onRefresherrefresh = (_ : UniRefresherEvent) => {
|
||||
pageData.refresherTriggered = true;
|
||||
setTimeout(() => {
|
||||
initSectionArray()
|
||||
pageData.refresherTriggered = false;
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
const jest_checkPreload = () => {
|
||||
return sectionRefs.value?.every(sectionElement => {
|
||||
return sectionElement.querySelectorAll(".content-item").length > 0;
|
||||
}) ?? false;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
pageData,
|
||||
deleteSection,
|
||||
listViewScrollByY,
|
||||
toTop,
|
||||
gotoStickyHeader,
|
||||
jest_checkPreload
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.page {
|
||||
flex: 1;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.sticky-header-text {
|
||||
font-size: 16px;
|
||||
padding: 8px;
|
||||
color: #959595;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.content-section {
|
||||
/* #ifdef APP && VUE3-VAPOR */
|
||||
/* 蒸汽模式sticky-section支持padding样式,不支持padding属性 */
|
||||
padding: 0px 10px 0px 10px;
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
.content-item {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.content-item-text {
|
||||
padding: 15px;
|
||||
background-color: #fff;
|
||||
}
|
||||
</style>
|
||||
在新工单中引用
屏蔽一个用户