refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范
这个提交包含在:
@@ -0,0 +1,49 @@
|
||||
const PAGE_PATH = '/pages/API/report/report'
|
||||
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
|
||||
const isMP = platformInfo.startsWith('mp')
|
||||
const isHarmony = platformInfo.startsWith('harmony')
|
||||
|
||||
describe('report', () => {
|
||||
if (isMP || isHarmony || process.env.NODE_ENV != 'production') {
|
||||
it('not support', () => {
|
||||
expect(1).toBe(1)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
let page = null
|
||||
beforeAll(async () => {
|
||||
page = await program.navigateTo(PAGE_PATH)
|
||||
await page.waitFor('view')
|
||||
})
|
||||
it('Report - onLaunch', async () => {
|
||||
await page.callMethod('handleAppLaunch')
|
||||
const msg = await page.data('msg.value')
|
||||
expect(msg).toBe('onLaunch --> report:ok')
|
||||
})
|
||||
it('Report - onShow', async () => {
|
||||
await page.callMethod('handleAppShow')
|
||||
const msg = await page.data('msg.value')
|
||||
expect(msg).toBe('onAppShow --> report:ok')
|
||||
})
|
||||
it('Report - onHide', async () => {
|
||||
await page.callMethod('handleAppHide')
|
||||
const msg = await page.data('msg.value')
|
||||
expect(msg).toBe('onAppHide --> report:ok')
|
||||
})
|
||||
it('Report - onError', async () => {
|
||||
await page.callMethod('handleAppError')
|
||||
const msg = await page.data('msg.value')
|
||||
expect(msg).toBe('onAppError --> report:ok')
|
||||
})
|
||||
it('Report - customTitle', async () => {
|
||||
await page.callMethod('handleTitle')
|
||||
const msg = await page.data('msg.value')
|
||||
expect(msg).toBe('自定义title --> report:ok')
|
||||
})
|
||||
it('Report - customEvent', async () => {
|
||||
await page.callMethod('handleEvent')
|
||||
const msg = await page.data('msg.value')
|
||||
expect(msg).toBe('自定义事件 --> report:ok')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,220 @@
|
||||
<template>
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
<scroll-view style="flex:1">
|
||||
<!-- #endif -->
|
||||
<page-head title="report"></page-head>
|
||||
<view class="tips">
|
||||
<view class="tips-title">调用信息:</view>
|
||||
<view class="tips-content">{{msg.value}}</view>
|
||||
</view>
|
||||
<view class="page">
|
||||
|
||||
<button class="normal-button" type="default" @click="handleAppLaunch">
|
||||
模拟应用启动
|
||||
</button>
|
||||
<button class="normal-button" type="default" @click="handleAppHide">
|
||||
模拟应用切入后台
|
||||
</button>
|
||||
<button class="normal-button" type="default" @click="handleAppShow">
|
||||
模拟应用切入前台
|
||||
</button>
|
||||
<button class="normal-button" type="default" @click="handleAppError">
|
||||
模拟应用错误
|
||||
</button>
|
||||
<button class="normal-button" type="default" @click="handleTitle">
|
||||
模拟自定义title
|
||||
</button>
|
||||
<button class="normal-button" type="default" @click="handleEvent">
|
||||
模拟自定义事件
|
||||
</button>
|
||||
<text class="instructions">
|
||||
当前页面调用API均为模拟,请查看文档,在特定场景下使用以上 API。请在main.uts中设置统计debug配置为true,并点击按钮查控制台输出。
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
</scroll-view>
|
||||
<!-- #endif -->
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
type MsgType = {
|
||||
value: string
|
||||
}
|
||||
// 使用reactive避免ref数据在自动化测试中无法访问
|
||||
const msg = reactive({ value: '点击按钮,测试上报' } as MsgType)
|
||||
|
||||
onLoad(() => {
|
||||
uni.report({
|
||||
name: '自定义上报-report页面打开',
|
||||
options: '1'
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
// #ifndef APP-IOS
|
||||
uni.report({
|
||||
name: '自定义上报-report页面关闭',
|
||||
options: '1'
|
||||
})
|
||||
// #endif
|
||||
|
||||
})
|
||||
|
||||
const handleAppLaunch = () => {
|
||||
const options = uni.getLaunchOptionsSync()
|
||||
// #ifndef APP-IOS
|
||||
uni.report({
|
||||
name: 'uni-app-launch',
|
||||
options: options,
|
||||
success: (res) => {
|
||||
msg.value = 'onLaunch --> ' + res.errMsg
|
||||
console.log(res);
|
||||
}, fail: (err) => {
|
||||
msg.value = 'onLaunch --> ' + err.errMsg
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
|
||||
}
|
||||
|
||||
const handleAppHide = () => {
|
||||
// #ifndef APP-IOS
|
||||
uni.report({
|
||||
name: 'uni-app-hide',
|
||||
success: (res) => {
|
||||
msg.value = 'onAppHide --> ' + res.errMsg
|
||||
console.log(res);
|
||||
}, fail: (err) => {
|
||||
msg.value = 'onAppHide --> ' + err.errMsg
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
|
||||
}
|
||||
|
||||
const handleAppShow = () => {
|
||||
// const options = uni.getLaunchOptionsSync()
|
||||
// #ifndef APP-IOS
|
||||
uni.report({
|
||||
name: 'uni-app-show',
|
||||
success: (res) => {
|
||||
msg.value = 'onAppShow --> ' + res.errMsg
|
||||
console.log(res);
|
||||
}, fail: (err) => {
|
||||
msg.value = 'onAppShow --> ' + err.errMsg
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
|
||||
}
|
||||
|
||||
const handleAppError = () => {
|
||||
const errmsg = '测试错误'
|
||||
// #ifndef APP-IOS
|
||||
uni.report({
|
||||
name: 'uni-app-error',
|
||||
options: errmsg,
|
||||
success: (res) => {
|
||||
msg.value = 'onAppError --> ' + res.errMsg
|
||||
console.log(res);
|
||||
}, fail: (err) => {
|
||||
msg.value = 'onAppError --> ' + err.errMsg
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
|
||||
}
|
||||
|
||||
const handleEvent = () => {
|
||||
// 此处name为用户自定义
|
||||
// #ifndef APP-IOS
|
||||
uni.report({
|
||||
name: 'custom-event',
|
||||
options: {
|
||||
title: '自定义事件',
|
||||
total: 1
|
||||
},
|
||||
success: (res) => {
|
||||
msg.value = '自定义事件 --> ' + res.errMsg
|
||||
console.log(res);
|
||||
}, fail: (err) => {
|
||||
msg.value = '自定义事件 --> ' + err.errMsg
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
|
||||
}
|
||||
|
||||
const handleTitle = () => {
|
||||
// 此处name为用户自定义
|
||||
// #ifndef APP-IOS
|
||||
uni.report({
|
||||
name: 'title',
|
||||
options: '自定义title测试上报',
|
||||
success: (res) => {
|
||||
msg.value = '自定义title --> ' + res.errMsg
|
||||
console.log(res);
|
||||
}, fail: (err) => {
|
||||
msg.value = '自定义title --> ' + err.errMsg
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
msg,
|
||||
handleAppLaunch,
|
||||
handleAppHide,
|
||||
handleAppShow,
|
||||
handleAppError,
|
||||
handleEvent,
|
||||
handleTitle
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.page {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.tips {
|
||||
margin: 15px;
|
||||
padding: 15px;
|
||||
background-color: #f5f5f5;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.tips-title {
|
||||
font-size: 16px;
|
||||
color: #333;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.tips-content {
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.normal-button {
|
||||
width: 100%;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.instructions {
|
||||
margin-top: 10px;
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
background-color: #eee;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
在新工单中引用
屏蔽一个用户