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

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

查看文件

@@ -0,0 +1,16 @@
<template>
<image class="child-image" src="/static/test-image/logo.png"></image>
</template>
<script setup lang="uts">
</script>
<style>
.child-image {
width: 80px;
height: 80px;
border-radius: 10px;
border: 2px solid #ff6b6b;
background-color: #ffe0e0;
}
</style>

查看文件

@@ -0,0 +1,26 @@
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
describe('image format', () => {
if (isMP) {
it('skip', () => {
expect(1).toBe(1)
})
return
}
let page;
beforeAll(async () => {
page = await program.reLaunch('/pages/component/image/image-format');
await page.waitFor('view')
await page.waitFor(isWeb ? 5000 : 2000); // 等待页面加载完成
});
it('screenshot', async () => {
const image = await program.screenshot({
fullPage: true,
});
expect(image).toSaveImageSnapshot();
});
});

查看文件

@@ -0,0 +1,131 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1;">
<!-- #endif -->
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<!-- <view class="uni-title">
<text class="uni-title-text">支持的图片格式示例</text>
</view> -->
<view v-for="(item,index) in supportFormats" :key="index">
<text class="uni-subtitle-text">{{item.format}},右边为拍平测试</text>
<view class="uni-center" style="background:#FFFFFF;">
<!-- <image class="image" mode="widthFix" :src="item.src"></image> -->
<image class="image" mode="widthFix" :src="item.errorImage == null ? item.src : item.errorImage"
@error="imageErrorEvent(index, $event as ImageErrorEvent)"></image>
<image class="image" mode="widthFix" :src="item.errorImageFlatten == null ? item.src : item.errorImageFlatten"
@error="imageErrorEventFlatten(index, $event as ImageErrorEvent)" flatten></image>
</view>
</view>
<!-- <view class="uni-title">
<text class="uni-title-text">暂不支持的格式</text>
</view>
<view v-for="(item,index) in notSupportFormats" :key="index">
<text class="uni-subtitle-text">{{item.format}}</text>
<view class="uni-center" style="background:#FFFFFF;">
<image class="image" mode="widthFix" :src="item.errorImage == null ? item.src : item.errorImage"
@error="imageErrorEvent(index, $event as ImageErrorEvent)"></image>
</view>
</view> -->
</view>
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
type ImageFormat = {
format : string
src : string.ImageURIString
errorImage ?: string.ImageURIString | null
errorImageFlatten ?: string.ImageURIString | null
}
const title = ref('image-format')
const supportFormats = ref([
{
format: 'bmp',
src: '/static/test-image/logo.bmp'
},
{
format: 'gif',
src: '/static/test-image/logo.gif'
},
{
format: 'gif 动画',
src: '/static/test-image/animated.gif'
},
{
format: 'ico',
src: '/static/test-image/logo.ico'
},
{
format: 'jpg',
src: '/static/test-image/logo.jpg'
},
{
format: 'png',
src: '/static/test-image/logo.png'
},
{
format: 'webp',
src: '/static/test-image/logo.webp'
},
{
format: 'webp 动画',
src: '/static/test-image/animated.webp'
},
{
format: 'heic(Android10+)',
src: '/static/test-image/logo.heic'
},
{
format: 'avif(iOS16+,Android12+)',
src: '/static/test-image/logo.avif'
},
{
format: 'tif(Android不支持)',
src: '/static/test-image/logo.tif'
},
{
format: 'svg本地路径(iOS13+)',
src: '/static/test-image/logo.svg'
},
{
format: 'svg网络路径(iOS13+)',
src: 'https://web-ext-storage.dcloud.net.cn/hello-uni-app-x/image/logo.svg',
}
] as Array<ImageFormat>)
/* notSupportFormats: [
{
format: 'avif',
src: '/static/test-image/logo.avif'
},
{
format: 'tif',
src: '/static/test-image/logo.tif'
}
] as Array<ImageFormat> */
function imageErrorEvent(index : number, e : ImageErrorEvent) {
console.log("图片加载错误", e.detail);
// 图片加载失败,加载本地占位图
supportFormats.value[index].errorImage = '/static/dislike.png'
}
function imageErrorEventFlatten(index : number, e : ImageErrorEvent) {
console.log("拍平图片加载错误", e.detail);
// 图片加载失败,加载本地占位图
supportFormats.value[index].errorImageFlatten = '/static/dislike.png'
}
</script>
<style>
.image {
margin: 40px auto;
width: 100px;
}
</style>

查看文件

@@ -0,0 +1,38 @@
<template>
<scroll-view style="flex: 1;">
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-title">
<text class="uni-title-text">大图示例</text>
</view>
<view class="uni-common-mt" v-for="_ in 10">
<text class="uni-subtitle-text">width={{width}}px height={{height}}px memory={{memory}}MB</text>
<image class="image" mode="widthFix" :src="src" @load="load"></image>
</view>
</view>
</scroll-view>
</template>
<script setup lang="uts">
// Data
const title = ref('image-large')
const src = ref('https://qiniu-web-assets.dcloud.net.cn/uni-app-x/static/img/building.jpg')
const width = ref(0)
const height = ref(0)
const memory = ref(0)
// Methods
function load(event : ImageLoadEvent) {
width.value = event.detail.width
height.value = event.detail.height
memory.value = Math.round(width.value * height.value * 4 / 1024 / 1024 * 100) / 100
}
</script>
<style>
.image {
width: 100%;
}
</style>

查看文件

@@ -0,0 +1,19 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1;">
<!-- #endif -->
<image style="width: 100%;" src="/static/test-image/longPath.jpg" mode="widthFix" @load="load"></image>
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
function load(event : ImageLoadEvent) {
console.log("load event:", event)
}
</script>
<style>
</style>

查看文件

@@ -0,0 +1,139 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1;">
<!-- #endif -->
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-title">
<text class="uni-title-text">支持的图片缩放模式示例</text>
</view>
<view v-for="(item,index) in data" :key="index">
<text class="uni-subtitle-text">{{item.mode}}: {{item.description}}</text>
<text class="uni-subtitle-text">右边为拍平测试</text>
<view class="uni-center image-bg">
<image class="image" :mode="item.mode" src="/static/shuijiao.jpg"></image>
<image class="image" :mode="item.mode" src="/static/shuijiao.jpg" flatten></image>
</view>
</view>
<view class="uni-title">
<text class="uni-title-text">其他示例</text>
</view>
<view>
<text class="uni-subtitle-text">同时设置mode和圆角(右边为拍平测试)</text>
<view class="uni-center image-bg">
<image class="image radius" mode="heightFix" src="/static/shuijiao.jpg"></image>
<image class="image radius" mode="heightFix" src="/static/shuijiao.jpg" flatten></image>
</view>
</view>
<view>
<text class="uni-subtitle-text">设置图片width='100%'与mode='widthFix'(右边为拍平测试)</text>
<view class="uni-center image-bg">
<view class="uni-center" style="background-color: red; width: 150px; margin: 20px;">
<image style="width: 100%" mode="widthFix" src="/static/shuijiao.jpg"></image>
</view>
<view class="uni-center" style="background-color: red; width: 150px; margin: 20px;">
<image style="width: 100%" mode="widthFix" src="/static/shuijiao.jpg" flatten></image>
</view>
</view>
</view>
<view>
<text class="uni-subtitle-text">image默认mode(右边为拍平测试)</text>
<view class="uni-center image-bg">
<view class="uni-center" style="margin: 20px;">
<image style="width: 100px; height: 100px;margin-right: 20px;" src="/static/test-image/logo.png"></image>
<image style="width: 100px; height: 100px;" src="/static/test-image/logo.png" flatten></image>
</view>
</view>
</view>
</view>
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
type ImageMode = {
mode : string
description : string
}
// Data
const title = ref('image-mode')
const data = ref([
{
mode: 'scaleToFill',
description: '不保持纵横比缩放图片,使图片的宽高完全拉伸至填满 image 元素'
},
{
mode: 'aspectFit',
description: '保持纵横比缩放图片,使图片的长边能完全显示出来。也就是说,可以完整地将图片显示出来'
},
{
mode: 'aspectFill',
description: '保持纵横比缩放图片,只保证图片的短边能完全显示出来。也就是说,图片通常只在水平或垂直方向是完整的,另一个方向将会发生截取'
},
{
mode: 'top',
description: '不缩放图片,只显示图片的顶部区域'
},
{
mode: 'bottom',
description: '不缩放图片,只显示图片的底部区域'
},
{
mode: 'center',
description: '不缩放图片,只显示图片的中间区域'
},
{
mode: 'left',
description: '不缩放图片,只显示图片的左边区域'
},
{
mode: 'right',
description: '不缩放图片,只显示图片的右边区域'
},
{
mode: 'top left',
description: '不缩放图片,只显示图片的左上边区域'
},
{
mode: 'top right',
description: '不缩放图片,只显示图片的右上边区域'
},
{
mode: 'bottom left',
description: '不缩放图片,只显示图片的左下边区域'
},
{
mode: 'bottom right',
description: '不缩放图片,只显示图片的右下边区域'
},
{
mode: 'widthFix',
description: '宽度不变,高度自动变化,保持原图宽高比不变'
},
{
mode: 'heightFix',
description: '高度不变,宽度自动变化,保持原图宽高比不变'
}
] as Array<ImageMode>)
</script>
<style>
.image {
margin: 20px auto;
width: 100px;
height: 100px;
background-color: #eeeeee;
}
.radius {
border-radius: 10px;
}
.image-bg{
background:#FFFFFF;
}
</style>

查看文件

@@ -0,0 +1,29 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1;">
<!-- #endif -->
<view style="align-items: center;">
<text>原图是横向且orientation=90°的jpg图片,预期显示为竖向</text>
<image style="width: 100px;height: 200px;" :src="src1" @error="error1"></image>
<text>原图是横向且orientation=90°的heic图片(需要支持heic的平台方有效),预期显示为竖向</text>
<image style="width: 100px;height: 200px;" :src="src2" @error="error2"></image>
</view>
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
const src1 = ref('/static/test-image/orientation-90.jpg');
const src2 = ref('/static/test-image/orientation-90.heic');
function error1() {
src1.value = '/static/dislike.png';
}
function error2() {
src2.value = '/static/dislike.png';
}
</script>
<style>
</style>

查看文件

@@ -0,0 +1,26 @@
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
describe('image path', () => {
if (isMP) {
it('skip', () => {
expect(1).toBe(1)
})
return
}
let page;
beforeAll(async () => {
page = await program.reLaunch('/pages/component/image/image-path');
await page.waitFor('view')
await page.waitFor(isWeb ? 5000 : 2000); // 等待页面加载完成
});
it('screenshot', async () => {
const image = await program.screenshot({
fullPage: true,
});
expect(image).toSaveImageSnapshot();
});
});

文件差异因一行或多行过长而隐藏

查看文件

@@ -0,0 +1,25 @@
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isHarmony = platformInfo.startsWith('harmony')
describe('image switch render', () => {
if (!isHarmony) {
it('Only HarmonyOS', () => {
expect(1).toBe(1)
})
return
}
let page;
beforeAll(async () => {
page = await program.reLaunch('/pages/component/image/image-switch');
await page.waitFor('view')
// 需要第二次进入页面才可复现问题
page = await program.reLaunch('/pages/component/image/image-switch');
await page.waitFor('view')
});
it('screenshot', async () => {
const image = await program.screenshot({ fullPage: true });
expect(image).toSaveImageSnapshot();
});
});

查看文件

@@ -0,0 +1,20 @@
<template>
<view>
<image class="logo" src="/static/test-image/logo.png"></image>
<switch activeBackgroundColor="#23C343" backgroundColor="#C5C5C5" />
</view>
</template>
<style>
.logo {
height: 100px;
width: 100px;
margin: 100px auto 25px auto;
}
.title {
font-size: 18px;
color: #8f8f94;
text-align: center;
}
</style>

查看文件

@@ -0,0 +1,187 @@
jest.setTimeout(30000)
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
const isAppWebView = process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true'
const isAndroid = platformInfo.startsWith('android')
const isWeb = platformInfo.startsWith('web')
const isHarmony = platformInfo.startsWith('harmony')
const isPad = process.env.UNI_AUTOMATOR_IS_PAD == 'true'
describe('component-native-image', () => {
if (isMP || (isHarmony && isPad)) {
it('skip', () => {
expect(1).toBe(1)
})
return
}
const screenshotParams = { fullPage: true }
let page;
let start = 0;
beforeAll(async () => {
page = await program.reLaunch('/pages/component/image/image');
await page.waitFor('view');
await page.waitFor(isWeb ? 4000 : 100);
});
async function setPageData(newData) {
return await page.setData({ data: newData });
}
it('screenshot', async () => {
const image = await program.screenshot({fullPage: true});
expect(image).toSaveImageSnapshot()
});
it('check_image_load', async () => {
expect(await page.data('data.loadError')).toBe(false)
});
it('check_image_load_url', async () => {
await setPageData({
loadError: false,
imageSrc: 'https://request.dcloud.net.cn/api/http/contentType/image/png'
})
await page.waitFor(300);
expect(await page.data('data.loadError')).toBe(false)
})
if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
it('check_qurey_url', async () => {
await setPageData({
loadError: false,
imageSrc: '/static/test-image/logo.png?t=11234'
})
await page.waitFor(300);
expect(await page.data('data.loadError')).toBe(false)
})
};
it('check_image_load_error', async () => {
await setPageData({
loadError: false,
imageSrc: 'testerror.jpg'
})
await page.waitFor(300);
expect(await page.data('data.loadError')).toBe(true)
})
if (isAndroid && !isAppWebView) {
it('check-cookie', async () => {
await setPageData({
autoTest: true,
setCookieImage: 'https://cdn.dcloud.net.cn/img/shadow-grey.png'
});
await page.waitFor(1000);
await setPageData({
loadError: false,
verifyCookieImage: 'https://request.dcloud.net.cn/img/shadow-grey.png'
});
await page.waitFor(1000);
expect(await page.data('data.loadError')).toBe(false);
await setPageData({
autoTest: false
});
})
}
it('test event load', async () => {
await setPageData({
autoTest: true,
imageSrc: 'https://request.dcloud.net.cn/api/http/contentType/image/png'
});
start = Date.now();
await page.waitFor(async () => {
return (await page.data('data.eventLoad')) || (Date.now() - start > 1000);
});
expect(await page.data('data.eventLoad')).toEqual({
tagName: isMP ? '' : 'IMAGE',
type: 'load',
width: 10,
height: 10
});
});
it('test event error', async () => {
await setPageData({
imageSrc: 'https://request.dcloud.net.cn/api/http/contentType/404.png'
});
start = Date.now();
await page.waitFor(async () => {
return (await page.data('data.eventError')) || (Date.now() - start > 1000);
});
expect(await page.data('data.eventError')).toEqual({
tagName: isMP ? '' : 'IMAGE',
type: 'error'
});
await setPageData({
autoTest: false
});
});
if(isMP) {
// TODO 整理小程序、web支持的类型,页面上进行条件编译展示
return
}
// app web 存在差异
if (!isAppWebView) {
it('path-screenshot', async () => {
const page = await program.navigateTo('/pages/component/image/image-path');
await page.waitFor(3000);
const image = await program.screenshot(screenshotParams)
expect(image).toSaveImageSnapshot()
});
}
it('mode-screenshot', async () => {
if (process.env.android_cpu_type === 'x86_64') return
const page = await program.navigateTo('/pages/component/image/image-mode');
await page.waitFor(3000);
const image = await program.screenshot(screenshotParams)
expect(image).toSaveImageSnapshot()
});
it('long-path-screenshot', async() => {
if (isAndroid) {
const infos = process.env.uniTestPlatformInfo.split(' ');
const version = parseInt(infos[infos.length - 1]);
if (version < 8) {
console.log("安卓版本小于8设备 测试image-long 模拟器会出现内存不足错误 影响后续测试")
expect(1).toBe(1)
return
}
}
const page = await program.navigateTo('/pages/component/image/image-long');
await page.waitFor(3000);
const image = await program.screenshot(screenshotParams)
expect(image).toSaveImageSnapshot()
})
it('test all button clicks', async () => {
page = await program.reLaunch('/pages/component/image/image');
await page.waitFor('view');
await page.waitFor(isWeb ? 4000 : 100);
// 获取所有按钮元素
const buttons = await page.$$('.uni-btn');
const buttonCount = buttons.length;
console.log('buttonCount',buttonCount)
// 循环点击每个按钮
for (let i = 0; i < buttonCount; i++) {
// 重新获取按钮(因为返回后页面可能重新渲染)
const currentButtons = await page.$$('.uni-btn');
const button = currentButtons[i];
console.log('button',button)
// 点击按钮
await button.tap();
// 等待页面跳转完成,返回上一页
await page.waitFor(isWeb ? 1000 : 500);
await program.navigateBack();
await page.waitFor(300);
}
// 验证所有按钮都点击成功(通过没有抛出异常来验证)
expect(buttonCount).toBeGreaterThan(0);
});
});

查看文件

@@ -0,0 +1,187 @@
<template>
<view style="flex: 1;">
<page-head :title="data.title"></page-head>
<scroll-view style="flex: 1">
<view class="uni-padding-wrap">
<!-- image样式大合集 -->
<text class="uni-title-text">image样式大合集</text>
<text class="uni-subtitle-text uni-common-mb">右边为拍平</text>
<view class="styled-image-row">
<image class="styled-image" mode="aspectFill" :src="data.imageSrc"></image>
<image class="styled-image" mode="aspectFill" :src="data.imageSrc" flatten></image>
</view>
<text class="uni-title-text">自定义组件:右边拍平</text>
<view class="styled-image-row">
<child></child>
<child flatten></child>
</view>
<!-- 原有的基础拍平测试 -->
<text class="uni-title-text uni-common-mt">基础(右边为拍平)</text>
<view class="uni-center image-bg">
<!-- #ifndef APP-IOS -->
<image class="image" :fade-show="true" mode="widthFix" :src="data.imageSrc" @error="error" @load="load"></image>
<image class="image" :fade-show="true" mode="widthFix" :src="data.imageSrc" @error="error" @load="load" flatten></image>
<!-- #endif -->
<!-- #ifdef APP-IOS -->
<image class="image" mode="widthFix" :src="data.imageSrc" @error="error" @load="load"></image>
<image class="image" mode="widthFix" :src="data.imageSrc" @error="error" @load="load" flatten></image>
<!-- #endif -->
</view>
<button class="uni-btn" @tap="imageFormat">图片格式示例</button>
<button class="uni-btn" @tap="imageMode">图片缩放模式示例</button>
<button class="uni-btn" @tap="imagePath">图片路径示例</button>
<button class="uni-btn" @tap="imageLarge">大图示例</button>
<button class="uni-btn" @tap="imageLong">长图示例</button>
<button class="uni-btn" @tap="imageOrientation">图片方向修正示例</button>
<!-- #ifdef VUE3-VAPOR -->
<navigator url="/pages/template/2000-image/2000-image">
<button class="uni-btn">组件性能测试</button>
</navigator>
<navigator url="/pages/template/2000-image/2000-image-svg">
<button class="uni-btn">组件性能测试(SVG)</button>
</navigator>
<!-- #endif -->
</view>
</scroll-view>
<view v-if="data.autoTest">
<image :src="data.setCookieImage"></image>
<image :src="data.verifyCookieImage" @error="error"></image>
</view>
</view>
</template>
<script setup lang="uts">
import Child from './child.uvue'
type DataType = {
title: string;
imageSrc: string.ImageURIString;
loadError: boolean;
autoTest: boolean;
setCookieImage: string;
verifyCookieImage: string;
eventLoad: UTSJSONObject | null;
eventError: UTSJSONObject | null;
}
// 使用reactive避免ref数据在自动化测试中无法访问
const data = reactive({
title: 'image',
imageSrc: "/static/test-image/logo.png",
loadError: false,
// 自动化测试
autoTest: false,
setCookieImage: "",
verifyCookieImage: "",
eventLoad: null,
eventError: null
} as DataType)
const error = (event: ImageErrorEvent) => {
data.loadError = true
console.log(event.type, event.detail);
if (data.autoTest) {
data.eventError = {
"tagName": event.target?.tagName,
"type": event.type,
// "errMsg": event.detail.errMsg
};
}
}
const load = (event: ImageLoadEvent) => {
console.log(event.type, event.detail);
if (data.autoTest) {
data.eventLoad = {
"tagName": event.target?.tagName,
"type": event.type,
"width": event.detail.width,
"height": event.detail.height
};
}
}
const imageFormat = () => {
uni.navigateTo({
url: '/pages/component/image/image-format'
});
}
const imageMode = () => {
uni.navigateTo({
url: '/pages/component/image/image-mode'
});
}
const imagePath = () => {
uni.navigateTo({
url: '/pages/component/image/image-path'
});
}
const imageLarge = () => {
uni.navigateTo({
url: '/pages/component/image/image-large'
});
}
const imageLong = () => {
uni.navigateTo({
url: '/pages/component/image/image-long'
});
}
const imageOrientation = () => {
uni.navigateTo({
url: '/pages/component/image/image-orientation'
});
}
defineExpose({
data,
error,
load,
imageFormat,
imageMode,
imagePath,
imageLarge,
imageLong
})
</script>
<style>
.styled-image-row {
flex-direction: row;
background: #fff;
justify-content: space-around;
height: 120px;
align-items: center;
}
/* image样式大合集 */
.styled-image {
width: 80px;
height: 80px;
margin: 5px;
padding: 5px;
border: 2px solid #ff6b6b;
border-radius: 10px;
background-color: #ffe0e0;
/* === 阴影 === */
box-shadow: 0 3px 6px rgba(255, 107, 107, 0.3);
/* === 可见性 === */
opacity: 0.98;
/* === 变换 === */
transform: rotate(45deg);
}
.image {
margin: 20px auto;
width: 100px;
}
.image-bg {
background: #FFFFFF;
}
</style>

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 4.2 KiB