refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范
这个提交包含在:
@@ -0,0 +1,42 @@
|
||||
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
|
||||
const isMP = platformInfo.startsWith('mp')
|
||||
|
||||
describe('page-scroll-to', () => {
|
||||
if ( isMP) {
|
||||
it('skip', async () => {
|
||||
expect(1).toBe(1);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const PAGE_PATH = '/pages/API/page-scroll-to/page-scroll-to'
|
||||
let page
|
||||
beforeAll(async () => {
|
||||
page = await program.reLaunch(PAGE_PATH)
|
||||
await page.waitFor(500)
|
||||
})
|
||||
it('scroll-to', async () => {
|
||||
const btnScrollTo = await page.$('.btn-scrollTo')
|
||||
|
||||
await btnScrollTo.tap()
|
||||
// 等待滚动完成
|
||||
await page.waitFor(1000)
|
||||
|
||||
const scrollTop = await page.scrollTop()
|
||||
// 设备精度问题,允许上下浮动 1px
|
||||
expect(scrollTop > 99 && scrollTop < 101).toBe(true)
|
||||
})
|
||||
it('scroll-to-element', async () => {
|
||||
const btnScrollTo = await page.$('.btn-scrollToElement')
|
||||
const scrollToElement = await page.$('.custom-element')
|
||||
|
||||
await btnScrollTo.tap()
|
||||
await page.waitFor(1000)
|
||||
|
||||
const offset = await scrollToElement.offset()
|
||||
// android 6 分辨率为 720*1280,需要调整期望数值
|
||||
if (!process.env.uniTestPlatformInfo.startsWith('android 6')) {
|
||||
expect(offset.top >= 1180).toBe(true)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,60 @@
|
||||
<template>
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
<scroll-view style="flex: 1" scroll-with-animation="true">
|
||||
<!-- #endif -->
|
||||
<view class="uni-padding-wrap">
|
||||
<page-head :title="title"></page-head>
|
||||
<button type="default" class="btn-scrollTo" @click="scrollTo">
|
||||
scrollTo
|
||||
</button>
|
||||
<button type="default" class="btn-scrollToElement" @click="scrollToElement">
|
||||
scrollToElement
|
||||
</button>
|
||||
<view class="uni-list" v-for="(_, index) in 10" :key="index">
|
||||
<view class="uni-list-cell list-item">{{ index }}</view>
|
||||
</view>
|
||||
<view class="custom-element">scrollTo-custom-element</view>
|
||||
<view class="uni-list" v-for="(_, index2) in 10" :key="index2">
|
||||
<view class="uni-list-cell list-item">{{ index2 }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
</scroll-view>
|
||||
<!-- #endif -->
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
const title = ref('pageScrollTo')
|
||||
|
||||
const scrollTo = () => {
|
||||
uni.pageScrollTo({
|
||||
scrollTop: 100,
|
||||
duration: 300,
|
||||
success: () => {
|
||||
console.log('success')
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const scrollToElement = () => {
|
||||
uni.pageScrollTo({
|
||||
selector: '.custom-element',
|
||||
duration: 300,
|
||||
success: () => {
|
||||
console.log('success')
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
scrollTo
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.list-item {
|
||||
height: 100px;
|
||||
padding-left: 30px;
|
||||
}
|
||||
</style>
|
||||
在新工单中引用
屏蔽一个用户