refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范
这个提交包含在:
@@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<view class="dialog-container">
|
||||
<!-- native-time-picker 通过 native-view 绑定原生time-picker 实现的UTS插件-标准模式组件 -->
|
||||
<native-time-picker class="native-time-picker" :hour=2 :minute=3 @changed="onChanged"></native-time-picker>
|
||||
<button @click="sure">确定</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
const currentPage = getCurrentInstance()?.proxy?.$page
|
||||
|
||||
function onChanged(e : UniNativeViewEvent) {
|
||||
console.log("onchanged-----", e.detail)
|
||||
}
|
||||
|
||||
function sure() {
|
||||
if (currentPage != null) {
|
||||
uni.closeDialogPage({
|
||||
dialogPage: currentPage
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.native-time-picker {
|
||||
margin: 10px auto 25px auto;
|
||||
border-style: solid;
|
||||
border-radius: 5px;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.dialog-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.3);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,55 @@
|
||||
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
|
||||
const isMP = platformInfo.startsWith('mp')
|
||||
const isWeb = platformInfo.startsWith('web')
|
||||
const isAppWebView = process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true'
|
||||
const isIOS = platformInfo.startsWith('ios')
|
||||
const NAV_BAR_HEIGHT = 44
|
||||
|
||||
describe('native-view.uvue', () => {
|
||||
if (isMP || isWeb || isAppWebView) {
|
||||
it('not support', () => {
|
||||
expect(1).toBe(1)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if(isIOS) {
|
||||
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
|
||||
if(
|
||||
platformInfo.indexOf('14.5') != -1 ||
|
||||
platformInfo.indexOf('13.7') != -1 ||
|
||||
platformInfo.indexOf('12.4') != -1
|
||||
){
|
||||
// TODO: 排查 ios 不兼容版本 测试异常原因
|
||||
it('14.5 13.7 12.4 测试异常', () => {
|
||||
expect(1).toBe(1)
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
it('native-view检测init函数是否响应', async () => {
|
||||
page = await program.reLaunch('/pages/component/native-view/native-view')
|
||||
await page.waitFor('view')
|
||||
|
||||
const isLoad = await page.callMethod('getIsLoadTest')
|
||||
expect(isLoad).toBe(true)
|
||||
})
|
||||
|
||||
it('native-view点击事件透传自定义value', async () => {
|
||||
page = await program.reLaunch('/pages/component/native-view/native-view')
|
||||
await page.waitFor('view')
|
||||
|
||||
const nativeButton = await page.$('#helloView')
|
||||
const rect = await nativeButton.offset()
|
||||
const size = await nativeButton.size()
|
||||
const windowInfo = await program.callUniMethod('getWindowInfo')
|
||||
const x = Math.round(rect.left + size.width / 2)
|
||||
const y = Math.round(rect.top + size.height / 2 + windowInfo.safeAreaInsets.top + NAV_BAR_HEIGHT)
|
||||
await program.device.tap(x, y + 30)
|
||||
await page.waitFor(100)
|
||||
|
||||
const buttonTapValue = await page.callMethod('getButtonTapValueTest')
|
||||
expect(buttonTapValue).toBe('CustomValue')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
<scroll-view style="flex: 1;">
|
||||
<!-- #endif -->
|
||||
<page-intro content="本页演示 native-view 原生视图与 UTS 插件组件:调用组件方法、native-button 与容器、native-view 样式;可跳转 native-time-picker 等原生能力。"></page-intro>
|
||||
<view style="padding-bottom: 50px;">
|
||||
<!-- #ifndef APP-HARMONY -->
|
||||
<text class="tips">说明:如果本地无 uts 插件编译环境请提交打包自定义基座查看效果</text>
|
||||
<!-- #endif -->
|
||||
<text>在 uvue 页面中使用 native-button</text>
|
||||
<button type="primary" @tap="testCallMethod">调用组件方法</button>
|
||||
<!-- native-button 通过 native-view 绑定原生button 实现的UTS插件-标准模式组件 -->
|
||||
<native-button id="helloView" class="native-button" style="width: 200px; height: 100px;" :text="buttonText" @buttonTap="ontap"
|
||||
@load="onload"></native-button>
|
||||
<native-button-container></native-button-container>
|
||||
<!-- #ifndef APP-HARMONY -->
|
||||
<button type="primary" @click="gotoTimePicker">调用native-time-picker</button>
|
||||
<!-- #endif -->
|
||||
|
||||
<text class="uni-title-text">native-view样式(仅支持排版相关样式)</text>
|
||||
<view class="styled-native-container">
|
||||
<native-view class="styled-native-view"></native-view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
</scroll-view>
|
||||
<!-- #endif -->
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { createNativeButtonContext } from "@/uni_modules/native-button";
|
||||
|
||||
const buttonText = ref("native-button")
|
||||
let isLoad = false
|
||||
let clickCount = 0
|
||||
let buttonTapValue = ""
|
||||
|
||||
function ontap(e : UniNativeViewEvent) {
|
||||
uni.showToast({
|
||||
title: "按钮被点击了"
|
||||
})
|
||||
clickCount ++
|
||||
buttonText.value = "native-button"+clickCount
|
||||
buttonTapValue = e.detail["value"] as string
|
||||
}
|
||||
|
||||
function onload() {
|
||||
//标记已初始化 用于自动化测试
|
||||
isLoad = true
|
||||
}
|
||||
|
||||
//用于自动化测试
|
||||
function getIsLoadTest():boolean {
|
||||
return isLoad
|
||||
}
|
||||
|
||||
//用于自动化测试
|
||||
function getButtonTapValueTest():string {
|
||||
return buttonTapValue
|
||||
}
|
||||
|
||||
function testCallMethod() {
|
||||
let context = createNativeButtonContext("helloView")
|
||||
context?.updateText("test code")
|
||||
}
|
||||
|
||||
function gotoTimePicker() {
|
||||
uni.openDialogPage({
|
||||
url: "/pages/component/native-view/native-view-time-picker-dialog",
|
||||
animationType: "fade-in"
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({getIsLoadTest, getButtonTapValueTest})
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.tips {
|
||||
font-size: 14px;
|
||||
color: #BEBEBE;
|
||||
margin: 25px auto 25px auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.native-button {
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
margin: 25px auto 25px auto;
|
||||
}
|
||||
|
||||
.styled-native-container {
|
||||
background-color: cyan;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.styled-native-view {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
margin: 20px 30px;
|
||||
}
|
||||
</style>
|
||||
在新工单中引用
屏蔽一个用户