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

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

查看文件

@@ -0,0 +1,44 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view style="padding: 0 10px;">
<button class="uni-common-mb component-check-page-btn" @click="check$page">
component check $page
</button>
<view class="flex-row uni-common-mb">
<text>check page:</text>
<text class="check-page-res">{{checkPageRes}}</text>
</view>
</view>
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
const instance = getCurrentInstance()
const checkPageRes = ref(false)
const check$page = () => {
const pages = getCurrentPages()
const page = pages[pages.length-1]
const $page = instance?.proxy?.$page
const res = $page === page
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
checkPageRes.value = res
return res
}
defineExpose({
check$page
})
</script>
<style>
.flex-row{
flex-direction: row;
justify-content: space-between;
}
</style>

查看文件

@@ -0,0 +1,192 @@
jest.setTimeout(60000)
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 isWeb = platformInfo.startsWith('web')
const isMP = platformInfo.startsWith('mp')
const isAppWebView = process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true'
const isDom2 = process.env.UNI_APP_X_DOM2 === "true"
const HOME_PAGE_PATH = '/pages/tabBar/component'
const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages?test=123'
describe('getCurrentPages', () => {
if (isAppWebView || (isAndroid && platformInfo.includes('14.0.0'))) {
it('not support', () => {
expect(1).toBe(1)
})
return
}
let page
const deviceScreenshotParams = {
deviceShot: true,
area: {
x: 0,
y: 0,
}
}
it('getCurrentPages', async () => {
// web 端等待应用首页加载完成
if (isWeb) {
const waitTime = process.env.uniTestPlatformInfo.includes('safari') ?
5000 :
3000
await new Promise((resolve) => {
setTimeout(() => {
resolve()
}, waitTime)
})
}
page = await program.switchTab(HOME_PAGE_PATH)
await page.waitFor(1000)
page = await program.navigateTo(PAGE_PATH)
await page.waitFor(1000)
await page.callMethod('_getCurrentPages')
await page.waitFor(200)
const data = await page.data('data')
expect(data.checked).toBe(true)
})
it('$page', async () => {
await page.setData({data:{testing: true}})
const pageRes = await page.callMethod('check$page')
expect(pageRes).toBe(true)
expect(await page.callMethod('componentCheck$page')).toBe(true)
})
if (isMP) {
return
}
it('page-style', async () => {
const windowInfo = await program.callUniMethod('getWindowInfo');
deviceScreenshotParams.area.y = windowInfo.safeAreaInsets.top + 44;
await page.callMethod('getPageStyle')
await page.waitFor(200)
const isEnablePullDownRefresh1 = await page.data('data.currentPageStyle.enablePullDownRefresh')
expect(isEnablePullDownRefresh1).toBe(true)
// setPageStyle
await page.callMethod('setPageStyle', {
enablePullDownRefresh: false
})
await page.waitFor(200)
await page.callMethod('getPageStyle')
await page.waitFor(200)
const isEnablePullDownRefresh2 = await page.data('data.currentPageStyle.enablePullDownRefresh')
expect(isEnablePullDownRefresh2).toBe(false)
await page.callMethod('startPullDownRefresh')
await page.waitFor(500)
const image2 = await program.screenshot({fullPage: true});
expect(image2).toSaveImageSnapshot({customSnapshotIdentifier() {
return 'get-current-pages-test-js-get-current-pages-page-style-before-set-page-style'
}});
await page.waitFor(3500)
await page.callMethod('setPageStyle', {
enablePullDownRefresh: true
})
await page.waitFor(200)
await page.callMethod('startPullDownRefresh')
await page.waitFor(500)
const image3 = await program.screenshot({fullPage: true});
expect(image3).toSaveImageSnapshot({customSnapshotIdentifier() {
return 'get-current-pages-test-js-get-current-pages-page-style-after-set-page-style'
}});
await page.waitFor(3500)
// setPageStyle
await page.callMethod('setPageStyle', {
androidThreeButtonNavigationBackgroundColor: 'aqua'
});
await page.waitFor(2000);
const image4 = await program.screenshot(deviceScreenshotParams);
expect(image4).toSaveImageSnapshot({customSnapshotIdentifier() {
return 'get-current-pages-test-androidThreeButtonNavigationBackgroundColor'
}});
await page.callMethod('setPageStyle', {
androidThreeButtonNavigationStyle: 'black'
});
await page.waitFor(2000);
const image5 = await program.screenshot(deviceScreenshotParams);
expect(image5).toSaveImageSnapshot({customSnapshotIdentifier() {
return 'get-current-pages-test-androidThreeButtonNavigationStyle'
}});
await page.callMethod('setPageStyle', {
androidThreeButtonNavigationTranslucent: true
});
await page.waitFor(2000);
const image6 = await program.screenshot(deviceScreenshotParams);
expect(image6).toSaveImageSnapshot({customSnapshotIdentifier() {
return 'get-current-pages-test-androidThreeButtonNavigationTranslucent'
}});
await program.adbCommand('settings put secure immersive_mode_confirmations confirmed');
await page.callMethod('setPageStyle', {
hideBottomNavigationIndicator: true,
hideStatusBar: true
})
await page.waitFor(2000);
const image7 = await program.screenshot(deviceScreenshotParams);
expect(image7).toSaveImageSnapshot({customSnapshotIdentifier() {
return 'get-current-pages-test-hideStatusBar-hideBottomNavigationIndicator'
}});
})
it('getParentPage', async () => {
const res = await page.callMethod('checkGetParentPage')
expect(res).toBe(true)
})
it('getDialogPages', async () => {
const res = await page.callMethod('checkGetDialogPages')
expect(res).toBe(true)
})
it('getElementById', async () => {
const res = await page.callMethod('checkGetElementById')
expect(res).toBe(true)
})
it('getAndroidView', async () => {
const res = await page.callMethod('checkGetAndroidView')
expect(res).toBe(isAndroid && !isDom2)
})
it('getIOSView', async () => {
const res = await page.callMethod('checkGetIOSView')
expect(res).toBe(false)
})
it('getHTMLElement', async () => {
const res = await page.callMethod('checkGetHTMLElement')
expect(res).toBe(isWeb)
})
it('querySelector', async () => {
const res = await page.callMethod('checkQuerySelector')
expect(res).toBe(true)
})
it('querySelectorAll', async () => {
const res = await page.callMethod('checkQuerySelectorAll')
expect(res).toBe(true)
})
if(isAndroid) {
it('getAndroidActivity', async () => {
const res = await page.callMethod('checkGetAndroidActivity')
expect(res).toBe(!isDom2)
})
}
if(isApp) {
it('takeSnapshot', async () => {
await page.callMethod('checkTakeSnapshot')
// harmony 滚动截屏,需要增加等待时间
await page.waitFor(isHarmony ? 6000 : 2000)
expect(await page.data('data.checkSnapshotResult')).toBe(true)
})
}
})

查看文件

@@ -0,0 +1,407 @@
<template>
<!-- #ifdef APP -->
<scroll-view class="page-scroll-view">
<!-- #endif -->
<view id="container">
<page-head title="getCurrentPages"></page-head>
<view class="uni-padding-wrap">
<button @click="_getCurrentPages">getCurrentPages</button>
<view v-if="data.pages.length" style="padding: 15px 0px">
<text>当前页面栈中 {{ data.pages.length }} 个页面,列表如下:</text>
<template v-for="(page, index) in data.pages" :key="page">
<text style="margin-top: 5px">index: {{ index }}, route: {{ page }}</text>
</template>
</view>
<button class="uni-common-mt" @click="check$page">page check $page</button>
<!-- #ifndef MP -->
<button class="uni-common-mt" @click="checkGetParentPage">
check getParentPage
</button>
<button class="uni-common-mt" @click="checkGetDialogPages">
check getDialogPages
</button>
<button id="check-get-element-by-id-btn" class="uni-common-mt" @click="checkGetElementById">
check getElementById
</button>
<button class="uni-common-mt" @click="checkGetAndroidView">
check getAndroidView
</button>
<button class="uni-common-mt" @click="checkGetIOSView">
check getIOSView
</button>
<button class="uni-common-mt" @click="checkGetHTMLElement">
check getHTMLElement
</button>
<button class="uni-common-mt" @click="checkQuerySelector">
check querySelector
</button>
<button class="uni-common-mt" @click="checkQuerySelectorAll">
check querySelectorAll
</button>
<!-- #endif -->
<!-- #ifdef APP-ANDROID -->
<button class="uni-common-mt" @click="checkGetAndroidActivity">
check getAndroidActivity
</button>
<!-- #endif -->
<!-- #ifdef APP -->
<button class="uni-common-mt" @click="checkTakeSnapshot">
check takeSnapshot
</button>
<!-- #endif -->
</view>
<!-- #ifndef MP -->
<page-head title="currentPageStyle"></page-head>
<template v-for="(item, index) in data.PageStyleArray">
<view class="page-style-item" v-if="data.currentPageStyle[item.key] != null" :key="index">
<view class="item-text">
<text class="item-text-key">{{ item.key }}:</text>
<text class="item-text-value">{{
data.currentPageStyle[item.key]
}}</text>
</view>
<view class="set-value" v-if="item.type == 'boolean'">
<switch :checked="data.currentPageStyle.getBoolean(item.key)"
@change="switchChange(item.key, $event as UniSwitchChangeEvent)">
</switch>
</view>
<view class="set-value" v-else-if="item.type == 'number'">
<slider :value="data.currentPageStyle.getNumber(item.key)" :show-value="true"
@change="sliderChange(item.key, $event as UniSliderChangeEvent)" />
</view>
<view class="set-value" v-else-if="item.type == 'string'">
<radio-group class="radio-set-value" @change="radioChange(item.key, $event as RadioGroupChangeEvent)">
<radio class="radio-value" v-for="(item2, index2) in item.value" :key="index2" :value="item2">{{ item2 }}
</radio>
</radio-group>
</view>
</view>
</template>
<!-- #ifndef APP-HARMONY -->
<button style="margin: 10px" @click="goSetDisablePullDownRefresh">
go set disable pullDownRefresh
</button>
<!-- #endif -->
<!-- #endif -->
<ComponentCheckPage ref="componentCheckPage" />
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
import ComponentCheckPage from './component-check-page.uvue'
import { PageStyleItem, PageStyleArray } from './page-style.uts';
const currentInstance = getCurrentInstance()
const componentCheckPage = ref<ComponentPublicInstance | null>(null)
type DataType = {
checked: boolean;
pages: string[];
PageStyleArray: PageStyleItem[];
currentPageStyle: UTSJSONObject;
testing: boolean;
checkSnapshotResult: boolean;
}
const data = reactive({
checked: false,
pages: [] as string[],
PageStyleArray: PageStyleArray,
currentPageStyle: {},
testing: false,
checkSnapshotResult: false
} as DataType)
const pageStyleText = computed(() : string => {
return JSON.stringify(data.currentPageStyle)
})
const getPageStyle = () : UTSJSONObject => {
const pages: UniPage[] = getCurrentPages();
const currentPage = pages[pages.length - 1];
data.currentPageStyle = currentPage.getPageStyle()
console.log(data.currentPageStyle)
return data.currentPageStyle;
}
const setPageStyle = (style : UTSJSONObject) => {
console.log('setPageStyle:', style);
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage.setPageStyle(style);
}
// #ifndef MP
onLoad(() => {
getPageStyle();
})
// #endif
onReady(() => {
// #ifdef APP-ANDROID
setPageStyle({
'androidThreeButtonNavigationBackgroundColor': 'transparent',
'androidThreeButtonNavigationStyle': 'black'
});
getPageStyle();
// #endif
})
onPullDownRefresh(() => {
setTimeout(() => {
uni.stopPullDownRefresh()
}, 2000)
})
const startPullDownRefresh = () => {
uni.startPullDownRefresh()
}
const _getCurrentPages = () => {
data.pages.length = 0
const pages = getCurrentPages()
data.pages.push(pages[0].route)
if (data.pages[0].includes('/tabBar/') || data.pages[0] == '/') {
data.checked = true
}
for (let i = 1; i < pages.length; i++) {
data.pages.push(pages[i].route)
if (pages[i].route.includes('/tabBar/')) {
data.checked = false
}
}
}
const setStyleValue = (key : string, value : any) => {
const style = {}
style[key] = value
setPageStyle(style)
getPageStyle()
}
/// get-set-page-style
const radioChange = (key : string, e : RadioGroupChangeEvent) => {
setStyleValue(key, e.detail.value);
}
const sliderChange = (key : string, e : UniSliderChangeEvent) => {
setStyleValue(key, e.detail.value);
}
const switchChange = (key : string, e : UniSwitchChangeEvent) => {
setStyleValue(key, e.detail.value);
}
const goSetDisablePullDownRefresh = () => {
uni.navigateTo({
url: '/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh'
});
}
const getCurrentPage = () : UniPage => {
const pages = getCurrentPages()
return pages[pages.length - 1]
}
const check$page = () : boolean => {
const page = getCurrentPage()
const $page = currentInstance?.proxy?.$page
let res = $page === page
if (data.testing && res) {
res = page.options['test'] == '123'
if (res) {
res = page.route == 'pages/API/get-current-pages/get-current-pages'
}
}
console.log('check $page', res)
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
return res
}
const componentCheck$page = () : boolean => {
const res = componentCheckPage.value?.$callMethod('check$page') as boolean
console.log('component check $page', res)
return res
}
const checkGetParentPage = () : boolean => {
const page = getCurrentPage()
const parentPage = page.getParentPage()
const res = parentPage == null
console.log('check getParentPage', res)
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
return res
}
const checkGetDialogPages = () : boolean => {
const page = getCurrentPage()
const dialogPages = page.getDialogPages()
const res = Array.isArray(dialogPages) && dialogPages.length == 0
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
console.log('check getDialogPages', res)
return res
}
const checkGetElementById = () : boolean => {
const page = getCurrentPage()
const element = page.getElementById('check-get-element-by-id-btn')
let res = element != null
// #ifndef APP-ANDROID
if (res) {
const elPage = element!.getPage()
console.log('elPage', elPage)
res = elPage === page
}
// #endif
console.log('check getElementById', res)
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
return res
}
const checkGetAndroidView = () : boolean => {
const page = getCurrentPage()
const androidView = page.getAndroidView()
const res = androidView != null
let failTitle = 'check fail'
// #ifdef APP-ANDROID && VUE3-VAPOR
if (!res) {
failTitle = '仅 Android uts 插件环境支持'
}
// #endif
console.log('check getAndroidView', res)
uni.showToast(res ? { title: 'check success' } : { title: failTitle, icon: 'error' })
return res
}
const checkGetIOSView = () : boolean => {
const page = getCurrentPage()
const IOSView = page.getIOSView()
const res = IOSView != null
console.log('check getIOSView', res)
uni.showToast(res ? { title: 'check success' } : { title: '仅 IOS uts 插件环境支持', icon: 'error' })
return res
}
const checkGetHTMLElement = () : boolean => {
const page = getCurrentPage()
const HTMLView = page.getHTMLElement()
const res = HTMLView != null
console.log('check getHTMLElement', res)
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
return res
}
const checkGetAndroidActivity = () : boolean => {
const page = getCurrentPage()
const activity = page.getAndroidActivity()
const res = activity != null
let failTitle = 'check fail'
// #ifdef APP-ANDROID && VUE3-VAPOR
if (!res) {
failTitle = '仅 Android uts 插件环境支持'
}
// #endif
console.log('check getAndroidActivity', res)
uni.showToast(res ? { title: 'check success' } : { title: failTitle, icon: 'error' })
return res
}
const checkQuerySelector = () : boolean => {
const page = getCurrentPage()
const container = page.querySelector('#container')
const doesNotExist = page.querySelector('#does-not-exist')
const res = (container != null) && (doesNotExist == null)
console.log('check checkQuerySelector', res)
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
return res
}
const checkQuerySelectorAll = () : boolean => {
const page = getCurrentPage()
const btnList = page.querySelectorAll('.uni-common-mt')
const doesNotExistList = page.querySelectorAll('.does-not-exist')
const res = (btnList.length > 1) && (doesNotExistList.length == 0)
console.log('check checkQuerySelectorAll', res)
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
return res
}
const checkTakeSnapshot = () => {
const page = getCurrentPage()
let callBackNum = 0
page.takeSnapshot({
success: (res) => {
console.log('check takeSnapshot success', res)
uni.showToast({ title: 'check success' })
callBackNum++
if(callBackNum == 2){
data.checkSnapshotResult = true
}
},
fail: (err) => {
console.log('check takeSnapshot fail', err)
uni.showToast({ title: 'check fail', icon: 'error' })
callBackNum--
},
complete: (info) => {
console.log('check takeSnapshot complete', info)
callBackNum++
if(callBackNum == 2){
data.checkSnapshotResult = true
}
}
})
}
defineExpose({
data,
pageStyleText,
_getCurrentPages,
getPageStyle,
setPageStyle,
startPullDownRefresh,
check$page,
componentCheck$page,
checkGetParentPage,
checkGetDialogPages,
checkGetElementById,
checkGetAndroidView,
checkGetIOSView,
checkGetHTMLElement,
checkQuerySelector,
checkQuerySelectorAll,
checkGetAndroidActivity,
checkTakeSnapshot
})
</script>
<style>
.page {
flex: 1;
padding: 10px;
}
.page-style {
margin-top: 15px;
}
.page-style-item {
padding: 10px;
margin-top: 10px;
background-color: #ffffff;
border-radius: 5px;
}
.item-text {
flex-direction: row;
}
.item-text-key {
font-weight: bold;
}
.item-text-value {
margin-left: 5px;
}
.set-value {
margin-top: 10px;
}
.radio-set-value {
flex-direction: row;
}
.radio-value {
margin-left: 10px;
}
</style>

查看文件

@@ -0,0 +1,98 @@
export type PageStyleItem = {
key : string
type : string
value : Array<any>
}
export const PageStyleArray = [
{
key: "navigationBarBackgroundColor",
type: "string",
value: ["#007AFF", "#FFFFFF", "#000000"]
},
{
key: "navigationBarTextStyle",
type: "string",
value: ["white", "black"]
},
{
key: "navigationBarTitleText",
type: "string",
value: ["title1", "title2", "title3"]
},
{
key: "navigationStyle",
type: "string",
value: ["default", "custom"]
},
{
key: "backgroundColor",
type: "string",
value: ["#FFFFFF", "#000000"]
},
{
key: "backgroundColorContent",
type: "string",
value: ["#FFFFFF", "#F0F0F0", "#000000"]
},
{
key: "backgroundTextStyle",
type: "string",
value: ["dark", "light"]
},
{
key: "enablePullDownRefresh",
type: "boolean",
value: [true, false]
},
{
key: "onReachBottomDistance",
type: "number",
value: [50, 100]
},
{
key: "pageOrientation",
type: "string",
value: ["auto", "portrait", "landscape"]
},
{
key: "backgroundColorTop",
type: "string",
value: ["#FFFFFF", "#000000"]
},
{
key: "backgroundColorBottom",
type: "string",
value: ["#FFFFFF", "#000000"]
},
{
key: "navigationBarAutoBackButton",
type: "boolean",
value: [true, false]
},
{
key: "hideStatusBar",
type: "boolean",
value: [true, false]
},
{
key: "hideBottomNavigationIndicator",
type: "boolean",
value: [true, false]
},
{
key: "androidThreeButtonNavigationTranslucent",
type: "boolean",
value: [true, false]
},
{
key: "androidThreeButtonNavigationBackgroundColor",
type: "string",
value: ["#000000", "#FFF00033", "aqua"]
},
{
key: "androidThreeButtonNavigationStyle",
type: "string",
value: ["white", "black"]
}] as PageStyleItem[]

查看文件

@@ -0,0 +1,57 @@
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
const isIos = platformInfo.startsWith('ios')
const isHarmony = platformInfo.startsWith('harmony')
const PAGE_PATH = '/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh'
describe('getCurrentPages', () => {
if (isMP || isIos) {
it('not-support', async () => {
expect(1).toBe(1)
})
return
}
let page
it('page-style', async () => {
page = await program.navigateTo(PAGE_PATH)
//onLoad会对currentPageStyle赋值
await page.waitFor(200)
const currentPageStyle = await page.data('data.currentPageStyle')
const isEnablePullDownRefresh1 = currentPageStyle.enablePullDownRefresh
expect(isEnablePullDownRefresh1).toBe(false)
//校验pageStyle数据是否完整
expect(currentPageStyle.navigationStyle != undefined && currentPageStyle.onReachBottomDistance != undefined).toBe(true)
await page.callMethod('setPageStyle', true)
await page.waitFor(200)
await page.callMethod('getPageStyle')
await page.waitFor(200)
const currentPageStyle2 = await page.data('data.currentPageStyle')
const isEnablePullDownRefresh2 = currentPageStyle2.enablePullDownRefresh
expect(isEnablePullDownRefresh2).toBe(true)
await page.callMethod('startPullDownRefresh')
await page.waitFor(500)
const image3 = await program.screenshot({
fullPage: true
});
expect(image3).toSaveImageSnapshot({customSnapshotIdentifier() {
return 'set-page-style-disable-pull-down-refresh-test-js-get-current-pages-page-style-before-set-page-style'
}});
await page.waitFor(3500)
// setPageStyle
await page.callMethod('setPageStyle', false)
await page.waitFor(200)
await page.callMethod('startPullDownRefresh')
await page.waitFor(500)
const image2 = await program.screenshot({
fullPage: true
});
expect(image2).toSaveImageSnapshot({customSnapshotIdentifier() {
return 'set-page-style-disable-pull-down-refresh-test-js-get-current-pages-page-style-after-set-page-style'
}});
})
})

查看文件

@@ -0,0 +1,115 @@
<template>
<page-head title="getCurrentPages"></page-head>
<view class="uni-padding-wrap">
<button class="btn btn-get-page-style" type="default" @click="getPageStyle">getPageStyle</button>
<button class="btn btn-set-page-style-1" type="default" @click="setPageStyle(true)">setPageStyle(true)</button>
<button class="btn btn-set-page-style-0" type="default" @click="setPageStyle(false)">setPageStyle(false)</button>
<text class="page-style">当前 PageStyle</text>
<text class="page-style-value">{{pageStyleText}}</text>
<text class="status">状态:</text>
<view class="status-list">
<text>enablePullDownRefresh: {{data.enablePullDownRefreshStatus}}</text>
</view>
<text class="tips">当前版本仅支持设置属性 enablePullDownRefresh</text>
</view>
</template>
<script setup lang="uts">
class Page {
constructor(public route : string) {
}
}
type DataType = {
currentPageStyle: UTSJSONObject,
enablePullDownRefreshStatus: boolean,
}
const checked = ref(false)
const pages = ref([] as Page[])
const data = reactive({
currentPageStyle: {} as UTSJSONObject,
enablePullDownRefreshStatus: true,
} as DataType)
const pageStyleText = computed(() : string => {
return JSON.stringify(data.currentPageStyle)
})
function getPageStyle() {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
data.currentPageStyle = currentPage.getPageStyle();
}
function setPageStyle(enable : boolean) {
// 目前仅支持 enablePullDownRefresh
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage.setPageStyle({
enablePullDownRefresh: enable
});
data.enablePullDownRefreshStatus = enable
}
function startPullDownRefresh() {
uni.startPullDownRefresh()
}
onLoad(() => {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
data.currentPageStyle = currentPage.getPageStyle();
data.enablePullDownRefreshStatus = data.currentPageStyle["enablePullDownRefresh"] as boolean
})
defineExpose({
data,
getPageStyle,
setPageStyle,
startPullDownRefresh
})
onPullDownRefresh(() => {
setTimeout(() => {
uni.stopPullDownRefresh()
}, 3000)
})
</script>
<style>
.btn {
margin-top: 10px;
}
.page-style {
margin-top: 15px;
}
.page-style-value {
margin-top: 5px;
padding: 5px;
background-color: #fff;
width: 100%;
/* #ifdef WEB */
overflow-wrap: break-word;
/* #endif */
}
.status {
margin-top: 20px;
}
.status-list {
margin-top: 5px;
}
.tips {
font-size: 12px;
margin-top: 15px;
opacity: .8;
}
</style>