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

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

查看文件

@@ -0,0 +1,98 @@
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isMP = platformInfo.startsWith('mp')
const isHarmony = platformInfo.startsWith('harmony')
const isIOS = platformInfo.startsWith('ios')
const isDom2 = process.env.UNI_APP_X_DOM2 == 'true'
const PAGE_PATH = '/pages/component/switch/switch'
describe('switch', () => {
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(500)
})
async function setPageData(newData) {
return await page.setData({ data: newData });
}
it('checked', async () => {
const switch_element = await page.$('.switch-checked')
await setPageData({
checked: false
})
await page.waitFor(100)
// TODO
const newValue1 = await switch_element.property('checked')
expect(newValue1.toString()).toBe(false + '')
await setPageData({
checked: true
})
await page.waitFor(100)
// TODO
const newValue2 = await switch_element.property('checked')
expect(newValue2.toString()).toBe(true + '')
})
it('color', async () => {
if ((isHarmony || isIOS || isAndroid) && isDom2) {
console.log('Switch Harmony or iOS or Android not support props color')
expect(1).toBe(1)
return
}
const switch_element = await page.$('.switch-color')
expect(await switch_element.attribute('color')).toBe('#FFCC33')
const color = '#00ff00'
await setPageData({
color: color
})
await page.waitFor(100)
expect(await switch_element.attribute('color')).toBe(color)
})
if(!isMP) {
it('dark', async () => {
if ((isHarmony || isIOS || isAndroid) && isDom2) {
console.log('Switch Harmony or iOS or Android not support props background-color、fore-color、active-background-color、active-fore-color')
expect(1).toBe(1)
return
}
const dark = await page.$('#dark')
const darkChecked = await page.$('#darkChecked')
expect(await dark.attribute('background-color')).toBe('#1f1f1f')
expect(await dark.attribute('fore-color')).toBe('#f0f0f0')
expect(await darkChecked.attribute('active-background-color')).toBe('#007aff')
expect(await darkChecked.attribute('active-fore-color')).toBe('#ffffff')
})
}
it('click', async () => {
let switchElement
// TODO 暂时通过获取组件内部的 class 触发模拟点击
if (isAndroid && !isDom2) {
switchElement = await page.$('.uni-switch-input')
await switchElement.tap()
await page.waitFor(200)
const {testVerifyEvent} = await page.data('data')
expect(testVerifyEvent).toBe(true)
} else {
// switchElement = await page.$('#testTap')
}
// await switchElement.tap()
// await page.waitFor(200)
// const {
// testVerifyEvent
// } = await page.data()
// expect(testVerifyEvent).toBe(true)
})
if (isDom2 && !isMP) {
it('externalClasses', async () => {
const switchElement = await page.$('#darkChecked')
expect(await switchElement.attribute('switch-active-class')).toContain('custom-switch-active')
expect(await switchElement.attribute('thumb-active-class')).toContain('custom-thumb-active1')
expect(await switchElement.attribute('thumb-class')).toContain('custom-thumb1')
})
}
})

查看文件

@@ -0,0 +1,152 @@
<template>
<view>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-title">默认样式</view>
<view class="flex-row">
<switch class="switch-checked" :checked="data.checked" @change="switch1Change" />
<switch @change="switch2Change" />
</view>
<view class="uni-title">暗黑样式</view>
<view class="flex-row">
<!-- #ifdef !VUE3-VAPOR || (VUE3-VAPOR && MP) -->
<switch id="darkChecked" background-color="#1f1f1f" activeBackgroundColor="#007aff" foreColor="#f0f0f0"
activeForeColor="#ffffff" :checked="data.checked" />
<switch id="dark" background-color="#1f1f1f" activeBackgroundColor="#007aff" foreColor="#f0f0f0"
activeForeColor="#ffffff" />
<!-- #endif -->
<!-- #ifdef VUE3-VAPOR && !MP -->
<switch id="darkChecked" :class="{ 'dark-class': !data.darkChecked1 }" switch-active-class="custom-switch-active" thumb-active-class="custom-thumb-active1" thumb-class="custom-thumb1" :checked="data.checked" @change="switch3Change" />
<switch id="dark" :class="{ 'dark-class': !data.darkChecked2 }" switch-active-class="custom-switch-active" thumb-active-class="custom-thumb-active1" thumb-class="custom-thumb1" @change="switch4Change" />
<!-- #endif -->
</view>
<view class="uni-title">禁用样式</view>
<view class="flex-row">
<switch class="switch-checked" :checked="data.checked" :disabled="true" />
<switch :disabled="true" />
</view>
<view class="uni-title">不同颜色和尺寸的switch</view>
<view class="flex-row">
<!-- #ifdef !VUE3-VAPOR || (VUE3-VAPOR && MP) -->
<switch class="switch-color-checked" :color="data.color" style="transform:scale(0.7)" :checked="true" />
<switch class="switch-color" :color="data.color" style="transform:scale(0.7)" />
<!-- #endif -->
<!-- #ifdef VUE3-VAPOR && !MP -->
<switch switch-active-class="custom-switch-active-color" style="transform:scale(0.7)" :checked="true" />
<switch switch-active-class="custom-switch-active-color" style="transform:scale(0.7)" />
<!-- #endif -->
</view>
<view class="uni-title">推荐展示样式</view>
</view>
<view class="uni-list">
<view class="uni-list-cell uni-list-cell-padding">
<view class="uni-list-cell-db">开启中</view>
<switch :checked="true" />
</view>
<view class="uni-list-cell uni-list-cell-padding">
<view class="uni-list-cell-db">关闭</view>
<switch />
</view>
<!-- #ifdef VUE3-VAPOR && !MP -->
<view class="uni-list-cell uni-list-cell-padding">
<view class="uni-list-cell-db">自定义 thumb 样式</view>
<switch thumb-class="custom-thumb" thumb-active-class="custom-thumb-active" />
</view>
<!-- #endif -->
</view>
<navigator class="uni-common-mb" url="/pages/template/switch-100/switch-100">
<button>组件性能测试</button>
</navigator>
</view>
</template>
<script setup lang="uts">
type DataType = {
title: string;
checked: boolean;
// #ifdef VUE3-VAPOR && !MP
darkChecked1: boolean;
darkChecked2: boolean;
// #endif
color: string;
clickCheckedValue: boolean;
testVerifyEvent: boolean;
}
// 使用reactive避免ref数据在自动化测试中无法访问
const data = reactive({
title: 'switch 开关',
checked: true,
// #ifdef VUE3-VAPOR && !MP
darkChecked1: true,
darkChecked2: false,
// #endif
color: '#FFCC33',
clickCheckedValue: true,
testVerifyEvent: false
} as DataType)
const switch1Change = (e: UniSwitchChangeEvent) => {
data.clickCheckedValue = e.detail.value
console.log('switch1 发生 change 事件,携带值为', e.detail.value)
// 仅测试
data.testVerifyEvent = (e.type == 'change' && (e.target?.tagName ?? '') == "SWITCH")
}
const switch2Change = (e: UniSwitchChangeEvent) => {
console.log('switch2 发生 change 事件,携带值为', e.detail.value)
}
// #ifdef VUE3-VAPOR && !MP
const switch3Change = (e: UniSwitchChangeEvent) => {
data.darkChecked1 = e.detail.value
}
const switch4Change = (e: UniSwitchChangeEvent) => {
data.darkChecked2 = e.detail.value
}
// #endif
defineExpose({
data
})
</script>
<style>
.flex-row {
flex-direction: row;
}
/* #ifdef VUE3-VAPOR && !MP */
.dark-class {
background-color: #1f1f1f;
border-color: #1f1f1f;
}
.custom-switch-active {
background-color: #007aff;
border-color: #007aff;
}
.custom-switch-active-color {
background-color: #FFCC33;
border-color: #FFCC33;
}
.custom-thumb-active1 {
background-color: #ffffff;
}
.custom-thumb1 {
background-color: #f0f0f0;
}
.custom-thumb {
background-color: #007aff;
}
.custom-thumb-active {
background-color: #e64340;
}
/* #endif */
</style>