This commit is contained in:
Home
2025-12-01 03:42:34 +08:00
parent 492a164bff
commit fde86ef902
1917 changed files with 21835 additions and 214147 deletions
+6
View File
@@ -0,0 +1,6 @@
https://www.bilibili.com/video/BV1pnkFYmEAE/?spm_id_from=333.337.search-card.all.click&vd_source=8e20afb98217f57c01c5b26045b62d6f
根目录进入
cd CosyVoice
启动虚拟环境
conda activate CosyVoice_V2
+21
View File
@@ -0,0 +1,21 @@
其他人教程https://blog.lukeewin.top/archives/centos-streaming-asr
git 地址:https://github.com/modelscope/FunASR/blob/main/runtime/docs/SDK_tutorial_online_zh.md#html-client
docker pull registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-online-cpu-0.1.12
docker exec -it 5808d9cf479122f0aaa59d5500148debfc80c4274159b96e2426a2b90b2976c8 bash
cd FunASR/runtime
nohup bash run_server_2pass.sh \
--certfile 0 \
--download-model-dir /workspace/models \
--vad-dir damo/speech_fsmn_vad_zh-cn-16k-common-onnx \
--model-dir damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-onnx \
--online-model-dir damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-online-onnx \
--punc-dir damo/punc_ct-transformer_zh-cn-common-vad_realtime-vocab272727-onnx \
--lm-dir damo/speech_ngram_lm_zh-cn-ai-wesp-fst \
--itn-dir thuduj12/fst_itn_zh \
--hotword /workspace/models/hotwords.txt > log.txt 2>&1 &
tail -n 100 -f log.txt
-29
View File
@@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
package="io.dcloud.hellouts">
<application android:networkSecurityConfig="@xml/custom_network_security_config"
>
<!--meta-data-->
<meta-data android:name="TencentMapSDK" android:value="您申请的腾讯定位App Key" />
<!--需要替换成开发者自己的包名-->
<activity android:name="uni.UNI70BE9D0.RootPackageActivity"
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<!--需要替换成开发者自己的包名-->
<action android:name="uni.UNI70BE9D0.RootPackageActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!--meta-data-->
<activity android:name="io.dcloud.uniapp.UniLaunchProxyActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="appuniappx"/>
</intent-filter>
</activity>
</application>
</manifest>
-46
View File
@@ -1,46 +0,0 @@
<!-- HBuilder X 版本要求: 3.6.11+ -->
<script lang="ts">
// #ifdef APP-ANDROID || APP-HARMONY
let firstBackTime = 0
// #endif
export default {
onLaunch: function () {
console.log('App Launch')
},
onShow: function () {
console.log('App Show')
},
onHide: function () {
console.log('App Hide')
},
// #ifdef UNI-APP-X && APP-ANDROID || APP-HARMONY
onLastPageBackPress: function () {
console.log('App LastPageBackPress')
if (firstBackTime == 0) {
uni.showToast({
title: '再按一次退出应用',
position: 'bottom',
})
firstBackTime = Date.now()
setTimeout(() => {
firstBackTime = 0
}, 2000)
} else if (Date.now() - firstBackTime < 2000) {
firstBackTime = Date.now()
uni.exit()
}
},
// #endif
onExit() {
console.log('App Exit')
},
}
</script>
<style>
/*每个页面公共css */
/* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */
/* #ifdef APP-VUE */
@import './common/uni.css';
/* #endif */
</style>
-7
View File
@@ -1,7 +0,0 @@
### uts 示例项目
### 仓库分支与 HBuilder 版本对应关系
- master 对应 [HBuilder](https://www.dcloud.io/hbuilderx.html) 正式版
- alpha 对应 [HBuilder](https://www.dcloud.io/hbuilderx.html) Alpha 版
- dev 对应 [HBuilder](https://www.dcloud.io/hbuilderx.html) 内部 dev 版
-3
View File
@@ -1,3 +0,0 @@
## 1.1.23
* update 4.85.2025110510
-136
View File
@@ -1,136 +0,0 @@
/* #ifndef APP-PLUS-NVUE */
/* page {
min-height: 100%;
height: auto;
} */
/* #endif */
/* 解决头条小程序字体图标不显示问题,因为头条运行时自动插入了span标签,且有全局字体 */
/* #ifdef MP-TOUTIAO */
/* text :not(view) {
font-family: uniicons;
} */
/* #endif */
.uni-icon {
/* font-family: uniicons;
font-weight: normal; */
width: 14px;
height: 14px;
}
.uni-container {
padding: 0 15px 15px;
background-color: #f8f8f8;
}
.uni-header-logo {
/* #ifdef H5 */
display: flex;
/* #endif */
padding: 15px 15px;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 10rpx;
}
.uni-header-image {
width: 80px;
height: 80px;
}
.uni-hello-text {
margin-bottom: 20px;
color: #7A7E83;
}
.hello-text {
color: #7A7E83;
font-size: 14px;
line-height: 20px;
}
.hello-link {
color: #7A7E83;
font-size: 14px;
line-height: 20px;
}
.uni-panel {
margin-bottom: 12px;
}
.text-disabled {
color: #a0a0a0;
}
.uni-panel-h {
display: flex;
background-color: #ffffff;
flex-direction: row !important;
justify-content: space-between !important;
align-items: center !important;
padding: 12px;
}
/*
.uni-panel-h:active {
background-color: #f8f8f8;
}
*/
.uni-panel-h-on {
background-color: #f0f0f0;
}
.uni-panel-text {
color: #000000;
font-size: 14px;
font-weight: normal;
}
.uni-panel-icon {
margin-left: 15px;
color: #999999;
font-size: 14px;
font-weight: normal;
transform: rotate(0deg);
transition-duration: 0s;
transition-property: transform;
}
.uni-panel-icon-on {
transform: rotate(180deg);
}
.uni-navigate-item {
display: flex;
flex-direction: row;
align-items: center;
background-color: #FFFFFF;
border-top-style: solid;
border-top-color: #f0f0f0;
border-top-width: 1px;
padding: 12px;
justify-content: space-between;
/* #ifdef H5 */
/* cursor: pointer; */
/* #endif */
}
.uni-navigate-item-active {
background-color: #f8f8f8;
}
.uni-navigate-text {
color: #000000;
font-size: 14px;
font-weight: normal;
}
.uni-navigate-icon {
margin-left: 15px;
color: #999999;
font-size: 14px;
font-weight: normal;
}
-159
View File
@@ -1,159 +0,0 @@
.uni-padding-wrap {
padding: 0 30rpx;
}
.uni-title {
padding: 20rpx 0;
}
.uni-title-text {
font-size: 30rpx;
font-weight: bold;
}
.uni-subtitle-text {
margin-top: 10rpx;
font-size: 24rpx;
color: #888;
font-weight: bold;
}
.uni-common-mb {
margin-bottom: 30rpx;
}
.uni-common-pb {
padding-bottom: 30rpx;
}
.uni-common-pl {
padding-left: 30rpx;
}
.uni-common-mt {
margin-top: 30rpx;
}
.uni-hello-text {
color: #7A7E83;
line-height: 22px;
}
.uni-list {
background-color: #FFFFFF;
position: relative;
display: flex;
flex-direction: column;
border-bottom: 1px solid #c8c7cc;
}
.uni-list-cell {
position: relative;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.uni-list-cell-line {
border-bottom: 1px solid #c8c7cc;
}
.uni-list-cell-hover {
background-color: #eee;
}
.uni-list-cell-pd {
padding: 22rpx 30rpx 22rpx 0;
}
.uni-list-cell-left {
padding: 0 30rpx 0 20rpx;
}
.uni-list-cell-db,
.uni-list-cell-right {
flex: 1;
}
.uni-label {
width: 210rpx;
font-size: 28rpx;
/* word-wrap: break-word;
word-break: break-all;
text-indent:20rpx; */
}
.uni-input {
height: 50rpx;
padding: 15rpx 25rpx;
line-height: 50rpx;
font-size: 28rpx;
background: #FFF;
flex: 1;
box-sizing: content-box;
}
.uni-flex {
/* #ifdef H5 */
display: flex;
/* #endif */
flex-direction: row;
}
.uni-flex-item {
flex: 1;
}
.uni-row {
flex-direction: row;
}
.uni-column {
flex-direction: column;
}
/* 背景色 */
.uni-bg-red {
background: #F76260;
color: #FFF;
}
.uni-bg-green {
background: #09BB07;
color: #FFF;
}
.uni-bg-blue {
background: #007AFF;
color: #FFF;
}
.uni-btn-v {
padding: 10rpx 0;
}
.uni-btn {
margin-top: 20rpx;
}
.uni-link {
color: #576B95;
font-size: 26rpx;
}
.uni-center {
flex-direction: row;
justify-content: center;
}
/* textarea */
.uni-textarea-box {
background: #ffffff;
}
.uni-textarea {
padding: 18rpx;
line-height: 1.6;
font-size: 28rpx;
}
@@ -1,38 +0,0 @@
<template name="page-head">
<view class="common-page-head">
<view class="common-page-head-title-box">
<text class="common-page-head-title">{{title}}</text>
</view>
</view>
</template>
<script>
export default {
name: "page-head",
props: {
title: {
type: String,
default: ""
}
}
}
</script>
<style>
.common-page-head {
display: flex;
padding: 35rpx;
flex-direction: row;
justify-content: center;
}
.common-page-head-title-box {
padding: 0 40rpx;
height: 88rpx;
border-bottom: 2rpx solid #D8D8D8;
}
.common-page-head-title {
line-height: 88rpx;
font-size: 30rpx;
color: #BEBEBE;
}
</style>
-31
View File
@@ -1,31 +0,0 @@
module.exports = {
"is-custom-runtime": false,
"compile": true,
"h5": {
"options": {
"headless": true
},
"executablePath": ""
},
"mp-weixin": {
"port": 9420,
"account": "",
"args": "",
"cwd": "",
"launch": true,
"teardown": "disconnect",
"remote": false,
"executablePath": ""
},
"app-plus": {
"android": {
"id": "emulator-5554",
"executablePath": "/Users/yuanrenjie/Desktop/HBuilderX-Alpha.app/Contents/HBuilderX/plugins/launcher/base/android_base.apk"
},
"version": "/Users/yuanrenjie/Desktop/HBuilderX-Alpha.app/Contents/HBuilderX/plugins/launcher/base/version.txt",
"ios": {
"id": "",
"executablePath": ""
}
}
}
-55
View File
@@ -1,55 +0,0 @@
const {
readFileSync,
readdirSync
} = require('fs')
const {
extname,
resolve
} = require('path')
const describeRE = /describe\(["|'](.*)["|']/
const testsRE = /test\(["|'](.*)["|']/g
function parse(content) {
const describes = content.match(describeRE)
if (!describes) {
return
}
const describe = describes[1]
const tests = []
let test
while (test = testsRE.exec(content)) {
tests.push(test[1])
}
return {
describe,
tests
}
}
function parseDescribes() {
const dir = resolve(__dirname, 'uni_modules/uts-tests/utssdk')
const describes = []
readdirSync(dir).forEach(file => {
if (extname(file) === '.uts') {
describes.push(parse(readFileSync(resolve(dir, file), 'utf8')))
}
})
return describes
};
module.exports = {
testTimeout: 60000,
reporters: [
'default'
],
setupFiles: ['./jest.global.js'],
globals: {
describes: parseDescribes()
},
watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],
moduleFileExtensions: ['js', 'json'],
rootDir: __dirname,
testMatch: ["<rootDir>/pages/**/*test.[jt]s?(x)"],
testPathIgnorePatterns: ['/node_modules/']
}
-44
View File
@@ -1,44 +0,0 @@
const {
readFileSync,
readdirSync
} = require('fs')
const {
extname,
resolve
} = require('path')
module.exports = async function (globalConfig, projectConfig) {
const describeRE = /describe\(["|'](.*)["|']/
const testsRE = /test\(["|'](.*)["|']/g
function parse(content) {
const describes = content.match(describeRE)
if (!describes) {
return
}
const describe = describes[1]
const tests = []
let test
while (test = testsRE.exec(content)) {
tests.push(test[1])
}
return {
describe,
tests
}
}
function parseDescribes() {
const dir = resolve(__dirname, 'uni_modules/uts-tests/utssdk')
const describes = []
readdirSync(dir).forEach(file => {
if (extname(file) === '.uts') {
describes.push(parse(readFileSync(resolve(dir, file), 'utf8')))
}
})
return describes
};
global.describes = parseDescribes();
};
-10
View File
@@ -1,10 +0,0 @@
import App from './App.vue'
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
return {
app
}
}
-57
View File
@@ -1,57 +0,0 @@
{
"name" : "UTS 插件工程",
"appid" : "",
"description" : "",
"versionName" : "1.1.0",
"versionCode" : "110",
"transformPx" : false,
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
"modules" : {},
"distribute" : {
"android" : {
"permissions" : [
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>"
],
"minSdkVersion" : 21,
"abiFilters" : [ "arm64-v8a" ]
},
"ios" : {
"dSYMs" : false
},
"sdkConfigs" : {
"ad" : {}
}
}
},
"quickapp" : {},
"mp-weixin" : {
"appid" : "",
"setting" : {
"urlCheck" : false
},
"usingComponents" : true
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false
},
"vueVersion" : "3"
}
@@ -1 +0,0 @@
demo
-88
View File
@@ -1,88 +0,0 @@
{
"id": "hello-uts",
"name": "hello-uts",
"displayName": "hello-uts",
"version": "1.1.23",
"description": "UTS插件示例项目",
"repository": "https://gitcode.net/dcloud/hello-uts",
"keywords": [
"uts",
"示例工程"
],
"author": "",
"license": "MIT",
"dependencies": {},
"engines": {
"HBuilderX": "^3.99"
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "不采集任何数据",
"permissions": "- android.permission.INTERNET \n- android.permission.READ_EXTERNAL_STORAGE \n- android.permission.WRITE_EXTERNAL_STORAGE \n- android.permission.ACCESS_FINE_LOCATION \n- android.permission.ACCESS_COARSE_LOCATION \n- android.permission.ACCESS_NETWORK_STATE \n- android.permission.READ_MEDIA_IMAGES \n- android.permission.READ_MEDIA_VIDEO"
},
"npmurl": "",
"type": "uniapp-template-project"
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"App": {
"app-vue": "y",
"app-nvue": "n",
"app-uvue": "n"
},
"H5-mobile": {
"Safari": "n",
"Android Browser": "n",
"微信浏览器(Android)": "n",
"QQ浏览器(Android)": "n"
},
"H5-pc": {
"Chrome": "n",
"IE": "n",
"Edge": "n",
"Firefox": "n",
"Safari": "n"
},
"小程序": {
"微信": "n",
"阿里": "n",
"百度": "n",
"字节跳动": "n",
"QQ": "n",
"京东": "n",
"钉钉": "n",
"快手": "n",
"飞书": "n"
},
"快应用": {
"华为": "n",
"联盟": "n"
},
"Vue": {
"vue2": "y",
"vue3": "y"
}
}
}
}
}
-233
View File
@@ -1,233 +0,0 @@
{
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/index/basicTest",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
// #ifndef WEB || MP || APP-HARMONY
,
{
"path": "pages/advance/advance",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/SystemAPI/SystemAPI",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/SystemAPI/Alert/alert",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "pages/component/helloView",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/SDKIntegration/SDKIntegration",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/SDKIntegration/TencentLocation/TencentLocation",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/SDKIntegration/Lottie/index",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/SDKIntegration/Toast/Toast",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/lifecycle/lifecycle",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/resource/resource",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/advance/android/decorview",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/advance/iOS/getResourcePath",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/advance/android/assetaudio",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/SystemAPI/ScreenListen/screenlisten",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/SyntaxCase/index",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/SyntaxCase/paramTest",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/SyntaxCase/consoleTest",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/SyntaxCase/MixNativeCode",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/SyntaxCase/nvueTest",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/SyntaxCase/instanceTest",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
// #endif
// #ifdef APP-ANDROID || APP-IOS
,{
"path": "pages/SyntaxCase/utsAndroid",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
,
{
"path": "pages/SyntaxCase/utsiOS",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
// #endif
// #ifdef APP-HARMONY
,{
"path" : "pages/issues/issue-20157/issue-20157",
"style" :
{
"navigationBarTitleText" : "issue-20157"
}
}
// #endif
],
"tabBar": {
"color": "#7A7E83",
"selectedColor": "#007AFF",
"borderStyle": "black",
"backgroundColor": "#F8F8F8",
"list": [{
"pagePath": "pages/index/index",
"text": "入门"
},
{
"pagePath": "pages/advance/advance",
"text": "进阶"
}, {
"pagePath": "pages/SystemAPI/SystemAPI",
"text": "系统API"
}, {
"pagePath": "pages/SDKIntegration/SDKIntegration",
"text": "三方SDK"
}
]
},
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
},
"uniIdRouter": {}
}
@@ -1,82 +0,0 @@
<template>
<div>
<button @tap="changeUrl">播放本地动画资源</button>
<button @tap="changeServerUrl">播放远程动画资源</button>
<button @tap="changeAutoPlay">测试AutoPlay</button>
<button @tap="changeLoop">测试Loop</button>
<button @tap="changeAction(1)">测试action play</button>
<button @tap="changeAction(2)">测试action pause</button>
<button @tap="changeAction(3)">测试action stop</button>
<uts-animation-view ref="animView" :path="animUrl" :autoplay="autoplay" :loop="loop" :action="action"
:hidden="hidden" @bindended="testAnimEnd" @click="lottieClickTest" @longpress="lottieLongpressTest"
:style="{width:widthNum+'rpx',height:heightNum+'px',background:yanse}">
</uts-animation-view>
</div>
</template>
<script>
export default {
data() {
return {
hidden: false,
autoplay: false,
action: "play",
loop: false,
yanse: "red",
widthNum: 750,
heightNum: 200,
comShow: true,
animUrl: "/static/anim_a.json"
}
},
methods: {
changeAutoPlay: function() {
this.autoplay = !this.autoplay
},
changeUrl: function() {
if (this.animUrl == "/static/anim_a.json") {
this.animUrl = "/static/anim_b.json"
} else {
this.animUrl = "/static/anim_a.json"
}
},
changeServerUrl: function() {
this.animUrl = "https://b.bdstatic.com/miniapp/images/lottie_example_one.json"
},
changeAction: function(type) {
if (type == 1) {
this.action = "play"
} else if (type == 2) {
this.action = "pause"
} else if (type == 3) {
this.action = "stop"
}
},
changeLoop: function() {
this.loop = !this.loop
},
testAnimEnd: function(res) {
console.log("testAnimEnd");
console.log(res);
},
changeRepeat: function(res) {
this.$refs["animView"].updateRepeatConfig("RESTART");
},
lottieClickTest: function(res) {
console.log("lottieClickTest");
console.log(res);
},
lottieLongpressTest: function(res) {
console.log("lottieClickTest");
console.log(res);
},
}
}
</script>
@@ -1,79 +0,0 @@
<template>
<div>
<button @tap="changeUrl">播放本地动画资源</button>
<button @tap="changeServerUrl">播放远程动画资源</button>
<button @tap="changeAutoPlay">测试AutoPlay</button>
<button @tap="changeLoop">测试Loop</button>
<button @tap="changeAction(1)">测试action play</button>
<button @tap="changeAction(2)">测试action pause</button>
<button @tap="changeAction(3)">测试action stop</button>
<uts-animation-view ref="animView" :path="animUrl" :autoplay="autoplay" :loop="loop" :action="action"
:hidden="hidden" @bindended="testAnimEnd" @click="lottieClickTest" @longpress="lottieLongpressTest"
:style="{width:widthNum+'rpx',height:heightNum+'px',background:yanse}">
</uts-animation-view>
</div>
</template>
<script lang="ts">
export default {
data() {
return {
hidden: false,
autoplay: false,
action: "play",
loop: false,
yanse: "red",
widthNum: 750,
heightNum: 200,
comShow: true,
animUrl: "/static/anim_a.json"
}
},
methods: {
changeAutoPlay: function() {
this.autoplay = !this.autoplay
},
changeUrl: function() {
if (this.animUrl == "/static/anim_a.json") {
this.animUrl = "/static/anim_b.json"
} else {
this.animUrl = "/static/anim_a.json"
}
},
changeServerUrl: function() {
this.animUrl = "https://b.bdstatic.com/miniapp/images/lottie_example_one.json"
},
changeAction: function(type: number) {
if (type == 1) {
this.action = "play"
} else if (type == 2) {
this.action = "pause"
} else if (type == 3) {
this.action = "stop"
}
},
changeLoop: function() {
this.loop = !this.loop
},
testAnimEnd: function() {
console.log("testAnimEnd");
},
changeRepeat: function() {
(this.$refs["animView"] as UtsAnimationViewElement).setRepeatMode("RESTART");
},
lottieClickTest: function() {
console.log("lottieClickTest");
},
lottieLongpressTest: function() {
console.log("lottieClickTest");
},
}
}
</script>
@@ -1,104 +0,0 @@
<template>
<view class="uni-container">
<page-head :title="title"></page-head>
<view class="uni-panel" v-for="(item, index) in list" :key="index">
<view class="uni-panel-h" :class="item.open == true ? 'uni-panel-h-on' : ''" @click="goDetailPage(item)"
hover-class="uni-navigate-item-active">
<text class="uni-panel-text">{{item.name}}</text>
<image :src="arrowRightIcon" class="uni-icon"></image>
</view>
</view>
</view>
</template>
<script lang="ts">
import {
checkHasIntegration
} from "@/uni_modules/uts-tencentgeolocation";
import {
checkHasLottieIntegration
} from "@/uni_modules/uts-animation-view";
type ListItem = {
name : string,
open ?: boolean,
function ?: string,
url ?: string
}
export default {
data() {
return {
title: 'SDK集成示例',
list: [{
name: "腾讯定位sdk集成示例",
function: "gotoTencentLocation",
},
{
name: "Toast示例",
url: "SDKIntegration/Toast/Toast"
},
{
name: "Lottie动画示例",
function: "gotoLottie"
}
] as ListItem[],
arrowRightIcon: '/static/icons/arrow-right.png',
}
},
methods: {
goDetailPage(e : ListItem) {
if (e.function != null) {
const funName = e.function
switch (funName) {
case 'gotoTencentLocation':
this.gotoTencentLocation()
break
case 'gotoLottie':
this.gotoLottie()
break
}
return
}
uni.navigateTo({
url: `/pages/${e.url!}`
})
},
gotoLottie: function () {
if (checkHasLottieIntegration()) {
uni.navigateTo({
url: '/pages/SDKIntegration/Lottie/index'
})
} else {
uni.showToast({
icon: 'none',
title: '需要在自定义基座中运行'
})
}
},
gotoTencentLocation: function () {
let ret = checkHasIntegration();
if (!ret) {
uni.showToast({
icon: 'none',
title: '需要在自定义基座中运行'
})
} else {
uni.navigateTo({
url: '/pages/SDKIntegration/TencentLocation/TencentLocation'
})
}
},
gotoTencentMap: function () {
uni.navigateTo({
url: '/pages/SDKIntegration/TencentMap/TencentMap'
})
}
}
}
</script>
<style>
@import '@/common/uni-uvue.css';
</style>
@@ -1,95 +0,0 @@
<template>
<view class="uni-container">
<page-head :title="title"></page-head>
<view class="uni-panel" v-for="(item, index) in list" :key="index">
<view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="goDetailPage(item)" hover-class="uni-navigate-item-active">
<text class="uni-panel-text">{{item.name}}</text>
<image :src="arrowRightIcon" class="uni-icon"></image>
</view>
</view>
</view>
</template>
<script>
import {
checkHasIntegration
} from "@/uni_modules/uts-tencentgeolocation";
import {
checkHasLottieIntegration
} from "@/uni_modules/uts-animation-view";
export default {
data() {
return {
title: 'SDK集成示例',
list: [{
name: "腾讯定位sdk集成示例",
function: "gotoTencentLocation"
},
{
name: "Toast示例",
url: "SDKIntegration/Toast/Toast"
},
{
name: "Lottie动画示例",
function: "gotoLottie"
}
],
arrowRightIcon: '/static/icons/arrow-right.png',
}
},
methods: {
goDetailPage(e) {
if (e.function) {
this[e.function]()
return
}
uni.navigateTo({
url: `/pages/${e.url}`
})
},
gotoLottie: function(e) {
if (checkHasLottieIntegration()) {
uni.navigateTo({
url: '/pages/SDKIntegration/Lottie/index'
})
} else {
uni.showToast({
icon: 'none',
title: '需要在自定义基座中运行'
})
}
},
gotoTencentLocation: function(e) {
let ret = checkHasIntegration();
if (!ret) {
uni.showToast({
icon: 'none',
title: '需要在自定义基座中运行'
})
} else {
uni.navigateTo({
url: '/pages/SDKIntegration/TencentLocation/TencentLocation'
})
}
},
gotoTencentMap: function(e) {
uni.navigateTo({
url: '/pages/SDKIntegration/TencentMap/TencentMap'
})
}
}
}
</script>
<style>
@import '@/common/uni-uvue.css';
.uni-container {
min-height: 100%;
}
</style>
@@ -1,100 +0,0 @@
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1. 腾讯定位sdk需在腾讯地图官网申请key。 https://lbs.qq.com/
</view>
<view class="uni-hello-text">
2. 按照readme文档配置apikey
</view>
<view class="uni-hello-text">
3. 需要制作自定义基座运行
</view>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="checkLocationPermission">请求定位权限</button>
<button type="primary" @tap="testGetlocation">获取设备位置信息</button>
<button type="primary" @tap="testWatchPosition">监听设备位置信息</button>
<button type="primary" @tap="testClearWatch">停止监听</button>
</view>
</view>
</template>
<script>
// import {
// checkHasIntegration,
// requestPremission,
// getLocation,
// watchPosition,
// clearWatch
// } from "../../../uni_modules/uts-tencentgeolocation";
export default {
data() {
return {
title: '腾讯定位SDK集成示例',
}
},
methods: {
checkLocationPermission: function() {
// requestPremission();
},
testGetlocation: function() {
// let startRet = getLocation({
// geocode: true,
// success: function(response) {
// console.log(response);
// var addressDesc = response.name + '-' + response.address
// uni.showToast({
// title: '执行结果:' + addressDesc,
// icon: 'none'
// });
// },
// fail: function(msg) {
// uni.showToast({
// title: msg,
// icon: "none"
// })
// }
// })
// if (!startRet) {
// uni.showToast({
// title: '定位启动失败,请检查配置',
// icon: 'none'
// });
// }
},
testWatchPosition() {
// watchPosition({
// geocode: true,
// success: function(response) {
// console.log(response);
// var addressDesc = response.name + '-' + response.address
// uni.showToast({
// title: '执行结果:' + addressDesc,
// icon: 'none'
// });
// },
// fail: function(msg) {
// uni.showToast({
// title: msg,
// icon: "none"
// })
// }
// })
},
testClearWatch() {
// clearWatch()
}
}
}
</script>
<style>
</style>
@@ -1,100 +0,0 @@
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1. 腾讯定位sdk需在腾讯地图官网申请key https://lbs.qq.com/
</view>
<view class="uni-hello-text">
2. 按照readme文档配置apikey
</view>
<view class="uni-hello-text">
3. 需要制作自定义基座运行
</view>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="checkLocationPermission">请求定位权限</button>
<button type="primary" @tap="testGetlocation">获取设备位置信息</button>
<button type="primary" @tap="testWatchPosition">监听设备位置信息</button>
<button type="primary" @tap="testClearWatch">停止监听</button>
</view>
</view>
</template>
<script>
import {
checkHasIntegration,
requestPremission,
getLocation,
watchPosition,
clearWatch
} from "@/uni_modules/uts-tencentgeolocation";
export default {
data() {
return {
title: '腾讯定位SDK集成示例',
}
},
methods: {
checkLocationPermission: function(e) {
requestPremission();
},
testGetlocation: function(e) {
let startRet = getLocation({
geocode: true,
success: function(response) {
console.log(response);
var addressDesc = response.name + '-' + response.address
uni.showToast({
title: '执行结果:' + addressDesc,
icon: 'none'
});
},
fail: function(msg) {
uni.showToast({
title: msg,
icon: "none"
})
}
})
if (!startRet) {
uni.showToast({
title: '定位启动失败,请检查配置',
icon: 'none'
});
}
},
testWatchPosition() {
watchPosition({
geocode: true,
success: function(response) {
console.log(response);
var addressDesc = response.name + '-' + response.address
uni.showToast({
title: '执行结果:' + addressDesc,
icon: 'none'
});
},
fail: function(msg) {
uni.showToast({
title: msg,
icon: "none"
})
}
})
},
testClearWatch() {
clearWatch()
}
}
}
</script>
<style>
</style>
@@ -1,47 +0,0 @@
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1.Android 平台需要自定义基座运行
</view>
</view>
<view class="uni-padding-wrap uni-common-mt">
<button @tap="testToastShow">调用 Toast 弹窗</button>
</view>
</view>
</template>
<script>
import { showToast } from '@/uni_modules/uts-toast'
export default {
data() {
return {
title:"Toast 示例"
}
},
methods:{
testToastShow(){
let ret = showToast();
if(!ret){
uni.showToast({
icon:'none',
title:'需要在自定义基座中运行'
})
}
}
}
}
</script>
<style>
</style>
@@ -1,47 +0,0 @@
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1.Android 平台需要自定义基座运行
</view>
</view>
<view class="uni-padding-wrap uni-common-mt">
<button @tap="testToastShow">调用 Toast 弹窗</button>
</view>
</view>
</template>
<script>
import { showToast } from '@/uni_modules/uts-toast'
export default {
data() {
return {
title:"Toast 示例"
}
},
methods:{
testToastShow(){
let ret = showToast();
if(!ret){
uni.showToast({
icon:'none',
title:'需要在自定义基座中运行'
})
}
}
}
}
</script>
<style>
</style>
@@ -1,63 +0,0 @@
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-btn-v uni-common-mt">
// #ifdef APP-ANDROID && UNI-APP-X
<button @tap="callKotlinMethodGetInfoTest">调用kotlin方法</button>
<button @tap="callJavaMethodGetInfoTest">调用java方法(需自定义基座)</button>
<view style="height: 10px;width: 100%;"></view>
<button @tap="kotlinMemListenTest">kotlin监听内存并持续回调UTS</button>
<button @tap="kotlinStopMemListenTest">停止监听</button>
<text>{{memInfo}}</text>
// #endif
</view>
</view>
</template>
<script>
// #ifdef APP-ANDROID && UNI-APP-X
import { callKotlinMethodGetInfo, callJavaMethodGetInfo,callKotlinCallbackUTS,callKotlinStopCallbackUTS} from "../../uni_modules/uts-syntaxcase";
// #endif
export default {
data() {
return {
title: 'UTS混编示例',
memInfo:''
}
},
methods: {
// #ifdef APP-ANDROID && UNI-APP-X
callKotlinMethodGetInfoTest: function () {
let phoneInfo = callKotlinMethodGetInfo();
uni.showToast({
title:phoneInfo
})
},
callJavaMethodGetInfoTest: function () {
let javaInfo = callJavaMethodGetInfo();
uni.showToast({
title:javaInfo
})
},
kotlinMemListenTest: function () {
callKotlinCallbackUTS(function(ret:string){
this.memInfo = ret
})
},
kotlinStopMemListenTest:function () {
callKotlinStopCallbackUTS()
},
// #endif
}
}
</script>
<style>
</style>
@@ -1,56 +0,0 @@
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-btn-v uni-common-mt">
<button @tap="callKotlinMethodGetInfoTest">调用kotlin方法</button>
<button @tap="callJavaMethodGetInfoTest">调用java方法(需自定义基座)</button>
<view style="height: 10px;width: 100%;"></view>
<button @tap="kotlinMemListenTest">kotlin监听内存并持续回调</button>
<button @tap="kotlinStopMemListenTest">停止监听</button>
<text>{{memInfo}}</text>
</view>
</view>
</template>
<script>
import { callKotlinMethodGetInfo, callJavaMethodGetInfo,callKotlinCallbackUTS,callKotlinStopCallbackUTS} from "../../uni_modules/uts-syntaxcase";
export default {
data() {
return {
title: 'UTS混编示例',
memInfo:''
}
},
methods: {
callKotlinMethodGetInfoTest: function () {
let phoneInfo = callKotlinMethodGetInfo();
uni.showToast({
title:phoneInfo
})
},
callJavaMethodGetInfoTest: function () {
let javaInfo = callJavaMethodGetInfo();
uni.showToast({
title:javaInfo
})
},
kotlinMemListenTest: function () {
callKotlinCallbackUTS((ret) =>{
this.memInfo = ret
})
},
kotlinStopMemListenTest:function () {
callKotlinStopCallbackUTS()
},
}
}
</script>
<style>
</style>
@@ -1,78 +0,0 @@
<template>
<div>
<button @click="doLogTest">打印测试</button>
<text>{{testRet}}</text>
</div>
</template>
<script>
import { getLog,logObjectTest,logClassTest,logFunctionTest,logFileTest,logDateTest,logUTSJSONObjectTest } from '../../uni_modules/uts-api-test'
export default {
data() {
return {
testRet:''
}
},
methods: {
doLogTest() {
if(getLog("") != '{"type":"string","value":""}'){
this.testRet = "测试失败1"
return;
}
if(getLog("字符串打印测试") != '{"type":"string","value":"字符串打印测试"}'){
this.testRet = "测试失败2"
return;
}
if(getLog(2023) != '{"subType":"number","type":"Int","value":"2023"}'){
this.testRet = "测试失败3"
return;
}
if(getLog(2023.002 as number) != '{"subType":"number","type":"Double","value":"2023.002"}'){
this.testRet = "测试失败4"
return;
}
if(logObjectTest() != '{"className":"uts.sdk.modules.utsApiTest.ParamOptions","subType":"object","__$originalPosition":"","type":"object","value":{"methods":[],"properties":[{"name":"array","subType":"array","className":"io.dcloud.uts.UTSArray","type":"object","value":{"properties":[{"name":{"value":{"value":0}},"type":"string","value":"1"},{"name":{"value":{"value":1}},"type":"string","value":"2"},{"name":{"value":{"value":2}},"type":"string","value":"3"}]}},{"name":"title","type":"string","value":"logObjectTest"}]}}'){
this.testRet = "测试失败5"
return;
}
if(logFunctionTest() != '{"parameter":[],"type":"function"}'){
this.testRet = "测试失败6"
return;
}
if(logClassTest() != '{"className":"uts.sdk.modules.utsApiTest.C","subType":"object","__$originalPosition":"","type":"object","value":{"methods":[],"properties":[{"name":"name","type":"string","value":"ccc"},{"parameter":["string"],"name":"sayBye","type":"function"}]}}'){
this.testRet = "测试失败7"
return;
}
/**
* uvue 和 vue 因为 java 版本不同,所以这里的打印格式可能存在差异
*/
if(logFileTest() != '{"className":"java.io.File","subType":"object","type":"object","value":{"methods":[],"properties":[]}}'){
this.testRet = "测试失败8"
return;
}
if(logDateTest() != '{"className":"io.dcloud.uts.Date","subType":"date","type":"object","value":"Sat Aug 08 1998 08:00:00 GMT+0800"}'){
this.testRet = "测试失败9"
return;
}
this.testRet = "测试完成"
}
}
}
</script>
<style>
</style>
@@ -1,78 +0,0 @@
<template>
<div>
<button @click="doLogTest">打印测试</button>
<text>{{testRet}}</text>
</div>
</template>
<script>
import { getLog,logObjectTest,logClassTest,logFunctionTest,logFileTest,logDateTest,logUTSJSONObjectTest } from '../../uni_modules/uts-api-test'
export default {
data() {
return {
testRet:''
}
},
methods: {
doLogTest() {
if(getLog("") != '{"type":"string","value":""}'){
this.testRet = "测试失败1"
return;
}
if(getLog("字符串打印测试") != '{"type":"string","value":"字符串打印测试"}'){
this.testRet = "测试失败2"
return;
}
if(getLog(2023) != '{"subType":"number","type":"Int","value":"2023"}'){
this.testRet = "测试失败3"
return;
}
// if(getLog(2023.002 as number) != '{"subType":"number","type":"Double","value":"2023.002"}'){
// this.testRet = "测试失败4"
// return;
// }
if(logObjectTest() != '{"className":"uts.sdk.modules.utsApiTest.ParamOptions","subType":"object","__$originalPosition":"","type":"object","value":{"methods":[],"properties":[{"name":"array","subType":"array","className":"io.dcloud.uts.UTSArray","type":"object","value":{"properties":[{"name":{"value":{"value":0}},"type":"string","value":"1"},{"name":{"value":{"value":1}},"type":"string","value":"2"},{"name":{"value":{"value":2}},"type":"string","value":"3"}]}},{"name":"title","type":"string","value":"logObjectTest"}]}}'){
this.testRet = "测试失败5"
return;
}
if(logFunctionTest() != '{"parameter":[],"type":"function"}'){
this.testRet = "测试失败6"
return;
}
if(logClassTest() != '{"className":"uts.sdk.modules.utsApiTest.C","subType":"object","__$originalPosition":"","type":"object","value":{"methods":[],"properties":[{"name":"name","type":"string","value":"ccc"},{"parameter":["string"],"name":"sayBye","type":"function"}]}}'){
this.testRet = "测试失败7"
return;
}
/**
* uvue 和 vue 因为 java 版本不同,所以这里的打印格式可能存在差异
*/
if(logFileTest() != '{"className":"java.io.File","subType":"object","type":"object","value":{"methods":[],"properties":[]}}'){
this.testRet = "测试失败8"
return;
}
if(logDateTest() != '{"className":"io.dcloud.uts.Date","subType":"date","type":"object","value":"Sat Aug 08 1998 08:00:00 GMT+0800"}'){
this.testRet = "测试失败9"
return;
}
this.testRet = "测试完成"
}
}
}
</script>
<style>
</style>
@@ -1,65 +0,0 @@
<template>
<view class="buttons">
<button @click="testClick">测试全部</button>
<text>{{testRet}}</text>
</view>
</template>
<script setup>
import {
Scan,
Scan1,
Scan2,
myClass
} from "@/uni_modules/uts-syntaxcase";
import { ref } from 'vue'
const myClassInit = new myClass();
let testRet = ref("1");
const testClick = function(){
testRet.value = "success"
// #ifdef APP-ANDROID
if(Scan() != 60000){
testRet = "error1"
console.log("error1")
}
if(Scan(100) != 100){
testRet = "error2"
console.log("error2")
}
// #endif
if(Scan1() != "null"){
testRet = "error3"
console.log("error3")
}
if(Scan1(100) != 100){
testRet = "error4"
console.log("error4")
}
if(Scan2() != "null"){
testRet = "error5"
console.log("error5")
}
if(Scan2(100) != 100){
testRet = "error6"
console.log("error6")
}
if(myClassInit.to('123') != "123"){
testRet = "error7"
console.log("error7")
}
}
</script>
<style lang="scss">
.buttons{
padding: 20rpx 20rpx 460rpx;
button{
margin-bottom: 20rpx;
font-size: 28rpx;
padding: 3px;
}
}
</style>
@@ -1,555 +0,0 @@
<template>
<scroll-view style="flex:1">
<view >
<button @click="testUtsSync">点击测试uts同步方法</button>
<view>测试return
{{ format(testUtsSyncResult) }}
</view>
<button @click="testUtsSyncWithCallback">
点击测试uts带callback的同步方法
</button>
<view>测试return{{ format(testUtsSyncWithCallbackResult['return']) }}</view>
<view>测试success{{ format(testUtsSyncWithCallbackResult['success']) }}</view>
<view>测试complete{{ format(testUtsSyncWithCallbackResult['complete']) }}</view>
<button @click="testUtsAsync">点击测试uts异步方法</button>
<view>测试return{{ format(testUtsAsyncResult['return']) }}</view>
<view>测试success{{ format(testUtsAsyncResult['success']) }}</view>
<view>测试complete{{ format(testUtsAsyncResult['complete']) }}</view>
<button @click="testUtsAsyncMulitParam">点击测试uts异步方法-多参数</button>
<view>测试return{{ format(testUtsAsyncMulitParamResult['return']) }}</view>
<view>测试success{{ format(testUtsAsyncMulitParamResult['success']) }}</view>
<view>测试complete{{ format(testUtsAsyncMulitParamResult['complete']) }}</view>
<button @click="testUtsClassConstructor">点击测试uts class构造函数</button>
<view>测试callback{{ format(testUtsClassConstructorResult['callback']) }}</view>
<button @click="testUtsClassStaticProp">点击测试uts class静态属性</button>
<view>测试value{{ format(testUtsClassStaticPropResult) }}</view>
<button @click="testUtsClassStaticSyncWithCallback">
点击测试uts class静态方法
</button>
<view>测试return{{ format(testUtsClassStaticSyncWithCallbackResult['return']) }}</view>
<view>测试success{{ format(testUtsClassStaticSyncWithCallbackResult['success']) }}</view>
<view>测试complete{{ format(testUtsClassStaticSyncWithCallbackResult['complete']) }}</view>
<button @click="testUtsClassStaticAsync">点击测试uts class静态异步方法</button>
<view>测试return{{ format(testUtsClassStaticAsyncResult['return']) }}</view>
<view>测试success{{ format(testUtsClassStaticAsyncResult['success']) }}</view>
<view>测试complete{{ format(testUtsClassStaticAsyncResult['complete']) }}</view>
<button @click="testUtsClassProp">点击测试uts class实例属性</button>
<view>测试value{{ format(testUtsClassPropResult) }}</view>
<button @click="testUtsClassSyncWithCallback">
点击测试uts class实例方法
</button>
<view>测试return{{ format(testUtsClassSyncWithCallbackResult['return']) }}</view>
<view>测试success{{ format(testUtsClassSyncWithCallbackResult['success']) }}</view>
<view>测试complete{{ format(testUtsClassSyncWithCallbackResult['complete']) }}</view>
<button @click="testUtsClassAsync">点击测试uts class实例异步方法</button>
<view>测试return{{ format(testUtsClassAsyncResult['return']) }}</view>
<view>测试success{{ format(testUtsClassAsyncResult['success']) }}</view>
<view>测试complete{{ format(testUtsClassAsyncResult['complete']) }}</view>
<button @click="testUtsClassInstance">点击测试uts方法返回类实例</button>
<view>测试prop{{ format(testUtsClassInstanceResult['prop']) }}</view>
<view>测试return{{ format(testUtsClassInstanceResult['return']) }}</view>
<view>测试success{{ format(testUtsClassInstanceResult['success']) }}</view>
<view>测试complete{{ format(testUtsClassInstanceResult['complete']) }}</view>
<view>测试callback{{ format(testUtsClassInstanceResult['callback']) }}</view>
<button @click="testUtsClassSetter">点击测试class 示例setter方法</button>
<view>测试setter{{ format(testUtsClassSetterResult) }}</view>
<view>测试promise返回值:{{ format(testUtsReturnPromiseResult) }}</view>
<button @click="testAll">点击测试所有</button>
<!-- #ifdef APP-IOS -->
<button @click="testPromiseStaticMethod">点击测试promise静态方法</button>
<button @click="testBigArrayBuffer">测试原生->JS ArrayBuffer内存共享</button>
<button @click="doTestBufferParam">测试JS->原生 ArrayBuffer内存共享</button>
<button @click="doTestNestedBufferParam">嵌套类型ArrayBuffer参数传递</button>
<button @click="doTestBufferReturnedValue">ArrayBuffer返回值</button>
<button @click="doTestNestedBufferReturnedValue">嵌套类型ArrayBuffer返回值</button>
<!-- #endif -->
</view>
<view style="height: 20px;"></view>
</scroll-view>
</template>
<script>
// #ifndef H5
import {
MAX,
testSync,
testSyncWithCallback,
testAsync,
AsyncOptions,
TestOptions,
SyncOptions,
testAsyncParam3,
Test,
request,
SetterTest,
PromiseReturnDemo,
} from "../../uni_modules/uts-syntaxcase";
// #endif
// #ifdef APP-IOS
import {
testPromiseStaticMethod,
testBigArrayBuffer,
testArrayBufferParam,
testMultyArrayBufferParam,
testMultyReturnBuffer,
testReturnedArrayBuffer
} from "@/uni_modules/uts-syntaxcase"
// #endif
let test:Test|null = null
let id = 0
export default {
data() {
return {
testUtsSyncResult: null,
testUtsSyncWithCallbackResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsAsyncResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsAsyncMulitParamResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsClassConstructorResult: {
callback: null
},
testUtsClassStaticPropResult: null,
testUtsClassStaticSyncWithCallbackResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsClassStaticAsyncResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsClassPropResult: null,
testUtsClassSyncWithCallbackResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsClassAsyncResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsClassInstanceResult: {
prop: null,
return: null,
success: null,
fail: null,
complete: null,
callback: null
},
testUtsClassSetterResult: null,
testUtsReturnPromiseResult: null,
}
},
methods: {
format(v:any|null):string {
if(v == null){
return '--'
}
if(v == true){
return "通过"
}
return "未通过"
},
testAll() {
this.testUtsSync();
this.testUtsSyncWithCallback();
this.testUtsAsync();
this.testUtsAsyncMulitParam()
this.testUtsClassConstructor();
this.testUtsClassStaticProp();
this.testUtsClassStaticSyncWithCallback();
this.testUtsClassStaticAsync();
this.testUtsClassProp();
this.testUtsClassSyncWithCallback();
this.testUtsClassAsync();
this.testUtsClassInstance();
this.testUtsClassSetter();
this.testUtsReturnPromise();
},
testUtsSync() {
this.testUtsSyncResult = false;
try {
if (testSync("dcloud").msg == "hello dcloud") {
this.testUtsSyncResult = true;
}
} catch (e) {
console.error("testUtsSync", e);
}
},
testUtsSyncWithCallback() {
try {
this.testUtsSyncWithCallbackResult['return'] = false;
this.testUtsSyncWithCallbackResult['success'] = false;
this.testUtsSyncWithCallbackResult['complete'] = false;
if (
testSyncWithCallback({
type: "success",
success: (res:any) => {
console.log("testSyncWithCallback.success.callback", res);
this.testUtsSyncWithCallbackResult['success'] = true;
},
fail: (res:any) => {
console.log("testSyncWithCallback.fail.callback", res);
// testUtsSyncWithCallbackResult.fail = true;
},
complete: (res:any) => {
console.log("testSyncWithCallback.complete.callback", res);
this.testUtsSyncWithCallbackResult['complete'] = true;
},
} as AsyncOptions)['name'] === "testSyncWithCallback"
) {
this.testUtsSyncWithCallbackResult['return'] = true;
}
} catch (e) {}
},
async testUtsAsync():Promise<void|null> {
this.testUtsAsyncResult['return'] = false;
this.testUtsAsyncResult['success'] = false;
// testUtsAsyncResult.fail = false;
this.testUtsAsyncResult['complete'] = false;
try {
const res = await testAsync({
type:"success",
success:(res:any) => {
console.log("testAsync.success.callback", res);
this.testUtsAsyncResult['success'] = true;
},
fail:(res:any) => {
console.log("testAsync.fail.callback", res);
},
complete:(res:any) => {
console.log("testAsync.complete.callback", res);
this.testUtsAsyncResult['complete'] = true;
},
} as AsyncOptions);
if (res.name === "testAsync") {
this.testUtsAsyncResult['return'] = true;
}
} catch (e) {}
return null
},
async testUtsAsyncMulitParam():Promise<void|null> {
this.testUtsAsyncMulitParamResult['return'] = false;
this.testUtsAsyncMulitParamResult['success'] = false;
this.testUtsAsyncMulitParamResult['complete'] = false;
try {
const res = await testAsyncParam3(100,"hello",{
type:"success",
success:(res) => {
console.log("testUtsAsyncMulitParam.success.callback", res);
this.testUtsAsyncMulitParamResult['success'] = true;
},
fail:(res) => {
console.log("testUtsAsyncMulitParam.fail.callback", res);
},
complete:(res) => {
console.log("testUtsAsyncMulitParam.complete.callback", res);
this.testUtsAsyncMulitParamResult['complete'] = true;
},
} as AsyncOptions);
if (res.name === "testUtsAsyncMulitParam") {
this.testUtsAsyncMulitParamResult['return'] = true;
}
} catch (e) {}
return null
},
testUtsClassConstructor() {
this.testUtsClassConstructorResult['callback'] = false
id++
test = new Test(id, {
name:'name' + id,
callback:(res) => {
console.log(res)
this.testUtsClassConstructorResult['callback'] = true
}
} as TestOptions)
},
testUtsClassStaticProp() {
this.testUtsClassStaticPropResult = false
if (Test.type === 'Test') {
this.testUtsClassStaticPropResult = true
}
},
testUtsClassStaticSyncWithCallback() {
try {
this.testUtsClassStaticSyncWithCallbackResult['return'] = false;
this.testUtsClassStaticSyncWithCallbackResult['success'] = false;
this.testUtsClassStaticSyncWithCallbackResult['complete'] = false;
if (
Test.testClassStaticSyncWithCallback({
type:"success",
success:(res) => {
console.log("testStaticSyncWithCallback.success.callback", res);
this.testUtsClassStaticSyncWithCallbackResult['success'] = true;
},
fail:(res) => {
console.log("testStaticSyncWithCallback.fail.callback", res);
},
complete:(res) => {
console.log("testStaticSyncWithCallback.complete.callback", res);
this.testUtsClassStaticSyncWithCallbackResult['complete'] = true;
},
} as AsyncOptions)['name'] === "testSyncWithCallback"
) {
this.testUtsClassStaticSyncWithCallbackResult['return'] = true;
}
} catch (e) {}
},
async testUtsClassStaticAsync():Promise<void|null> {
this.testUtsClassStaticAsyncResult['return'] = false;
this.testUtsClassStaticAsyncResult['success'] = false;
this.testUtsClassStaticAsyncResult['complete'] = false;
try {
const res = await Test.testClassStaticAsync({
type:"success",
success:(res:any) => {
console.log("testAsync.success.callback", res);
this.testUtsClassStaticAsyncResult['success'] = true;
},
fail:(res:any) => {
console.log("testAsync.fail.callback", res);
},
complete:(res:any) => {
console.log("testAsync.complete.callback", res);
this.testUtsClassStaticAsyncResult['complete'] = true;
},
} as AsyncOptions);
if (res.name === "testAsync") {
this.testUtsClassStaticAsyncResult['return'] = true;
}
} catch (e) {}
return null
},
testUtsClassProp() {
if (test == null) {
this.testUtsClassConstructor()
}
this.testUtsClassPropResult = false
if (test!.id > 0) {
this.testUtsClassPropResult = true
}
},
testUtsClassSyncWithCallback() {
if (test == null) {
this.testUtsClassConstructor()
}
try {
this.testUtsClassSyncWithCallbackResult['return'] = false;
this.testUtsClassSyncWithCallbackResult['success'] = false;
this.testUtsClassSyncWithCallbackResult['complete'] = false;
if (
test!.testClassSyncWithCallback({
type:"success",
success:(res) => {
console.log("testSyncWithCallback.success.callback", res);
this.testUtsClassSyncWithCallbackResult['success'] = true;
},
fail:(res) => {
console.log("testSyncWithCallback.fail.callback", res);
// testUtsClassSyncWithCallbackResult.fail = true;
},
complete:(res) => {
console.log("testSyncWithCallback.complete.callback", res);
this.testUtsClassSyncWithCallbackResult['complete'] = true;
}
} as AsyncOptions).name === "testSyncWithCallback"
) {
this.testUtsClassSyncWithCallbackResult['return'] = true;
}
} catch (e) {}
},
async testUtsClassAsync():Promise<void|null> {
if (test == null) {
this.testUtsClassConstructor()
}
this.testUtsClassAsyncResult['return'] = false;
this.testUtsClassAsyncResult['success'] = false;
this.testUtsClassAsyncResult['complete'] = false;
try {
const res = await test!.testClassAsync({
type:"success",
success:(res) => {
console.log("testAsync.success.callback", res);
this.testUtsClassAsyncResult['success'] = true;
},
fail:(res) => {
console.log("testAsync.fail.callback", res);
},
complete:(res) => {
console.log("testAsync.complete.callback", res);
this.testUtsClassAsyncResult['complete'] = true;
},
} as AsyncOptions);
if (res.name === "testAsync") {
this.testUtsClassAsyncResult['return'] = true;
}
} catch (e) {
console.error(e)
}
return null
},
testUtsClassInstance() {
this.testUtsClassInstanceResult['prop'] = false;
this.testUtsClassInstanceResult['return'] = false;
this.testUtsClassInstanceResult['success'] = false;
// testUtsClassAsyncResult.fail = false;
this.testUtsClassInstanceResult['complete'] = false;
this.testUtsClassInstanceResult['callback'] = false;
const url = 'https://dcloud.io/'
const task = request(url)
if (task!.url === url && task!.abort().url === url) {
this.testUtsClassInstanceResult['prop'] = true;
}
task!.onCallback((res) => {
if (res === 'onCallback') {
this.testUtsClassInstanceResult['callback'] = true;
}
})
const res = task!.sync({
success:(res) => {
console.log("task.sync.success.callback", res);
this.testUtsClassInstanceResult['success'] = true;
},
fail:(res) => {
console.log("task.sync.fail.callback", res);
},
complete:(res) => {
console.log("task.sync.complete.callback", res);
this.testUtsClassInstanceResult['complete'] = true;
}} as SyncOptions)
if (res === 'sync') {
this.testUtsClassInstanceResult['return'] = true;
}
},
testUtsClassSetter() {
this.testUtsClassSetterResult = false;
try {
let obj = new SetterTest()
obj.nickName = "Tom";
if (obj.nickName == "Tom") {
this.testUtsClassSetterResult = true;
}
} catch (e) {
console.error("testUtsClassSetter", e);
}
},
testUtsReturnPromise() {
this.testUtsReturnPromiseResult = false;
try {
let demo = new PromiseReturnDemo();
demo.test1();
demo.test2();
if (demo.recordRet == 2) {
this.testUtsReturnPromiseResult = true;
}
} catch (e) {
console.error("testUtsClassSetter", e);
}
},
// #ifdef APP-IOS
testPromiseStaticMethod() {
testPromiseStaticMethod()
},
testBigArrayBuffer() {
testBigArrayBuffer({
url: "/static/test.txt",
success: (res) => {
console.log("读取成功")
console.log("ArrayBuffer 长度:",res.byteLength)
},
fail: (code) => {
console.log(code)
}
})
},
doTestBufferParam() {
let buffer = new ArrayBuffer(16)
let dataView = new DataView(buffer)
dataView.setInt16(1, 42)
testArrayBufferParam(buffer)
},
doTestNestedBufferParam() {
let buffer = new ArrayBuffer(16)
let dataView = new DataView(buffer)
dataView.setInt16(1, 42)
testMultyArrayBufferParam({
a: "1234",
b: true,
c: buffer
})
},
doTestBufferReturnedValue() {
let buffer = testReturnedArrayBuffer()
let dataView = new DataView(buffer)
console.log(dataView.getInt16(0))
console.log(dataView.getInt16(1))
console.log(dataView.getInt16(2))
console.log(dataView.getInt16(3))
console.log(dataView.getInt16(4))
console.log(dataView.getInt16(5))
console.log(dataView.getInt16(6))
console.log(dataView.getInt16(7))
console.log(dataView.getInt16(8))
console.log(dataView.getInt16(9))
console.log(dataView.getInt16(10))
console.log(dataView.getInt16(11))
console.log(dataView.getInt16(12))
console.log(dataView.getInt16(13))
console.log(dataView.getInt16(14))
console.log(new Uint8Array(buffer))
console.log(new Uint8ClampedArray(buffer))
console.log(new Uint16Array(buffer))
console.log(new Uint32Array(buffer))
console.log(new BigUint64Array(buffer))
console.log(new Float32Array(buffer))
console.log(new Float64Array(buffer))
console.log(new Int8Array(buffer))
console.log(new Int16Array(buffer))
console.log(new Int32Array(buffer))
console.log(new BigInt64Array(buffer))
},
doTestNestedBufferReturnedValue() {
let ret = testMultyReturnBuffer()
console.log(ret.a)
let dataView = new DataView(ret.b, 0, 16)
console.log(dataView.getInt16(1))
}
// #endif
}
}
</script>
-446
View File
@@ -1,446 +0,0 @@
<template>
<view>
<button @click="testUtsSync">点击测试uts同步方法</button>
<view>测试return
{{ format(testUtsSyncResult) }}
</view>
<button @click="testUtsSyncWithCallback">
点击测试uts带callback的同步方法
</button>
<view>测试return{{ format(testUtsSyncWithCallbackResult.return) }}</view>
<view>测试success{{ format(testUtsSyncWithCallbackResult.success) }}</view>
<view>测试complete{{ format(testUtsSyncWithCallbackResult.complete) }}</view>
<button @click="testUtsAsync">点击测试uts异步方法</button>
<view>测试return{{ format(testUtsAsyncResult.return) }}</view>
<view>测试success{{ format(testUtsAsyncResult.success) }}</view>
<view>测试complete{{ format(testUtsAsyncResult.complete) }}</view>
<button @click="testUtsAsyncMulitParam">点击测试uts异步方法-多参数</button>
<view>测试return{{ format(testUtsAsyncMulitParamResult.return) }}</view>
<view>测试success{{ format(testUtsAsyncMulitParamResult.success) }}</view>
<view>测试complete{{ format(testUtsAsyncMulitParamResult.complete) }}</view>
<button @click="testUtsClassConstructor">点击测试uts class构造函数</button>
<view>测试callback{{ format(testUtsClassConstructorResult.callback) }}</view>
<button @click="testUtsClassStaticProp">点击测试uts class静态属性</button>
<view>测试value{{ format(testUtsClassStaticPropResult) }}</view>
<button @click="testUtsClassStaticSyncWithCallback">
点击测试uts class静态方法
</button>
<view>测试return{{ format(testUtsClassStaticSyncWithCallbackResult.return) }}</view>
<view>测试success{{ format(testUtsClassStaticSyncWithCallbackResult.success) }}</view>
<view>测试complete{{ format(testUtsClassStaticSyncWithCallbackResult.complete) }}</view>
<button @click="testUtsClassStaticAsync">点击测试uts class静态异步方法</button>
<view>测试return{{ format(testUtsClassStaticAsyncResult.return) }}</view>
<view>测试success{{ format(testUtsClassStaticAsyncResult.success) }}</view>
<view>测试complete{{ format(testUtsClassStaticAsyncResult.complete) }}</view>
<button @click="testUtsClassProp">点击测试uts class实例属性</button>
<view>测试value{{ format(testUtsClassPropResult) }}</view>
<button @click="testUtsClassSyncWithCallback">
点击测试uts class实例方法
</button>
<view>测试return{{ format(testUtsClassSyncWithCallbackResult.return) }}</view>
<view>测试success{{ format(testUtsClassSyncWithCallbackResult.success) }}</view>
<view>测试complete{{ format(testUtsClassSyncWithCallbackResult.complete) }}</view>
<button @click="testUtsClassAsync">点击测试uts class实例异步方法</button>
<view>测试return{{ format(testUtsClassAsyncResult.return) }}</view>
<view>测试success{{ format(testUtsClassAsyncResult.success) }}</view>
<view>测试complete{{ format(testUtsClassAsyncResult.complete) }}</view>
<button @click="testUtsClassInstance">点击测试uts方法返回类实例</button>
<view>测试prop{{ format(testUtsClassInstanceResult.prop) }}</view>
<view>测试return{{ format(testUtsClassInstanceResult.return) }}</view>
<view>测试success{{ format(testUtsClassInstanceResult.success) }}</view>
<view>测试complete{{ format(testUtsClassInstanceResult.complete) }}</view>
<view>测试callback{{ format(testUtsClassInstanceResult.callback) }}</view>
<button @click="testUtsClassSetter">点击测试class 示例setter方法</button>
<view>测试setter{{ format(testUtsClassSetterResult) }}</view>
<view>测试promise返回值{{ format(testUtsReturnPromiseResult) }}</view>
<button @click="testAll">点击测试所有</button>
</view>
</template>
<script>
// #ifndef H5
import {
MAX,
testSync,
testSyncWithCallback,
testAsync,
testAsyncParam3,
Test,
request,
SetterTest,
PromiseReturnDemo,
} from "../../uni_modules/uts-syntaxcase";
// #endif
let test
let id = 0
export default {
data() {
return {
testUtsSyncResult: null,
testUtsSyncWithCallbackResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsAsyncResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsAsyncMulitParamResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsClassConstructorResult: {
callback: null
},
testUtsClassStaticPropResult: null,
testUtsClassStaticSyncWithCallbackResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsClassStaticAsyncResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsClassPropResult: null,
testUtsClassSyncWithCallbackResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsClassAsyncResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsClassInstanceResult: {
prop: null,
return: null,
success: null,
fail: null,
complete: null,
callback: null
},
testUtsClassSetterResult: null,
testUtsReturnPromiseResult: null,
}
},
methods: {
format(v) {
return v == null ? "--" : v ? "通过" : "未通过";
},
testAll() {
this.testUtsSync();
this.testUtsSyncWithCallback();
this.testUtsAsync();
this.testUtsAsyncMulitParam()
this.testUtsClassConstructor();
this.testUtsClassStaticProp();
this.testUtsClassStaticSyncWithCallback();
this.testUtsClassStaticAsync();
this.testUtsClassProp();
this.testUtsClassSyncWithCallback();
this.testUtsClassAsync();
this.testUtsClassInstance();
this.testUtsClassSetter();
this.testUtsReturnPromise();
},
testUtsSync() {
this.testUtsSyncResult = false;
try {
if (testSync("dcloud").msg === "hello dcloud") {
this.testUtsSyncResult = true;
}
} catch (e) {
console.error("testUtsSync", e);
}
},
testUtsSyncWithCallback() {
try {
this.testUtsSyncWithCallbackResult.return = false;
this.testUtsSyncWithCallbackResult.success = false;
// testUtsSyncWithCallbackResult.fail = false;
this.testUtsSyncWithCallbackResult.complete = false;
if (
testSyncWithCallback({
type: "success",
success: (res) => {
console.log("testSyncWithCallback.success.callback", res);
this.testUtsSyncWithCallbackResult.success = true;
},
fail: (res) => {
console.log("testSyncWithCallback.fail.callback", res);
// testUtsSyncWithCallbackResult.fail = true;
},
complete: (res) => {
console.log("testSyncWithCallback.complete.callback", res);
this.testUtsSyncWithCallbackResult.complete = true;
},
}).name === "testSyncWithCallback"
) {
this.testUtsSyncWithCallbackResult.return = true;
}
} catch (e) {}
},
async testUtsAsync() {
this.testUtsAsyncResult.return = false;
this.testUtsAsyncResult.success = false;
// testUtsAsyncResult.fail = false;
this.testUtsAsyncResult.complete = false;
try {
const res = await testAsync({
type: "success",
success: (res) => {
console.log("testAsync.success.callback", res);
this.testUtsAsyncResult.success = true;
},
fail: (res) => {
console.log("testAsync.fail.callback", res);
},
complete: (res) => {
console.log("testAsync.complete.callback", res);
this.testUtsAsyncResult.complete = true;
},
});
if (res.name === "testAsync") {
this.testUtsAsyncResult.return = true;
}
} catch (e) {}
},
async testUtsAsyncMulitParam() {
this.testUtsAsyncMulitParamResult.return = false;
this.testUtsAsyncMulitParamResult.success = false;
// testUtsAsyncResult.fail = false;
this.testUtsAsyncMulitParamResult.complete = false;
try {
const res = await testAsyncParam3(100,"hello",{
type: "success",
success: (res) => {
console.log("testUtsAsyncMulitParam.success.callback", res);
this.testUtsAsyncMulitParamResult.success = true;
},
fail: (res) => {
console.log("testUtsAsyncMulitParam.fail.callback", res);
},
complete: (res) => {
console.log("testUtsAsyncMulitParam.complete.callback", res);
this.testUtsAsyncMulitParamResult.complete = true;
},
});
if (res.name === "testUtsAsyncMulitParam") {
this.testUtsAsyncMulitParamResult.return = true;
}
} catch (e) {}
},
testUtsClassConstructor() {
this.testUtsClassConstructorResult.callback = false
id++
test = new Test(id, {
name: 'name' + id,
callback: (res) => {
console.log(res)
this.testUtsClassConstructorResult.callback = true
}
})
},
testUtsClassStaticProp() {
this.testUtsClassStaticPropResult = false
if (Test.type === 'Test') {
this.testUtsClassStaticPropResult = true
}
},
testUtsClassStaticSyncWithCallback() {
try {
this.testUtsClassStaticSyncWithCallbackResult.return = false;
this.testUtsClassStaticSyncWithCallbackResult.success = false;
// testUtsClassStaticSyncWithCallbackResult.fail = false;
this.testUtsClassStaticSyncWithCallbackResult.complete = false;
if (
Test.testClassStaticSyncWithCallback({
type: "success",
success: (res) => {
console.log("testStaticSyncWithCallback.success.callback", res);
this.testUtsClassStaticSyncWithCallbackResult.success = true;
},
fail: (res) => {
console.log("testStaticSyncWithCallback.fail.callback", res);
// testUtsClassStaticSyncWithCallbackResult.fail = true;
},
complete: (res) => {
console.log("testStaticSyncWithCallback.complete.callback", res);
this.testUtsClassStaticSyncWithCallbackResult.complete = true;
},
}).name === "testSyncWithCallback"
) {
this.testUtsClassStaticSyncWithCallbackResult.return = true;
}
} catch (e) {}
},
async testUtsClassStaticAsync() {
this.testUtsClassStaticAsyncResult.return = false;
this.testUtsClassStaticAsyncResult.success = false;
// testUtsClassStaticAsyncResult.fail = false;
this.testUtsClassStaticAsyncResult.complete = false;
try {
const res = await Test.testClassStaticAsync({
type: "success",
success: (res) => {
console.log("testAsync.success.callback", res);
this.testUtsClassStaticAsyncResult.success = true;
},
fail: (res) => {
console.log("testAsync.fail.callback", res);
},
complete: (res) => {
console.log("testAsync.complete.callback", res);
this.testUtsClassStaticAsyncResult.complete = true;
},
});
if (res.name === "testAsync") {
this.testUtsClassStaticAsyncResult.return = true;
}
} catch (e) {}
},
testUtsClassProp() {
if (!test) {
this.testUtsClassConstructor()
}
this.testUtsClassPropResult = false
if (test.id > 0) {
this.testUtsClassPropResult = true
}
},
testUtsClassSyncWithCallback() {
if (!test) {
this.testUtsClassConstructor()
}
try {
this.testUtsClassSyncWithCallbackResult.return = false;
this.testUtsClassSyncWithCallbackResult.success = false;
// testUtsClassSyncWithCallbackResult.fail = false;
this.testUtsClassSyncWithCallbackResult.complete = false;
if (
test.testClassSyncWithCallback({
type: "success",
success: (res) => {
console.log("testSyncWithCallback.success.callback", res);
this.testUtsClassSyncWithCallbackResult.success = true;
},
fail: (res) => {
console.log("testSyncWithCallback.fail.callback", res);
// testUtsClassSyncWithCallbackResult.fail = true;
},
complete: (res) => {
console.log("testSyncWithCallback.complete.callback", res);
this.testUtsClassSyncWithCallbackResult.complete = true;
},
}).name === "testSyncWithCallback"
) {
this.testUtsClassSyncWithCallbackResult.return = true;
}
} catch (e) {}
},
async testUtsClassAsync() {
if (!test) {
this.testUtsClassConstructor()
}
this.testUtsClassAsyncResult.return = false;
this.testUtsClassAsyncResult.success = false;
// testUtsClassAsyncResult.fail = false;
this.testUtsClassAsyncResult.complete = false;
try {
const res = await test.testClassAsync({
type: "success",
success: (res) => {
console.log("testAsync.success.callback", res);
this.testUtsClassAsyncResult.success = true;
},
fail: (res) => {
console.log("testAsync.fail.callback", res);
},
complete: (res) => {
console.log("testAsync.complete.callback", res);
this.testUtsClassAsyncResult.complete = true;
},
});
console.log('res', res)
if (res.name === "testAsync") {
this.testUtsClassAsyncResult.return = true;
}
} catch (e) {
console.error(e)
}
},
testUtsClassInstance() {
this.testUtsClassInstanceResult.prop = false;
this.testUtsClassInstanceResult.return = false;
this.testUtsClassInstanceResult.success = false;
// testUtsClassAsyncResult.fail = false;
this.testUtsClassInstanceResult.complete = false;
this.testUtsClassInstanceResult.callback = false;
const url = 'https://dcloud.io/'
const task = request(url)
if (task.url === url && task.abort().url === url) {
this.testUtsClassInstanceResult.prop = true;
}
task.onCallback((res) => {
if (res === 'onCallback') {
this.testUtsClassInstanceResult.callback = true;
}
})
const res = task.sync({
success: (res) => {
console.log("task.sync.success.callback", res);
this.testUtsClassInstanceResult.success = true;
},
fail: (res) => {
console.log("task.sync.fail.callback", res);
},
complete: (res) => {
console.log("task.sync.complete.callback", res);
this.testUtsClassInstanceResult.complete = true;
},
})
if (res === 'sync') {
this.testUtsClassInstanceResult.return = true;
}
},
testUtsClassSetter() {
this.testUtsClassSetterResult = false;
try {
let obj = new SetterTest()
obj.nickName = "Tom";
if (obj.nickName == "Tom") {
this.testUtsClassSetterResult = true;
}
} catch (e) {
console.error("testUtsClassSetter", e);
}
},
testUtsReturnPromise() {
this.testUtsReturnPromiseResult = false;
try {
let demo = new PromiseReturnDemo();
demo.test1();
demo.test2();
if (demo.recordRet == 2) {
this.testUtsReturnPromiseResult = true;
}
} catch (e) {
console.error("testUtsClassSetter", e);
}
},
}
}
</script>
@@ -1,48 +0,0 @@
<template>
{{ret}}
<button @click="instanceCreate">多实例创建测试</button>
</template>
<script>
import {
User
} from '@/uni_modules/uts-advance'
export default {
data() {
return {
ret:'',
// 将uts的class实例放进data里,测试响应式包装后是否有问题
user1: new User("张三", 20)
}
},
methods: {
instanceCreate() {
const user2 = new User("李四", 30);
const user3 = new User("王五", 40);
let userText1 = this.user1.describeSelf()
let userText2 = user2.describeSelf()
let userText3 = user3.describeSelf()
if(userText1 == userText2 || userText1 == userText3 || userText2 == userText3){
this.ret = '测试未通过'
}else{
this.ret = '测试通过'
}
}
}
}
</script>
<style>
</style>
@@ -1,84 +0,0 @@
<template>
<div>
{{ret}}
<button @click="instanceCreate">多实例创建测试</button>
<button @click="defaultValueTest">默认值测试</button>
</div>
</template>
<script>
import {
User
} from '@/uni_modules/uts-advance'
import {
Scan,
Scan1,
Scan2,
myClass
} from "@/uni_modules/uts-syntaxcase";
export default {
data() {
return {
ret:'',
// 将uts的class实例放进data里,测试响应式包装后是否有问题
user1: new User("张三", 20)
}
},
methods: {
defaultValueTest() {
const myClassInit = new myClass();
// 默认值测试
if(Scan() != 60000){
this.ret = "测试失败1"
}
if(Scan(100) != 100){
this.ret = "测试失败2"
}
if(Scan1() != null){
this.ret = "测试失败3"
}
if(Scan1(100) != 100){
this.ret = "测试失败4"
}
let ret5 = Scan2()
if(ret5 != "null"){
console.log(ret5)
this.ret = "测试失败5"
}
if(Scan2(100) != 100){
this.ret = "测试失败6"
}
if(myClassInit.to('123') != 123){
this.ret = "测试失败7"
}
},
instanceCreate() {
const user2 = new User("李四", 30);
const user3 = new User("王五", 40);
let userText1 = this.user1.describeSelf()
let userText2 = user2.describeSelf()
let userText3 = user3.describeSelf()
if(userText1 == userText2 || userText1 == userText3 || userText2 == userText3){
this.ret = '测试未通过'
}else{
this.ret = '测试通过'
}
}
}
}
</script>
<style>
</style>
@@ -1,39 +0,0 @@
<template>
<div>
<text>宽:{{width}},高:{{height}}</text>
<button @tap="getSystemInfoClick">getSystemInfo测试</button>
</div>
</template>
<script>
export default {
data:{
width:"",
height:""
},
onLoad() {
console.log("onload")
},
methods:{
getSystemInfoClick:function(){
console.log("getSystemInfoClick")
try {
let systemInfo = uni.getSystemInfoSync()
this.height = systemInfo.screenHeight
this.width = systemInfo.screenWidth
console.log("globalScreenHeight",this.height,"globalScreenWidth",this.width)
} catch (e) {
// 兼容本地测试
console.error(e)
}
}
}
}
</script>
<style>
</style>
@@ -1,22 +0,0 @@
<template>
<view>
<text>暂不支持</text>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>
@@ -1,92 +0,0 @@
<template>
<button @click="inputArrayTest">传入数组参数</button>
<button @click="inputParamTest">传入复杂对象参数</button>
<button @click="returnArrayTest">返回数组参数</button>
<button @click="returnParamTest">返回复杂对象参数</button>
<button @click="callbackArrayTest">异步返回数组</button>
<button @click="callbackParamTest">异步返回复杂对象</button>
</template>
<script>
import {
inputArray,
inputParam,
returnArray,
returnParam,
callbackArray,
callbackParam,
ParamOptions
} from '@/uni_modules/uts-advance'
export default {
data() {
return {}
},
methods: {
inputArrayTest() {
let ret = inputArray(['a', 'b', 'c'])
if (ret) {
uni.showToast({
title: '测试通过'
})
}
},
inputParamTest() {
let ret = inputParam({
title: "hello",
array: ["1", "2", "3"]
} as ParamOptions)
if (ret) {
uni.showToast({
title: '测试通过'
})
}
},
returnArrayTest() {
let ret = returnArray()
if ('["1","2","3"]' == JSON.stringify(ret)) {
uni.showToast({
title: '测试通过'
})
}
},
returnParamTest() {
let ret = returnParam()
if ('{"title":"returnParam","array":["1","2","3"]}' == JSON.stringify(ret)) {
uni.showToast({
title: '测试通过'
})
}
},
callbackArrayTest() {
callbackArray(function(res) {
if ('["8","8","8"]' == JSON.stringify(res)) {
uni.showToast({
title: '测试通过'
})
}
});
},
callbackParamTest() {
callbackParam(function(res) {
if ('{"title":"callbackParam","array":["4","5","6"]}' == JSON.stringify(res)) {
uni.showToast({
title: '测试通过'
})
}
});
}
}
}
</script>
<style>
</style>
@@ -1,108 +0,0 @@
<template>
<div>
<button @click="inputArrayTest">传入数组参数</button>
<button @click="inputParamTest">传入复杂对象参数</button>
<button @click="returnArrayTest">返回数组参数</button>
<button @click="returnParamTest">返回复杂对象参数</button>
<button @click="callbackArrayTest">异步返回数组</button>
<button @click="callbackParamTest">异步返回复杂对象</button>
<button @click="callbackDefaultParamTest">默认值测试</button>
</div>
</template>
<script>
import {
inputArray,
inputParam,
returnArray,
returnParam,
callbackArray,
callbackParam,
DefaultParamTest,
defaultParamFunc
} from '@/uni_modules/uts-advance'
export default {
data() {
return {}
},
methods: {
inputArrayTest() {
let ret = inputArray(['a', 'b', 'c'])
if (ret) {
uni.showToast({
title: '测试通过'
})
}
},
inputParamTest() {
let ret = inputParam({
title: "hello",
array: ["1", "2", "3"]
})
if (ret) {
uni.showToast({
title: '测试通过'
})
}
},
returnArrayTest() {
let ret = returnArray()
console.log( JSON.stringify(ret))
if ('["1","2","3"]' == JSON.stringify(ret)) {
uni.showToast({
title: '测试通过'
})
}
},
returnParamTest() {
let ret = returnParam()
if ('{"title":"returnParam","array":["1","2","3"]}' == JSON.stringify(ret)) {
uni.showToast({
title: '测试通过'
})
}
},
callbackArrayTest() {
callbackArray(function(res) {
if ('["8","8","8"]' == JSON.stringify(res)) {
uni.showToast({
title: '测试通过'
})
}
});
},
callbackDefaultParamTest(){
if(defaultParamFunc() == "789" && DefaultParamTest.execute() == "123" && new DefaultParamTest().execute2() == "456"){
uni.showToast({
title:'测试通过'
})
}else{
uni.showToast({
title:'测试失败'
})
}
},
callbackParamTest() {
callbackParam(function(res) {
if ('{"title":"callbackParam","array":["4","5","6"]}' == JSON.stringify(res)) {
uni.showToast({
title: '测试通过'
})
}
});
}
}
}
</script>
<style>
</style>
@@ -1,313 +0,0 @@
<template>
<!-- #ifdef APP-ANDROID -->
<scroll-view style="flex: 1">
<view>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text"> 逐一点击执行,观察测试反馈 </view>
</view>
<button @click="getAppContextClick">getAppContext</button>
<button @click="getUniActivityClick">getUniActivity</button>
<button @click="getJavaClassClick">getJavaClass</button>
<button @click="getAppTempPathClick">getAppTempPath</button>
<button @click="typeofClick">typeof</button>
<button @click="arrayPermissionFlowClick">组权限申请流程测试</button>
<button @click="singlePermissionFlowClick">单权限申请流程测试</button>
<button @click="dispatchAsyncClick">任务分发测试</button>
<button @click="pathTestClick">路径转换测试</button>
<button @click="privacyStateClick">隐私协议状态测试</button>
<button @click="privacyStateCallBackClick">隐私协议回调测试</button>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1. 当前页面已通过initAppLifecycle函数注册了生命周期监听。
</view>
<view class="uni-hello-text">
2. 手动切换其他APP再返回,可在控制台和界面观察事件日志
</view>
</view>
<view class="uni-padding-wrap uni-common-mt">
<view class="text-box" scroll-y="true">
<text>{{ text }}</text>
</view>
</view>
<button @click="gotoSystemPermissionActivityClick">
手动申请权限测试
</button>
<button @tap="testGoOtherActivity">跳转拍照界面</button>
<button @tap="testUnRegLifecycle">取消注册周期函数</button>
<image :src="selectImage" v-if="selectImage"></image>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text"> 获取设备信息,观察是否符合预期 </view>
</view>
<button @tap="getDeviceInfoClick">获取设备基础信息</button>
<button @tap="getFileProviderUriClick">使用外部应用访问私有文件</button>
</view>
</scroll-view>
<!-- #endif -->
</template>
<script>
// #ifdef APP-ANDROID
import {
getAppContextTest,
getUniActivityTest,
getJavaClassTest,
getAppTempPathTest,
typeofClickTest,
gotoSystemPermissionActivityTest,
arrayPermissionFlowTest,
singlePermissionFlowTest,
dispatchAsyncTest,
convert2AbsFullPathTest,
unRegLifecycle,
initAppLifecycle,
gotoCameraTake,
getDeviceInfoTest,
privacyStateTest
} from '@/uni_modules/uts-platform-api'
// #endif
// #ifdef APP-ANDROID
import {
UTSAcvitiyLifeCycleCallback,
UTSAcvitiyKeyEventCallback,
UTSActivityWindowCallback,
UTSActivityCallback,
UTSActivityComponentCallback,
onCallbackChange
} from '@/uni_modules/uts-syntaxcase'
import File from 'java.io.File';
import Intent from 'android.content.Intent';
// #endif
/**
* 测试在页面生命周期之外,使用api
*/
export default {
data() {
return {
text: '',
selectImage: '',
}
},
unmounted() {
},
onLoad: function () {
// #ifdef APP-ANDROID
let that = this
initAppLifecycle(function (eventLog) {
// 展示捕捉到的声明周期日志
let nextLine = that.text + eventLog
that.text = nextLine
let nextLineFlag = that.text + '\n'
that.text = nextLineFlag
})
// #endif
},
methods: {
// #ifdef APP-ANDROID
privacyStateClick() {
privacyStateTest(function (ret, desc) {
if (ret) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc,
})
}
})
},
privacyStateCallBackClick() {
let isAgree : boolean = true
const cb = (ret : PrivacyOption) => {
console.log('privacyStateCallBackTest->' + ret.isAgree)
if (ret.isAgree == isAgree) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败'
})
}
}
// 先重置用户同意状态
UTSAndroid.onPrivacyAgreeChange(cb)
UTSAndroid.setPrivacyAgree(isAgree)
UTSAndroid.offPrivacyAgreeChange(cb)
setTimeout(function () {
console.log('privacyStateCallBackTest->false')
UTSAndroid.setPrivacyAgree(false)
}, 5000);
},
getDeviceInfoClick() {
this.text = getDeviceInfoTest()
},
testGoOtherActivity() {
var that = this
let ret = gotoCameraTake(function (file) {
// 展示捕捉到的声明周期日志
console.log(file)
that.selectImage = 'file://' + file
})
if (!ret) {
uni.showToast({
icon: 'none',
title: '测试失败',
})
}
},
testUnRegLifecycle() {
// 取消注册生命周期
unRegLifecycle()
},
getJavaClassClick() {
if (getJavaClassTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败'
})
}
},
getAppContextClick() {
if (getAppContextTest()) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败',
})
}
},
getUniActivityClick() {
if (getUniActivityTest()) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败',
})
}
},
pathTestClick() {
if (convert2AbsFullPathTest()) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败',
})
}
},
getFileProviderUriClick() {
let file = new File(UTSAndroid.getResourcePath("static/logo.png"))
const uri = UTSAndroid.getFileProviderUri(file)
console.log("uri", uri.toString())
const intent = new Intent(Intent.ACTION_VIEW, uri)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) // 添加权限标志
const context = UTSAndroid.getUniActivity()!;
context.startActivity(intent);
},
getAppTempPathClick() {
if (getAppTempPathTest()) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败',
})
}
},
dispatchAsyncClick() {
dispatchAsyncTest(function (ret, desc) {
if (ret) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc,
})
}
})
},
typeofClick() {
if (typeofClickTest()) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败',
})
}
},
gotoSystemPermissionActivityClick() {
gotoSystemPermissionActivityTest()
},
arrayPermissionFlowClick() {
arrayPermissionFlowTest(function (ret, desc) {
if (ret) {
uni.showToast({
icon: 'none',
title: '测试通过',
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc,
})
}
})
},
singlePermissionFlowClick() {
singlePermissionFlowTest(function (ret, desc) {
if (ret) {
uni.showToast({
icon: 'none',
title: '测试通过',
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc,
})
}
})
},
// #endif
},
}
</script>
<style>
.testButton {
width: 100%;
}
</style>
@@ -1,267 +0,0 @@
<template>
<view>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
逐一点击执行观察测试反馈
</view>
</view>
<button @click="getAppContextClick">getAppContext</button>
<button @click="getUniActivityClick">getUniActivity</button>
<button @click="getJavaClassClick">getJavaClass</button>
<button @click="getAppTempPathClick">getAppTempPath</button>
<button @click="typeofClick">typeof</button>
<button @click="arrayPermissionFlowClick">组权限申请流程测试</button>
<button @click="singlePermissionFlowClick">单权限申请流程测试</button>
<button @click="dispatchAsyncClick">任务分发测试</button>
<button @click="pathTestClick">路径转换测试</button>
<button @click="privacyStateClick">隐私协议状态测试</button>
<button @click="privacyStateCallBackClick">隐私协议回调测试</button>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1. 当前页面已通过initAppLifecycle函数注册了生命周期监听
</view>
<view class="uni-hello-text">
2. 手动切换其他APP再返回可在控制台和界面观察事件日志
</view>
</view>
<view class="uni-padding-wrap uni-common-mt">
<view class="text-box" scroll-y="true">
<text>{{text}}</text>
</view>
</view>
<button @click="gotoSystemPermissionActivityClick">手动申请权限测试</button>
<button @tap="testGoOtherActivity">跳转拍照界面</button>
<button @tap="testUnRegLifecycle">取消注册周期函数</button>
<image :src="selectImage" v-if="selectImage"></image>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
获取设备信息观察是否符合预期
</view>
</view>
<button @tap="getDeviceInfoClick">获取设备基础信息</button>
</view>
</template>
<script>
import {
getAppContextTest,
getUniActivityTest,
getJavaClassTest,
getAppTempPathTest,
typeofClickTest,
gotoSystemPermissionActivityTest,
arrayPermissionFlowTest,
singlePermissionFlowTest,
dispatchAsyncTest,
convert2AbsFullPathTest,
unRegLifecycle,
initAppLifecycle,
gotoCameraTake,
getDeviceInfoTest,
privacyStateTest,
privacyStateCallBackTest
} from '@/uni_modules/uts-platform-api'
/**
* 测试在页面生命周期之外,使用api
*/
export default {
data() {
return {
text: '',
selectImage:''
}
},
onLoad:function(){
let that = this;
initAppLifecycle(function(eventLog){
// 展示捕捉到的声明周期日志
that.text = that.text += eventLog;
that.text = that.text += '\n';
});
},
methods: {
privacyStateClick(){
privacyStateTest(function(ret,desc){
if (ret) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc
})
}
})
},
privacyStateCallBackClick() {
privacyStateCallBackTest(function(ret, desc) {
if (ret) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc
})
}
})
},
getDeviceInfoClick(){
this.text = getDeviceInfoTest()
},
testGoOtherActivity(){
var that = this;
let ret = gotoCameraTake(function(file){
// 展示捕捉到的声明周期日志
console.log(file);
that.selectImage = "file://" + file;
});
if(!ret){
uni.showToast({
icon:'none',
title:'测试失败'
})
}
},
testUnRegLifecycle(){
// 取消注册生命周期
unRegLifecycle();
},
getJavaClassClick() {
if (getJavaClassTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败'
})
}
},
getAppContextClick() {
if (getAppContextTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败'
})
}
},
getUniActivityClick() {
if (getUniActivityTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败'
})
}
},
pathTestClick() {
if (convert2AbsFullPathTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败'
})
}
},
getAppTempPathClick() {
if (getAppTempPathTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败'
})
}
},
dispatchAsyncClick() {
dispatchAsyncTest(function(ret,desc){
if (ret) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc
})
}
})
},
typeofClick() {
if (typeofClickTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败'
})
}
},
gotoSystemPermissionActivityClick() {
gotoSystemPermissionActivityTest()
},
arrayPermissionFlowClick() {
arrayPermissionFlowTest(function(ret,desc){
if (ret) {
uni.showToast({
icon: 'none',
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc
})
}
})
},
singlePermissionFlowClick() {
singlePermissionFlowTest(function(ret,desc){
if (ret) {
uni.showToast({
icon: 'none',
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc
})
}
})
}
}
}
</script>
<style>
.testButton{
width:100%
}
</style>
@@ -1,170 +0,0 @@
<template>
<!-- #ifdef APP-IOS -->
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<button @click="testCurrentVC">获取当前UIViewController</button>
<view class="result" :style="resultStyle(currentVCResult.passed)"> 测试结果 -- {{formatResult(currentVCResult.passed)}}</view>
<button @click="testKeyWindow">获取当前app的keyWindow</button>
<view class="result" :style="resultStyle(keyWindowResult.passed)"> 测试结果 -- {{formatResult(keyWindowResult.passed)}}</view>
<button @click="testColorConvert">将字符串色值转换为UIColor</button>
<view class="result">
<p v-for="item in colorConvertResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
</view>
<button @click="testResourcePath">资源路径转换</button>
<view class="result" :style="resultStyle(resourcePathResult.passed)"> {{resourcePathResult.key}}: {{resourcePathResult.value}} -- {{formatResult(resourcePathResult.passed)}}</view>
<button @click="testDeviceInfo">获取设备信息</button>
<view class="result">
<p v-for="item in deviceInfoResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
</view>
<button @click="testAppInfo">获取App信息相关api</button>
<view class="result">
<p v-for="item in appInfoResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
</view>
<button @click="testSystemSetting">获取系统设置</button>
<view class="result" :style="resultStyle(systemSettingResult.passed)"> {{systemSettingResult.key}}: {{systemSettingResult.value}} -- {{formatResult(systemSettingResult.passed)}}</view>
<button @click="testTypeof">typeof</button>
<view class="result">
<p v-for="item in typeofResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
</view>
<button @click="testDataConvert">数据转换</button>
<view class="result">
<p v-for="item in dataConvertResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
</view>
<button @click="testAll">test all</button>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
<!-- #endif -->
</template>
<script>
<!-- #ifdef APP-IOS -->
import {
getCurrentVCTest,
getKeyWindowTest,
colorWithStringTest,
getResourcePathTest,
getDeviceInfoTest,
getAppInfoTest,
getSystemSettingTest,
tepeofTest,
dataConvertTest,
} from "@/uni_modules/uts-platform-api"
export default {
data() {
return {
title: "UTSiOS test",
currentVCResult: {},
keyWindowResult: {},
colorConvertResult: [],
resourcePathResult: {},
deviceInfoResult: [],
appInfoResult: [],
systemSettingResult: {},
typeofResult: [],
dataConvertResult: []
}
},
methods: {
formatResult(res) {
if (res == null) {
return "";
}
return res ? "测试通过": "测试失败"
},
resultStyle(res) {
if (res == null) {
return {
color: "#333333"
}
}
let color = res ? "#00ff00" : "#ff0000";
return {
color: color
}
},
testCurrentVC() {
this.currentVCResult = getCurrentVCTest();
},
testKeyWindow() {
this.keyWindowResult = getKeyWindowTest();
},
testColorConvert() {
let array = colorWithStringTest();
this.colorConvertResult = array.map((value) => {
return JSON.parse(value)
})
},
testResourcePath() {
this.resourcePathResult = getResourcePathTest("/static/logo.png");
},
testDeviceInfo() {
let array = getDeviceInfoTest();
this.deviceInfoResult = array.map((value) => {
return JSON.parse(value)
})
},
testAppInfo() {
let array = getAppInfoTest();
this.appInfoResult = array.map((value) => {
return JSON.parse(value)
})
},
testSystemSetting() {
this.systemSettingResult = getSystemSettingTest();
},
testTypeof() {
let array = tepeofTest();
this.typeofResult = array.map((value) => {
return JSON.parse(value)
})
},
testDataConvert() {
let array = dataConvertTest();
this.dataConvertResult = array.map((value) => {
return JSON.parse(value)
})
},
testAll() {
this.testCurrentVC();
this.testKeyWindow();
this.testColorConvert();
this.testResourcePath();
this.testDeviceInfo();
this.testAppInfo();
this.testSystemSetting();
this.testTypeof();
this.testDataConvert();
}
}
}
<!-- #endif -->
</script>
<style>
.result {
text-align: left;
padding-left: 20px;
padding-right: 20px;
max-width: 750rpx;
overflow: visible;
}
</style>
@@ -1,163 +0,0 @@
<template>
<view>
<button @click="testCurrentVC">获取当前UIViewController</button>
<view class="result" :style="resultStyle(currentVCResult.passed)"> 测试结果 -- {{formatResult(currentVCResult.passed)}}</view>
<button @click="testKeyWindow">获取当前app的keyWindow</button>
<view class="result" :style="resultStyle(keyWindowResult.passed)"> 测试结果 -- {{formatResult(keyWindowResult.passed)}}</view>
<button @click="testColorConvert">将字符串色值转换为UIColor</button>
<view class="result">
<p v-for="item in colorConvertResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
</view>
<button @click="testResourcePath">资源路径转换</button>
<view class="result" :style="resultStyle(resourcePathResult.passed)"> {{resourcePathResult.key}}: {{resourcePathResult.value}} -- {{formatResult(resourcePathResult.passed)}}</view>
<button @click="testDeviceInfo">获取设备信息</button>
<view class="result">
<p v-for="item in deviceInfoResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
</view>
<button @click="testAppInfo">获取App信息相关api</button>
<view class="result">
<p v-for="item in appInfoResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
</view>
<button @click="testSystemSetting">获取系统设置</button>
<view class="result" :style="resultStyle(systemSettingResult.passed)"> {{systemSettingResult.key}}: {{systemSettingResult.value}} -- {{formatResult(systemSettingResult.passed)}}</view>
<button @click="testTypeof">typeof</button>
<view class="result">
<p v-for="item in typeofResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
</view>
<button @click="testDataConvert">数据转换</button>
<view class="result">
<p v-for="item in dataConvertResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
</view>
<button @click="testAll">test all</button>
</view>
</template>
<script>
import {
getCurrentVCTest,
getKeyWindowTest,
colorWithStringTest,
getResourcePathTest,
getDeviceInfoTest,
getAppInfoTest,
getSystemSettingTest,
tepeofTest,
dataConvertTest,
} from "@/uni_modules/uts-platform-api"
export default {
data() {
return {
title: "UTSiOS test",
currentVCResult: {},
keyWindowResult: {},
colorConvertResult: [],
resourcePathResult: {},
deviceInfoResult: [],
appInfoResult: [],
systemSettingResult: {},
typeofResult: [],
dataConvertResult: []
}
},
methods: {
formatResult(res) {
if (res == null) {
return "";
}
return res ? "测试通过": "测试失败"
},
resultStyle(res) {
if (res == null) {
return {
color: "#333333"
}
}
let color = res ? "#00ff00" : "#ff0000";
return {
color: color
}
},
testCurrentVC() {
this.currentVCResult = getCurrentVCTest();
},
testKeyWindow() {
this.keyWindowResult = getKeyWindowTest();
},
testColorConvert() {
let array = colorWithStringTest();
this.colorConvertResult = array.map((value) => {
return JSON.parse(value)
})
},
testResourcePath() {
this.resourcePathResult = getResourcePathTest("/static/logo.png");
},
testDeviceInfo() {
let array = getDeviceInfoTest();
this.deviceInfoResult = array.map((value) => {
return JSON.parse(value)
})
},
testAppInfo() {
let array = getAppInfoTest();
this.appInfoResult = array.map((value) => {
return JSON.parse(value)
})
},
testSystemSetting() {
this.systemSettingResult = getSystemSettingTest();
},
testTypeof() {
let array = tepeofTest();
this.typeofResult = array.map((value) => {
return JSON.parse(value)
})
},
testDataConvert() {
let array = dataConvertTest();
this.dataConvertResult = array.map((value) => {
return JSON.parse(value)
})
},
testAll() {
this.testCurrentVC();
this.testKeyWindow();
this.testColorConvert();
this.testResourcePath();
this.testDeviceInfo();
this.testAppInfo();
this.testSystemSetting();
this.testTypeof();
this.testDataConvert();
}
}
}
</script>
<style scoped>
.result {
text-align: left;
padding-left: 20px;
padding-right: 20px;
max-width: 750rpx;
overflow: visible;
}
</style>
@@ -1,55 +0,0 @@
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<button @tap="testShowAlert">确认框</button>
<button @tap="testShowPrompt">输入框</button>
</view>
</view>
</template>
<script>
// #ifdef APP-ANDROID||APP-IOS
import { showAlert,showPrompt } from '@/uni_modules/uts-alert'
// #endif
export default {
data() {
return {
title:"Alert 示例"
}
},
methods:{
testShowAlert(){
showAlert("提示框","这是一个提示框", (index)=> {
let title:string
if (index == 0) {
title = "点击了确认"
} else{
title = "点击了取消"
}
uni.showToast({
title: title,
icon:'none'
})
})
},
testShowPrompt() {
showPrompt("输入框","这是一个输入框","请输入内容", (content)=>{
let title = content.length > 0 ? content : "没有输入内容"
uni.showToast({
title: title,
icon:'none'
})
})
}
}
}
</script>
<style>
</style>
@@ -1,55 +0,0 @@
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<button @tap="testShowAlert">确认框</button>
<button @tap="testShowPrompt">输入框</button>
</view>
</view>
</template>
<script>
// #ifdef APP-ANDROID||APP-IOS
import { showAlert,showPrompt } from '@/uni_modules/uts-alert'
// #endif
export default {
data() {
return {
title:"Alert 示例"
}
},
methods:{
testShowAlert(){
showAlert("提示框","这是一个提示框", (index)=> {
var title = null
if (index == 0) {
title = "点击了确认"
} else{
title = "点击了取消"
}
uni.showToast({
title: title,
icon:'none'
})
})
},
testShowPrompt() {
showPrompt("输入框","这是一个输入框","请输入内容", (content)=>{
let title = content.length > 0 ? content : "没有输入内容"
uni.showToast({
title: title,
icon:'none'
})
})
}
}
}
</script>
<style>
</style>
@@ -1,89 +0,0 @@
<template>
<view>
<page-head title="监听系统截屏" accordion></page-head>
<button @click="testScreenShotListen">监听截屏事件</button>
<button @click="testScreenShotOff">关闭截屏监听</button>
<image :src="screenImage" mode="aspectFit" style="margin-top:10px"></image>
</view>
</template>
<script>
import {
onUserCaptureScreen,
offUserCaptureScreen
} from "@/uni_modules/uts-screenshot-listener";
export default {
data() {
return {
screenImage:""
}
},
methods: {
testScreenShotListen() {
var that = this;
onUserCaptureScreen(function(res) {
console.log(res);
if (uni.getSystemInfoSync().platform == "android") {
// 除android 之外的平台,不需要判断返回状态码
if(res.errCode == -1){
// 启动失败
return ;
}else if(res.errCode == 0){
uni.showToast({
icon:"none",
title:'截屏监听已开启'
})
}else {
uni.showToast({
icon:"none",
title:'捕获截屏事件'
})
if (res.image != null) {
that.screenImage = res.image!
}
}
}else{
// 除android 之外的平台,不需要判断返回状态码
uni.showToast({
icon:"none",
title:'捕获截屏事件'
})
}
});
if (uni.getSystemInfoSync().platform != "android") {
// 除android 之外的平台,直接提示监听已开启
uni.showToast({
icon:"none",
title:'截屏监听已开启'
})
}
},
testScreenShotOff() {
var that = this;
offUserCaptureScreen(function(res) {
console.log(res);
});
// 提示已经开始监听,注意观察
uni.showToast({
icon:"none",
title:'截屏监听已关闭'
})
},
}
}
</script>
<style>
</style>
@@ -1,88 +0,0 @@
<template>
<view>
<page-head title="监听系统截屏" accordion></page-head>
<button @click="testScreenShotListen">监听截屏事件</button>
<button @click="testScreenShotOff">关闭截屏监听</button>
<image :src="screenImage" mode="aspectFit" style="margin-top:10px"></image>
</view>
</template>
<script>
// #ifndef H5
import {
onUserCaptureScreen,
offUserCaptureScreen
} from "@/uni_modules/uts-screenshot-listener";
// #endif
export default {
data() {
return {
screenImage:""
}
},
methods: {
testScreenShotListen() {
var that = this;
onUserCaptureScreen(function(res) {
console.log(res);
if (uni.getSystemInfoSync().platform == "android") {
// 除android 之外的平台,不需要判断返回状态码
if(res.errCode == -1){
// 启动失败
return ;
}else if(res.errCode == 0){
uni.showToast({
icon:"none",
title:'截屏监听已开启'
})
}else {
uni.showToast({
icon:"none",
title:'捕获截屏事件'
})
that.screenImage = res.image
}
}else{
// 除android 之外的平台,不需要判断返回状态码
uni.showToast({
icon:"none",
title:'捕获截屏事件'
})
}
});
if (uni.getSystemInfoSync().platform != "android") {
// 除android 之外的平台,直接提示监听已开启
uni.showToast({
icon:"none",
title:'截屏监听已开启'
})
}
},
testScreenShotOff() {
var that = this;
offUserCaptureScreen(function(res) {
console.log(res);
});
// 提示已经开始监听,注意观察
uni.showToast({
icon:"none",
title:'截屏监听已关闭'
})
},
}
}
</script>
<style>
</style>
@@ -1,265 +0,0 @@
<template>
<view class="uni-container">
<page-head :title="title"></page-head>
<view class="uni-panel" v-for="(item, index) in list" :key="index">
<view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index)">
<text class="uni-panel-text">{{item.name}}</text>
<image :src="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon"
class="uni-icon"></image>
</view>
<view class="uni-panel-c" v-if="item.open">
<view class="uni-navigate-item" v-for="(page,key) in item.pages" :key="key" @click="goDetailPage(page)" hover-class="uni-navigate-item-active">
<text class="uni-navigate-text">{{page.name}}</text>
<image :src="arrowRightIcon" class="uni-icon" v-if="page.url"></image>
</view>
</view>
</view>
</view>
</template>
<script lang="ts">
import { getBatteryInfo, GetBatteryInfoOptions,GetBatteryInfoSuccess } from "@/uni_modules/uts-getbatteryinfo";
// #ifdef APP-ANDROID
import { gotoDemoActivity,sayHelloFromJar,sayHelloFromSO } from "@/uni_modules/uts-nativepage";
import {
UTSAcvitiyLifeCycleCallback,
UTSAcvitiyKeyEventCallback,
UTSActivityWindowCallback,
UTSActivityCallback,
UTSActivityComponentCallback,
onCallbackChange
} from '@/uni_modules/uts-syntaxcase'
import File from 'java.io.File';
import Intent from 'android.content.Intent';
// #endif
type Page = {
name : string,
url ?: string
function ?: string
}
type ListItem = {
name : string,
open : boolean,
pages : Page[],
}
export default {
unmounted() {
// #ifdef APP-ANDROID
this.unRegActivityCallback()
// #endif
},
data() {
return {
title: '系统API示例',
list: [{
name: "设备相关",
open: false,
pages: [{
name: "获取电池电量",
function: "testGetBatteryCapacity"
}
// #ifdef APP-ANDROID
,
{
name: "注册activity 回调方法",
function: "testActivityCallback"
},
// #endif
] as Page[]
},
{
name: "系统事件",
open: false,
pages: [{
name: "监听系统截屏",
url: "SystemAPI/ScreenListen/screenlisten"
}] as Page[]
},
{
name: "Alert系统弹窗",
open: false,
pages: [{
name: "Alert弹窗",
url: "SystemAPI/Alert/alert"
}] as Page[]
},
{
name: "android平台",
open: false,
pages: [{
name: "自定义activity(需自定义基座)",
function: "testGotoDemoActivity"
},{
name: "调用jar中的方法",
function: "testNativeJar"
},{
name: "调用so中的方法",
function: "testNativeSO"
}] as Page[]
}
] as ListItem[],
arrowUpIcon: '/static/icons/arrow-up.png',
arrowDownIcon: '/static/icons/arrow-down.png',
arrowRightIcon: '/static/icons/arrow-right.png',
callback: [] as Any[],
cbText: '',
}
},
methods: {
triggerCollapse(index: number) {
for (var i = 0; i < this.list.length; ++i) {
if (index == i) {
this.list[i].open = !this.list[i].open;
} else {
this.list[i].open = false;
}
}
},
goDetailPage(e: Page) {
if (e.function != null) {
const funName = e.function
switch (funName) {
case 'testGetBatteryCapacity':
this.testGetBatteryCapacity()
break
case 'testActivityCallback':
// #ifdef APP-ANDROID
this.testActivityCallback()
// #endif
break
case 'testGotoDemoActivity':
this.testGotoDemoActivity()
break
case 'testNativeJar':
this.testNativeJar()
break
case 'testNativeSO':
this.testNativeSO()
break
}
return
}
uni.navigateTo({
url: `/pages/${e.url}`
})
},
testGetBatteryCapacity() {
getBatteryInfo({
success(res:GetBatteryInfoSuccess) {
uni.showToast({
title: "当前电量:" + res.level + '%',
icon: 'none'
});
}
} as GetBatteryInfoOptions)
},
// #ifdef APP-ANDROID
testActivityCallback(){
this.activityCallback()
},
activityCallback() {
uni.showToast({
title: "注册成功,请尝试切换到其他app,在切换回来",
icon: 'none'
});
var that = this
onCallbackChange(function (eventLog : string) {
// 展示捕捉到的声明周期日志
let nextLine = that.cbText + eventLog
that.cbText = nextLine
let nextLineFlag = that.cbText + '\n'
that.cbText = nextLineFlag
console.log(that.cbText)
uni.showToast({
title: "activity 回调方法:" +eventLog,
icon: 'none'
});
})
let index = getCurrentPages().length - 1
let page = getCurrentPages()[index]
this.callback.push(new UTSAcvitiyLifeCycleCallback())
this.callback.push(new UTSActivityWindowCallback())
this.callback.push(new UTSAcvitiyKeyEventCallback())
this.callback.push(new UTSActivityCallback(), page.route)
this.callback.push(new UTSActivityComponentCallback())
this.callback.forEach((value) => {
if (value instanceof UTSAcvitiyLifeCycleCallback) {
UTSAndroid.onActivityCallback(value,'tabBar')
}
if (value instanceof UTSActivityWindowCallback) {
UTSAndroid.onActivityCallback(value)
}
if (value instanceof UTSAcvitiyKeyEventCallback) {
UTSAndroid.onActivityCallback(value)
}
if (value instanceof UTSActivityCallback) {
UTSAndroid.onActivityCallback(value)
}
if (value instanceof UTSActivityComponentCallback) {
UTSAndroid.onActivityCallback(value)
}
})
},
unRegActivityCallback() {
this.callback.forEach((value) => {
if (value instanceof UTSAcvitiyLifeCycleCallback) {
UTSAndroid.offActivityCallback(value)
}
if (value instanceof UTSActivityWindowCallback) {
UTSAndroid.offActivityCallback(value)
}
if (value instanceof UTSAcvitiyKeyEventCallback) {
UTSAndroid.offActivityCallback(value)
}
if (value instanceof UTSActivityCallback) {
UTSAndroid.offActivityCallback(value)
}
if (value instanceof UTSActivityComponentCallback) {
UTSAndroid.offActivityCallback(value)
}
})
},
// #endif
testNativeJar() {
let ret = sayHelloFromJar();
uni.showToast({
icon: 'none',
title: '来自jar中的返回值:' + ret
})
},
testNativeSO() {
let ret = sayHelloFromSO();
uni.showToast({
icon: 'none',
title: '来自so中的返回值:' + ret
})
},
testGotoDemoActivity() {
let ret = gotoDemoActivity();
if (!ret) {
uni.showToast({
icon: 'none',
title: '需要在自定义基座中运行'
})
}
}
}
}
</script>
<style>
@import '@/common/uni-uvue.css';
</style>
@@ -1,119 +0,0 @@
<template>
<view class="uni-container">
<page-head :title="title"></page-head>
<view class="uni-panel" v-for="(item, index) in list" :key="index">
<view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index, item)">
<text class="uni-panel-text">{{item.name}}</text>
<image :src="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon"
class="uni-icon"></image>
</view>
<view class="uni-panel-c" v-if="item.open">
<view class="uni-navigate-item" v-for="(page,key) in item.pages" :key="key" @click="goDetailPage(page)" hover-class="uni-navigate-item-active">
<text class="uni-navigate-text">{{page.name}}</text>
<image :src="arrowRightIcon" class="uni-icon" v-if="page.url"></image>
</view>
</view>
</view>
</view>
</template>·
<script>
// #ifdef APP-ANDROID
import { gotoDemoActivity } from "@/uni_modules/uts-nativepage";
// #endif
import { getBatteryInfo } from "@/uni_modules/uts-getbatteryinfo";
export default {
data() {
return {
title: '系统API示例',
list: [{
name: "设备相关",
open: false,
pages: [{
name: "获取电池电量",
function: "testGetBatteryCapacity"
}]
},
{
name: "系统事件",
open: false,
pages: [{
name: "监听系统截屏",
url: "SystemAPI/ScreenListen/screenlisten"
}]
},
{
name: "Alert系统弹窗",
open: false,
pages: [{
name: "Alert弹窗",
url: "SystemAPI/Alert/alert"
}]
},
{
name: "android平台",
open: false,
pages: [{
name: "自定义activity(需自定义基座)",
function: "testGotoDemoActivity"
}]
}
],
arrowUpIcon: '/static/icons/arrow-up.png',
arrowDownIcon: '/static/icons/arrow-down.png',
arrowRightIcon: '/static/icons/arrow-right.png',
}
},
methods: {
triggerCollapse(index) {
for (var i = 0; i < this.list.length; ++i) {
if (index == i) {
this.list[i].open = !this.list[i].open;
} else {
this.list[i].open = false;
}
}
},
goDetailPage(e) {
if (e.function) {
this[e.function]()
return
}
uni.navigateTo({
url: `/pages/${e.url}`
})
},
testGetBatteryCapacity() {
getBatteryInfo({
success(res) {
console.log(res)
uni.showToast({
title: "当前电量:" + res.level + '%',
icon: 'none'
});
}
})
},
testGotoDemoActivity() {
let ret = gotoDemoActivity();
if (!ret) {
uni.showToast({
icon: 'none',
title: '需要在自定义基座中运行'
})
}
}
}
}
</script>
<style>
@import '@/common/uni-uvue.css';
.uni-container {
min-height: 100%;
}
</style>
-227
View File
@@ -1,227 +0,0 @@
<template>
<view class="uni-container">
<page-head :title="title"></page-head>
<view class="uni-panel" v-for="(item, index) in list" :key="index">
<view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index)">
<text class="uni-panel-text">{{item.name}}</text>
<image :src="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon"
class="uni-icon"></image>
</view>
<view class="uni-panel-c" v-if="item.open">
<view class="uni-navigate-item" v-for="(page,key) in item.pages" :key="key" @click="goDetailPage(page)"
hover-class="uni-navigate-item-active">
<text class="uni-navigate-text">{{page.name}}</text>
<image :src="arrowRightIcon" class="uni-icon" v-if="page.url"></image>
</view>
</view>
</view>
</view>
</template>
<script>
import {
doTimerTask,
doIntervalTask,
clearIntervalTask,
playAssetAudio,
getMetaConfig,
quitApp,
TimerOptions
} from "../../uni_modules/uts-advance";
type Page = {
name : string,
url ?: string
function ?: string
}
type ListItem = {
name : string,
open : boolean,
pages : Page[],
}
export default {
data() {
return {
title: 'UTS进阶示例',
taskId: 0,
list: [{
name: "延迟任务",
open: false,
pages: [{
name: "开启延迟任务",
function: "testTimer"
}] as Page[]
},
{
name: "定时任务",
open: false,
pages: [{
name: "开启定时任务",
function: "testInterval"
}, {
name: "关闭定时任务",
function: "testClearInterval"
}] as Page[]
},
{
name: "语法示例",
open: false,
pages: [{
name: "进阶语法示例",
url: "SyntaxCase/index"
}, {
name: "参数传递示例",
url: "SyntaxCase/paramTest"
}, {
name: "实例测试示例",
url: "SyntaxCase/instanceTest"
},
{
name: "混编测试示例",
url: "SyntaxCase/MixNativeCode"
},
] as Page[]
},
{
name: "日志打印",
open: false,
pages: [{
name: "console示例",
url: "SyntaxCase/consoleTest"
}] as Page[]
},
{
name: "组件开发示例",
open: false,
pages: [{
name: "Hello UTS Component",
url: "component/helloView"
}]
},
{
name: "平台代码示例",
open: false,
pages: [{
name: "UTSAndroid",
url: "SyntaxCase/utsAndroid"
}, {
name: "UTSiOS",
url: "SyntaxCase/utsiOS"
}] as Page[]
},
] as ListItem[],
arrowUpIcon: '/static/icons/arrow-up.png',
arrowDownIcon: '/static/icons/arrow-down.png',
arrowRightIcon: '/static/icons/arrow-right.png',
}
},
methods: {
triggerCollapse(index : number) {
for (var i = 0; i < this.list.length; ++i) {
if (index == i) {
this.list[i].open = !this.list[i].open;
} else {
this.list[i].open = false;
}
}
},
goDetailPage(e : Page) {
if (e.function != null) {
const funName = e.function
switch (funName) {
case 'testTimer':
this.testTimer()
break
case 'testInterval':
this.testInterval()
break
case 'testClearInterval':
this.testClearInterval()
break
}
return
}
uni.navigateTo({
url: `/pages/${e.url}`
})
},
/**
* 测试延迟任务
*/
testTimer: function () {
doTimerTask({
start: function (response) {
uni.showToast({
title: response,
icon: 'none'
});
},
work: function (response) {
uni.showToast({
title: response,
icon: 'none'
});
},
} as TimerOptions);
},
/**
* 测试周期任务
*/
testInterval: function () {
var ret = doIntervalTask({
start: function (response) {
uni.showToast({
title: response,
icon: 'none'
});
},
work: function (response) {
uni.showToast({
title: response,
icon: 'none'
});
},
} as TimerOptions);
if (ret.taskId != null) {
this.taskId = ret.taskId!;
}
},
/**
* 取消周期任务
*/
testClearInterval: function () {
console.log(this.taskId);
clearIntervalTask(this.taskId);
},
// testInputDialog() {
// getUserInput(function (res) {
// console.log(res);
// });
// },
testQuitApp() {
quitApp()
},
testMetaRead() {
let ret = getMetaConfig();
uni.showToast({
icon: "none",
title: '读取成功,注意查看控制台输出'
});
console.log(ret);
}
}
}
</script>
<style>
@import '@/common/uni-uvue.css';
.uni-container {
/* min-height: 100%; */
}
</style>
-270
View File
@@ -1,270 +0,0 @@
<template>
<view class="uni-container">
<page-head :title="title"></page-head>
<view class="uni-panel" v-for="(item, index) in list" :key="index">
<view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index, item)">
<text class="uni-panel-text">{{item.name}}</text>
<image :src="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon"
class="uni-icon"></image>
</view>
<view class="uni-panel-c" v-if="item.open">
<view class="uni-navigate-item" v-for="(page,key) in item.pages" :key="key" @click="goDetailPage(page)" hover-class="uni-navigate-item-active">
<text class="uni-navigate-text">{{page.name}}</text>
<image :src="arrowRightIcon" class="uni-icon" v-if="page.url"></image>
</view>
</view>
</view>
</view>
</template>
<script>
import {
doTimerTask,
doIntervalTask,
clearIntervalTask,
playAssetAudio,
getMetaConfig,
quitApp,
arrayConvert
} from "../../uni_modules/uts-advance";
import {openFileWithProvider} from '../../uni_modules/uts-advance'
export default {
data() {
return {
title: 'UTS进阶示例',
taskId: 0,
list: [{
name: "延迟任务",
open: false,
pages: [{
name: "开启延迟任务",
function: "testTimer"
}]
},
{
name: "定时任务",
open: false,
pages: [{
name: "开启定时任务",
function: "testInterval"
}, {
name: "关闭定时任务",
function: "testClearInterval"
}]
},
{
name: "资源加载示例",
open: false,
pages: [{
name: "图片加载示例",
url: "resource/resource"
}]
},
{
name: "组件开发示例",
open: false,
pages: [{
name: "Hello UTS Component",
url: "component/helloView"
}]
},
{
name: "android平台示例",
open: false,
pages: [{
name: "activity生命周期监听",
url: "lifecycle/lifecycle"
}, {
name: "播放asset音频(需自定义基座)",
url: "advance/android/assetaudio"
},
{
name: "使用三方应用打开项目文件",
function: "testOpenFileWithProvider"
},
{
name: "操作DecorView",
url: "advance/android/decorview"
}, {
name: "读取meta配置",
function: "testMetaRead"
}, {
name: "退出当前应用",
function: "testQuitApp"
},{
name: "数组转换测试",
function: "testArrayConvert"
}]
},
{
name: "iOS平台示例",
open: false,
pages: [{
name: "资源路径获取示例",
url: "advance/iOS/getResourcePath"
}]
},
{
name: "语法示例",
open: false,
pages: [{
name: "进阶语法示例",
url: "SyntaxCase/index"
}, {
name: "参数传递示例",
url: "SyntaxCase/paramTest"
},
{
name: "实例测试示例",
url: "SyntaxCase/instanceTest"
},
// #ifdef UNI-APP-X
{
name: "默认值测试示例",
url: "SyntaxCase/defaultValueTest"
},
// #endif
{
name: "混编测试示例",
url: "SyntaxCase/MixNativeCode"
},
{
name: "nvue语法示例",
url: "SyntaxCase/nvueTest"
}
]
},
{
name: "日志打印",
open: false,
pages: [{
name: "console示例",
url: "SyntaxCase/consoleTest"
}]
},
{
name: "平台代码示例",
open: false,
pages: [{
name: "UTSAndroid",
url: "SyntaxCase/utsAndroid"
}, {
name: "UTSiOS",
url: "SyntaxCase/utsiOS"
}]
},
],
arrowUpIcon: '/static/icons/arrow-up.png',
arrowDownIcon: '/static/icons/arrow-down.png',
arrowRightIcon: '/static/icons/arrow-right.png',
}
},
methods: {
triggerCollapse(index) {
for (var i = 0; i < this.list.length; ++i) {
if (index == i) {
this.list[i].open = !this.list[i].open;
} else {
this.list[i].open = false;
}
}
},
goDetailPage(e) {
if (e.function) {
this[e.function]()
return
}
uni.navigateTo({
url: `/pages/${e.url}`
})
},
/**
* 测试延迟任务
*/
testTimer: function() {
doTimerTask({
start: function(response) {
uni.showToast({
title: response,
icon: 'none'
});
},
work: function(response) {
uni.showToast({
title: response,
icon: 'none'
});
},
});
},
/**
* 测试周期任务
*/
testInterval: function() {
var ret = doIntervalTask({
start: function(response) {
uni.showToast({
title: response,
icon: 'none'
});
},
work: function(response) {
uni.showToast({
title: response,
icon: 'none'
});
},
});
this.taskId = ret.taskId;
},
/**
* 取消周期任务
*/
testClearInterval: function() {
console.log(this.taskId);
clearIntervalTask(this.taskId);
},
testInputDialog() {
getUserInput(function(res) {
console.log(res);
});
},
testQuitApp() {
quitApp()
},
testOpenFileWithProvider() {
openFileWithProvider()
},
testArrayConvert() {
let convertRet = arrayConvert()
if(convertRet){
uni.showToast({
icon: "none",
title: '数组转换成功'
});
}
},
testMetaRead() {
let ret = getMetaConfig();
uni.showToast({
icon: "none",
title: '读取成功,注意查看控制台输出'
});
console.log(ret);
}
}
}
</script>
<style>
@import '@/common/uni-uvue.css';
.uni-container {
min-height: 100%;
}
</style>
@@ -1,44 +0,0 @@
<template>
<view>
<page-head title="asset 音频播放示例" accordion></page-head>
<button @click="testStart">播放asset音频</button>
<button @click="testStop">停止播放asset音频</button>
</view>
</template>
<script>
import {
playAssetAudio,
stopAssetAudio
} from "../../../uni_modules/uts-advance";
export default {
data() {
return {
}
},
methods: {
/**
* 测试添加View实例至顶层容器
*/
testStart: function() {
playAssetAudio();
},
/**
* 测试移除顶层容器的View实例
*/
testStop: function() {
stopAssetAudio();
}
}
}
</script>
<style>
</style>
@@ -1,44 +0,0 @@
<template>
<view>
<page-head title="asset 音频播放示例" accordion></page-head>
<button @click="testStart">播放asset音频</button>
<button @click="testStop">停止播放asset音频</button>
</view>
</template>
<script>
import {
playAssetAudio,
stopAssetAudio
} from "../../../uni_modules/uts-advance";
export default {
data() {
return {
}
},
methods: {
/**
* 测试添加View实例至顶层容器
*/
testStart: function() {
playAssetAudio();
},
/**
* 测试移除顶层容器的View实例
*/
testStop: function() {
stopAssetAudio();
}
}
}
</script>
<style>
</style>
@@ -1,45 +0,0 @@
<template>
<view>
<page-head title="DecorView示例" accordion></page-head>
<button @click="testAddToDecorView">添加TextView至视图顶层</button>
<button @click="testRemoveToDecorView">移除视图顶层的TextView</button>
</view>
</template>
<script>
import {
addViewToDecorView,
removeViewToDecorView
} from "../../../uni_modules/uts-advance";
export default {
data() {
return {
title: 'UTS进阶示例',
}
},
methods: {
/**
* 测试添加View实例至顶层容器
*/
testAddToDecorView: function() {
addViewToDecorView();
},
/**
* 测试移除顶层容器的View实例
*/
testRemoveToDecorView: function() {
removeViewToDecorView();
}
}
}
</script>
<style>
</style>
@@ -1,45 +0,0 @@
<template>
<view>
<page-head title="DecorView示例" accordion></page-head>
<button @click="testAddToDecorView">添加TextView至视图顶层</button>
<button @click="testRemoveToDecorView">移除视图顶层的TextView</button>
</view>
</template>
<script>
import {
addViewToDecorView,
removeViewToDecorView
} from "../../../uni_modules/uts-advance";
export default {
data() {
return {
title: 'UTS进阶示例',
}
},
methods: {
/**
* 测试添加View实例至顶层容器
*/
testAddToDecorView: function() {
addViewToDecorView();
},
/**
* 测试移除顶层容器的View实例
*/
testRemoveToDecorView: function() {
removeViewToDecorView();
}
}
}
</script>
<style>
</style>
@@ -1,37 +0,0 @@
<template>
<view>
<page-head title="资源路径获取示例" accordion></page-head>
<button @tap="getResourcePath">获取本地资源路径</button>
</view>
</template>
<script>
// import { getResourcePath } from '@/uni_modules/uts-advance'
// import { removeExampleImageView } from '@/uni_modules/uts-advance'
export default {
onUnload() {
// removeExampleImageView()
},
methods:{
getResourcePath(){
// getResourcePath("/static/logo.png")
}
}
}
</script>
<style>
.text-box {
margin-bottom: 40rpx;
padding: 40rpx 0;
display: flex;
min-height: 300rpx;
background-color: #FFFFFF;
justify-content: center;
align-items: center;
text-align: center;
font-size: 30rpx;
color: #353535;
line-height: 1.8;
}
</style>
@@ -1,37 +0,0 @@
<template>
<view>
<page-head title="资源路径获取示例" accordion></page-head>
<button @tap="getResourcePath">获取本地资源路径</button>
</view>
</template>
<script>
import { getResourcePath } from '@/uni_modules/uts-advance'
import { removeExampleImageView } from '@/uni_modules/uts-advance'
export default {
onUnload() {
removeExampleImageView()
},
methods:{
getResourcePath(){
getResourcePath("/static/logo.png")
}
}
}
</script>
<style>
.text-box {
margin-bottom: 40rpx;
padding: 40rpx 0;
display: flex;
min-height: 300rpx;
background-color: #FFFFFF;
justify-content: center;
align-items: center;
text-align: center;
font-size: 30rpx;
color: #353535;
line-height: 1.8;
}
</style>
@@ -1,16 +0,0 @@
<template>
<div>
<uts-hello-view buttonText="点击按钮内容" style="width:375px;height: 375px;background-color: aqua;"></uts-hello-view>
<uts-hello-container style="flex: 1;background-color: red;">
<text style="left: 100px;top: 100px;background-color: green;">文本组件</text>
<image src="../../static/logo.png" mode="aspectFit"></image>
</uts-hello-container>
</div>
</template>
<script>
</script>
<style>
</style>
@@ -1,30 +0,0 @@
<template>
<div>
<button @tap="doSth">调用组件的方法</button>
<uts-hello-view ref="helloView" buttonText="点击按钮内容" style="width:375px;height: 375px;background-color: aqua;"></uts-hello-view>
<uts-hello-container style="flex: 1;background-color: red;">
<text style="left: 100px;top: 100px;background-color: green;">文本组件</text>
<image src="../../static/logo.png" mode="aspectFit"></image>
</uts-hello-container>
</div>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
// 调用组件内的方法
doSth() {
// uvue 页面调用方法
(this.$refs["helloView"] as UtsHelloViewElement).doSth("param doSomething");
}
}
}
</script>
<style>
</style>
@@ -1,55 +0,0 @@
type TestRes = {
name : string
pass : boolean
}
export function testEncoder() : TestRes[] {
let res : TestRes[] = []
const encoder = new TextEncoder()
const int8 = encoder.encode("€");
const res0 : TestRes = {
name: 'basic encode',
pass: int8.toString() == "226,130,172"
}
res.push(res0)
const decoder = new TextDecoder()
const decode1 = decoder.decode(int8)
const res1 : TestRes = {
name: 'basic decode',
pass: decode1 == "€"
}
res.push(res1)
const STRING1 = "hello 中文 ♥️ 😊 の"
const str1 = encoder.encode(STRING1);
const restStr1 = decoder.decode(str1)
const res2 : TestRes = {
name: 'encode english',
pass: restStr1 == STRING1
}
res.push(res2)
// 空字符串
const empty = encoder.encode("");
const res3 : TestRes = {
name: 'encode empty',
pass: empty.length == 0
}
res.push(res3)
const deEmpty = decoder.decode(empty);
const res4 : TestRes = {
name: 'decode empty',
pass: deEmpty == ""
}
res.push(res4)
return res
}
@@ -1,59 +0,0 @@
const ERR_RE = /expected:<(.*)> but was:<(.*)>/
let result;
const resultEmptyError = '获取到 result 是空的, 请运行项目进行排查'
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isWeb = platformInfo.startsWith('web')
beforeAll(async () => {
if(isWeb) {
const homePage = await program.reLaunch('/pages/index/index')
await homePage.waitFor('view')
await homePage.waitFor(10000)
}
await program.reLaunch('/pages/index/basicTest')
page = await program.currentPage()
await page.waitFor(3000);
const data = await page.data();
result = data['result']
})
function getApiFailed(describe, api) {
if(Object.keys(result).length === 0){
return resultEmptyError
}
const failed = result[describe]?.failed?.find(item => {
return item.split(':')[0] === api
})
return failed
}
describes.forEach(d => {
d?.describe && describe(d.describe, () => {
d?.tests && d.tests.forEach(api => {
it(api, () => {
const failed = getApiFailed(d.describe, api)
if(failed == resultEmptyError){
expect('').toBe(resultEmptyError)
}else if (failed) {
const parts = failed.split('\n')
const matches = parts[1].match(ERR_RE)
if (matches?.length) {
expect(matches[2]).toEqual(matches[1])
} else {
expect(parts[1]).toEqual('')
}
}
})
})
})
})
if (process.env.UNI_PROJECT_TYPE === '2.0' && process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('ios')) {
describe('testTypeFromAppJs', () => {
it("jest_testTypeFromAppJs", async () => {
const res = await page.callMethod('jest_testTypeFromAppJs')
expect(res).toEqual(true)
})
})
}
-104
View File
@@ -1,104 +0,0 @@
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view class="content">
<page-head :title="title"></page-head>
<view v-for="(item, index) in resultArray" :key="index" class="result">
<view>{{ names[index] }}测试结果:</view>
<view> 测试api{{ item.passed.join(', ') }} </view>
<view>总共:{{ item.total }}</view>
<view>通过:{{ item.passed.length }}</view>
<view>失败:{{ item.failed.length }}</view>
<view v-for="(fail, i) in item.failed" :key="i">
<text class="failed">{{ fail }}</text>
</view>
</view>
<view class="result">
<view> uvue 测试</view>
<view>总共:{{ uvueResult.length }}</view>
<view>通过:{{ uvueResult.filter(i=>!!i).length }}</view>
<view>失败:{{ uvueResult.filter(i=>!i).length }}</view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="ts">
import { testEncoder } from './basicEncoder'
import { runTests, Result } from '../../uni_modules/uts-tests'
// #ifdef APP-IOS
import { testTypeFromAppJs, Options } from '@/uni_modules/uts-ios-tests'
// #endif
// #ifdef APP-ANDROID
// 故意使用 import type 引入一个不存在的类型,测试编译器是否会报错,旧版本不会报错,但android补充了移除type类型的transformer就会报错
// 目前android已经不再启用移除type类型的transformer
import type { TestType } from '@/uni_modules/uts-tests'
// #endif
import { testSyntaxUnion } from '@/uni_modules/uts-test-syntax-union'
// #ifdef APP-ANDROID || APP-IOS
import { testBuildinNative } from '@/uni_modules/uts-tests-hybrid'
// #endif
export default {
data() {
return {
title: 'UTS基础语法',
resultArray: [] as Result[],
result: {} as UTSJSONObject,
uvueResult: [] as boolean[],
names: [] as string[],
}
},
onReady() {
testSyntaxUnion()
// #ifdef APP-ANDROID || APP-IOS
testBuildinNative()
// #endif
this.test()
},
methods: {
test() {
const uvueTest = testEncoder().map(i => i.pass)
this.uvueResult = uvueTest
this.result = runTests()
// const resultMap = this.result.toMap()
// resultMap.forEach((res, name) => {
// this.names.push(name)
// this.resultArray.push(res as Result)
// })
const resultMap = this.result
for (const key in resultMap) {
this.names.push(key)
this.resultArray.push(resultMap[key] as Result)
}
},
// #ifdef APP-IOS
jest_testTypeFromAppJs() {
return testTypeFromAppJs({
num: 1
} as Options)
}
// #endif
},
}
</script>
<style>
@import '@/common/uni-uvue.css';
.content {
padding: 32rpx;
}
.passed {
color: green;
}
.failed {
color: red;
}
.result {
margin-bottom: 20rpx;
}
</style>
@@ -1,61 +0,0 @@
<template>
<view class="content">
<page-head :title="title"></page-head>
<view v-for="(item,name) in result" :key="name" class="result">
<view>{{name}}测试结果</view>
<view>
测试api{{item.passed.join(', ')}}
</view>
<view>总共{{item.total}}</view>
<view>通过{{item.passed.length}}</view>
<view>失败{{item.failed.length}}</view>
<view v-for="(fail,index) in item.failed" :key="index" class="failed">
<view>{{fail.split('\n')[0]}}</view>
<view>{{fail.split('\n')[1]}}</view>
</view>
</view>
</view>
</template>
<script>
import {
runTests
} from '../../uni_modules/uts-tests'
import { testSyntaxUnion } from '@/uni_modules/uts-test-syntax-union'
export default {
data() {
return {
title: 'UTS基础语法',
result: {}
}
},
onReady() {
testSyntaxUnion()
this.test()
},
methods: {
test() {
this.result = runTests()
console.log(this.result)
}
}
}
</script>
<style>
@import '@/common/uni-uvue.css';
.content {
min-height: 100%;
padding: 32rpx;
}
.passed {
color: green;
}
.failed {
color: red;
}
.result {
margin-bottom: 20rpx;
}
</style>
-116
View File
@@ -1,116 +0,0 @@
<template>
<view>
<page-head :title="title"></page-head>
<input class="uni-input" v-model="stringParam" />
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="testDoSthWithCallback">uts异步方法(无参数)</button>
<button type="primary" @tap="testDoSthWithString">uts异步方法(字符串参数)</button>
<button type="primary" @tap="testDoSthWithJSON">uts异步方法(json参数)</button>
<button type="primary" @tap="testCallback">多次回调示例1</button>
<button type="primary" @tap="testPluginDepend">uts插件依赖示例</button>
<button type="primary" @tap="testBuildinObject">内置对象语法测试</button>
</view>
</view>
</template>
<script>
import { callWithJSONParam, callWithStringParam, callWithoutParam, JsonParamOptions, inputJSON ,onCallback} from "../../uni_modules/uts-helloworld";
import { testb } from "@/uni_modules/uts-test-b";
export default {
data() {
return {
title: 'UTS入门示例',
stringParam: "hello world",
}
},
methods: {
/**
* 测试无参数调用
*/
testDoSthWithCallback: function () {
callWithoutParam(
() => {
uni.showToast({
title: '成功调用uts插件uts-helloworld的callWithoutParam',
icon: 'none'
});
}
);
},
/**
* 测试字符串参数回调
*/
testDoSthWithString: function () {
callWithStringParam(
this.stringParam,
function (response) {
uni.showToast({
title: 'uts插件uts-helloworld的callWithStringParam方法收到了你输入的字符串:' + response,
icon: 'none'
});
},
);
},
/**
* 测试json参数回调
*/
testDoSthWithJSON: function () {
const that = this
var inputObject : inputJSON = {
inputText: that.stringParam,
errCode: 0,
complete: (res) => {
uni.showToast({
title: '嵌套回调结果:' + JSON.stringify(res),
icon: 'none'
});
}
}
callWithJSONParam({
input: inputObject,
success: function (response) {
uni.showToast({
title: '执行结果:' + JSON.stringify(response),
icon: 'none'
});
}
} as JsonParamOptions);
},
testCallback: function () {
onCallback(
function(response){
uni.showToast({
title:'uts插件uts-helloworld的callWithStringParam方法收到了你输入的字符串:'+response,
icon:'none'
});
},
);
},
/**
* 测试内置对象
*/
testBuildinObject: function() {
uni.navigateTo({
url: `/pages/index/basicTest`
})
},
/**
* 测试插件依赖
*/
testPluginDepend() {
testb()
}
}
}
</script>
<style>
</style>
-118
View File
@@ -1,118 +0,0 @@
<template>
<view>
<page-head :title="title"></page-head>
<input class="uni-input" v-model="stringParam" />
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="testDoSthWithCallback">uts异步方法无参数</button>
<button type="primary" @tap="testDoSthWithString">uts异步方法字符串参数</button>
<button type="primary" @tap="testDoSthWithJSON">uts异步方法json参数</button>
<button type="primary" @tap="testCallback">多次回调示例2</button>
<button type="primary" @tap="testPluginDepend">uts插件依赖示例</button>
<button type="primary" @tap="testBuildinObject">内置对象语法测试</button>
</view>
</view>
</template>
<script>
import { callWithJSONParam, callWithStringParam, callWithoutParam,onCallback } from "../../uni_modules/uts-helloworld";
import { testb } from "@/uni_modules/uts-test-b";
export default {
data() {
return {
title: 'UTS入门示例',
stringParam:"hello world",
}
},
methods: {
/**
* 测试无参数调用
*/
testDoSthWithCallback: function () {
callWithoutParam(
()=>{
uni.showToast({
title:'成功调用uts插件uts-helloworld的callWithoutParam1',
icon:'none'
});
}
);
},
/**
* 测试字符串参数回调
*/
testDoSthWithString: function () {
callWithStringParam(
this.stringParam,
function(response){
uni.showToast({
title:'uts插件uts-helloworld的onCallback方法:'+response,
icon:'none'
});
},
);
},
/**
* 测试json参数回调
*/
testDoSthWithJSON: function () {
var inputObject = {
inputText:this.stringParam,
errCode:0,
complete: (res) => {
uni.showToast({
title: '嵌套回调结果:' + JSON.stringify(res),
icon: 'none'
});
}
}
callWithJSONParam({
input:inputObject,
success:function(response){
uni.showToast({
title:'执行结果:' + JSON.stringify(response),
icon:'none'
});
}
});
},
testCallback: function () {
onCallback(
function(response){
uni.showToast({
title:'uts插件uts-helloworld的callWithStringParam方法收到了你输入的字符串:'+response,
icon:'none'
});
},
);
},
/**
* 测试内置对象
*/
testBuildinObject: function() {
uni.navigateTo({
url: `/pages/index/basicTest`
})
},
/**
* 测试插件依赖
*/
testPluginDepend() {
testb()
}
}
}
</script>
<style>
</style>
@@ -1,27 +0,0 @@
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isHarmony = platformInfo.startsWith('harmony')
let page
if(isHarmony) {
beforeAll(async () => {
page = await program.reLaunch('/pages/issues/issue-20157/issue-20157')
});
}
describe('issue-20157', () => {
if(!isHarmony) {
it('skip',() => {
expect(1).toBe(1)
})
return
}
it('issue-20157', async () => {
const {
a,
b
} = await page.data()
expect(a).toBe('ab')
expect(b).toBe(12)
})
});
@@ -1,32 +0,0 @@
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<!-- #endif -->
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
import { A } from '@/uni_modules/issue-20157'
const a = {
a: 'ab',
b: 12
} as A
export default {
data() {
return {
a: a.a,
b: a.b
}
},
methods: {
}
}
</script>
<style>
</style>
@@ -1,79 +0,0 @@
<template>
<view>
<page-head :title="title"></page-head>
<button @tap="testGoOtherActivity">跳转选择界面</button>
<image :src="selectImage" v-if="selectImage"></image>
<button @tap="testUnRegLifecycle">取消注册周期函数</button>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1. 当前页面已通过initAppLifecycle函数注册了生命周期监听。
</view>
<view class="uni-hello-text">
2. 手动切换其他APP再返回,可在控制台和界面观察事件日志
</view>
</view>
<view class="uni-padding-wrap uni-common-mt">
<view class="text-box" scroll-y="true">
<text>{{text}}</text>
</view>
</view>
</view>
</template>
<script>
import { initAppLifecycle,unRegLifecycle,goOtherActivity } from '../../uni_modules/uts-advance';
export default {
data() {
return {
title: '生命周期监听',
text: '',
selectImage:""
}
},
onLoad:function(){
let that = this;
initAppLifecycle(function(eventLog){
// 展示捕捉到的声明周期日志
that.text += eventLog;
that.text += '\n';
});
},
methods:{
testGoOtherActivity(){
var that = this;
let ret = goOtherActivity(function(file){
// 展示捕捉到的声明周期日志
console.log(file);
that.selectImage = "file://" + file;
});
if(!ret){
uni.showToast({
icon:'none',
title:'请授予权限后重试'
})
}
},
testUnRegLifecycle(){
// 取消注册生命周期
unRegLifecycle();
}
}
}
</script>
<style>
.text-box {
margin-bottom: 40rpx;
padding: 40rpx 0;
display: flex;
min-height: 300rpx;
background-color: #FFFFFF;
justify-content: center;
align-items: center;
text-align: center;
font-size: 30rpx;
color: #353535;
line-height: 1.8;
}
</style>
@@ -1,79 +0,0 @@
<template>
<view>
<page-head :title="title"></page-head>
<button @tap="testGoOtherActivity">跳转选择界面</button>
<image :src="selectImage" v-if="selectImage"></image>
<button @tap="testUnRegLifecycle">取消注册周期函数</button>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1. 当前页面已通过initAppLifecycle函数注册了生命周期监听
</view>
<view class="uni-hello-text">
2. 手动切换其他APP再返回可在控制台和界面观察事件日志
</view>
</view>
<view class="uni-padding-wrap uni-common-mt">
<view class="text-box" scroll-y="true">
<text>{{text}}</text>
</view>
</view>
</view>
</template>
<script>
import { initAppLifecycle,unRegLifecycle,goOtherActivity } from '../../uni_modules/uts-advance';
export default {
data() {
return {
title: '生命周期监听',
text: '',
selectImage:""
}
},
onLoad:function(){
let that = this;
initAppLifecycle(function(eventLog){
// 展示捕捉到的声明周期日志
that.text = that.text += eventLog;
that.text = that.text += '\n';
});
},
methods:{
testGoOtherActivity(){
var that = this;
let ret = goOtherActivity(function(file){
// 展示捕捉到的声明周期日志
console.log(file);
that.selectImage = "file://" + file;
});
if(!ret){
uni.showToast({
icon:'none',
title:'请授予权限后重试'
})
}
},
testUnRegLifecycle(){
// 取消注册生命周期
unRegLifecycle();
}
}
}
</script>
<style>
.text-box {
margin-bottom: 40rpx;
padding: 40rpx 0;
display: flex;
min-height: 300rpx;
background-color: #FFFFFF;
justify-content: center;
align-items: center;
text-align: center;
font-size: 30rpx;
color: #353535;
line-height: 1.8;
}
</style>
@@ -1,31 +0,0 @@
<template>
<view>
<page-head :title="title"></page-head>
<image :src="logo" mode="aspectFit" style="width: 100%;"></image>
</view>
</template>
<script>
import { getLogoPath } from '../../uni_modules/uts-advance'
export default {
data() {
return {
title: '资源加载示例',
logo:""
}
},
onLoad:function(){
this.logo = getLogoPath()
}
}
</script>
<style>
</style>
@@ -1,31 +0,0 @@
<template>
<view>
<page-head :title="title"></page-head>
<image :src="logo" mode="aspectFit" style="width: 100%;"></image>
</view>
</template>
<script>
import { getLogoPath } from '../../uni_modules/uts-advance'
export default {
data() {
return {
title: '资源加载示例',
logo:""
}
},
onLoad:function(){
this.logo = getLogoPath()
}
}
</script>
<style>
</style>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.

Before

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 B

File diff suppressed because it is too large Load Diff
Binary file not shown.
@@ -1,97 +0,0 @@
{
"id": "issue-20157",
"displayName": "issue-20157",
"version": "1.0.0",
"description": "issue-20157",
"keywords": [
"issue-20157"
],
"repository": "",
"engines": {
"HBuilderX": "^3.6.8",
"uni-app": "^3.1.0",
"uni-app-x": "^3.1.0"
},
"dcloudext": {
"type": "uts",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "",
"data": "",
"permissions": ""
},
"npmurl": "",
"darkmode": "-",
"i18n": "-",
"widescreen": "-"
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "-",
"aliyun": "-",
"alipay": "-"
},
"client": {
"uni-app": {
"vue": {
"vue2": "-",
"vue3": "-"
},
"web": {
"safari": "-",
"chrome": "-"
},
"app": {
"vue": "-",
"nvue": "-",
"android": "-",
"ios": "-",
"harmony": "-"
},
"mp": {
"weixin": "-",
"alipay": "-",
"toutiao": "-",
"baidu": "-",
"kuaishou": "-",
"jd": "-",
"harmony": "-",
"qq": "-",
"lark": "-"
},
"quickapp": {
"huawei": "-",
"union": "-"
}
},
"uni-app-x": {
"web": {
"safari": "-",
"chrome": "-"
},
"app": {
"android": "-",
"ios": "-",
"harmony": "-"
},
"mp": {
"weixin": "-"
}
}
}
}
}
}
@@ -1,7 +0,0 @@
# issue-20157
### 开发文档
[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html)
[UTS API插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html)
[UTS uni-app兼容模式组件](https://uniapp.dcloud.net.cn/plugin/uts-component.html)
[UTS 标准模式组件](https://doc.dcloud.net.cn/uni-app-x/plugin/uts-vue-component.html)
[Hello UTS](https://gitcode.net/dcloud/hello-uts)
@@ -1,4 +0,0 @@
export type A = {
a: string,
b?: number | null
}
@@ -1,82 +0,0 @@
{
"id": "uts-advance",
"displayName": "uts-advance",
"version": "1.0.0",
"description": "uts-advance",
"keywords": [
"uts-advance"
],
"repository": "",
"engines": {
"HBuilderX": "^3.6.11"
},
"dcloudext": {
"type": "native-uts",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "",
"data": "",
"permissions": ""
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "u",
"aliyun": "u"
},
"client": {
"Vue": {
"vue2": "u",
"vue3": "u"
},
"App": {
"app-vue": "u",
"app-nvue": "u"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
},
"H5-pc": {
"Chrome": "u",
"IE": "u",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
},
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}
@@ -1,3 +0,0 @@
# uts-advance
UTS进阶示例插件
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
package="io.dcloud.uni_modules.uts_advance"
>
<!--permissions-->
<application><meta-data android:name="UTS_CUSTOM_LAUNCHER_META" android:value="HelloUTS" /></application>
</manifest>
@@ -1,535 +0,0 @@
import Color from "android.graphics.Color";
import TextView from "android.widget.TextView";
import FrameLayout from "android.widget.FrameLayout";
import ViewGroup from "android.view.ViewGroup";
import Gravity from "android.view.Gravity";
import Runnable from 'java.lang.Runnable';
import MediaPlayer from 'android.media.MediaPlayer';
import Intent from 'android.content.Intent';
import logo from "../../static/logo.png";
import PackageManager from "android.content.pm.PackageManager";
import MediaStore from "android.provider.MediaStore";
import ActivityCompat from "androidx.core.app.ActivityCompat";
import Manifest from "android.Manifest";
import Activity from "android.app.Activity";
import Bitmap from "android.graphics.Bitmap";
import FileOutputStream from "java.io.FileOutputStream";
import Toast from 'android.widget.Toast';
import AlertDialog from 'android.app.AlertDialog';
import DialogInterface from 'android.content.DialogInterface';
import EditText from 'android.widget.EditText';
import array from 'android.R.array';
import File from 'java.io.File';
/**
* 定时任务参数封装
*/
export type TimerOptions = {
/**
* 定时任务开始的回调
* @res 回调参数
*/
start : (res : string) => void;
/**
* 定时任务执行的回调
* @res 回调参数
*/
work : (res : string) => void;
};
export type TimerResult = {
name : string;
taskId ?: number;
};
/**
* 执行延时任务
*/
export function doTimerTask(opts : TimerOptions): TimerResult {
opts.start('doTimerTask start');
setTimeout(function () {
opts.work("doTimerTask work");
}, 2000);
const result: TimerResult = {
name: "doTimerTask"
}
return result
}
/**
* 执行周期任务
*/
export function doIntervalTask(opts : TimerOptions): TimerResult {
let taskRet = setInterval(function () {
opts.work("doIntervalTask work");
}, 2000);
opts.start('doIntervalTask start');
const result: TimerResult = {
name: "doIntervalTask",
taskId: taskRet
}
return result
}
/**
* 清除周期任务
*/
export function clearIntervalTask(taskId : number): TimerResult {
clearInterval(taskId);
const result: TimerResult = {
name: "clearIntervalTask"
}
return result
}
/**
* 实现一个添加view的 Runnable类
* 用法说明:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#%E5%8C%BF%E5%90%8D%E5%86%85%E9%83%A8%E7%B1%BB
*/
class AddUIRunnable implements Runnable {
override run() : void {
let textView = new TextView(UTSAndroid.getUniActivity())
textView.setText("HELLO WORLD");
textView.textSize = 30.0.toFloat();
textView.setBackgroundColor(Color.RED)
textView.setTag("helloText")
textView.setGravity(Gravity.CENTER)
let decorView = UTSAndroid.getUniActivity()!.getWindow().getDecorView();
let frameContent = decorView.findViewById<FrameLayout>(android.R.id.content)
let layoutParam = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParam.topMargin = 200;
frameContent.addView(textView, layoutParam)
}
};
/**
* 实现一个移除view的 Runnable类
* 用法说明:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#%E5%8C%BF%E5%90%8D%E5%86%85%E9%83%A8%E7%B1%BB
*/
class RemoveUIRunnable implements Runnable {
override run() : void {
let decorView = UTSAndroid.getUniActivity()!.getWindow().getDecorView();
let frameContent = decorView.findViewById<FrameLayout>(android.R.id.content)
let targetTV = frameContent.findViewWithTag<TextView>("helloText")
frameContent.removeView(targetTV)
}
};
/**
* 实现添加view实例至decorview
*
*/
export function addViewToDecorView() {
let uiRunable = new AddUIRunnable();
UTSAndroid.getUniActivity()!.runOnUiThread(uiRunable)
}
/**
* 实现从decorview上移除指定view
*/
export function removeViewToDecorView() {
var uiRunable = new RemoveUIRunnable();
UTSAndroid.getUniActivity()!.runOnUiThread(uiRunable)
}
/**
* 引用资源路径
*/
export function getMetaConfig() : string {
//
let packageName = UTSAndroid.getAppContext()!.getPackageName();
let appInfo = UTSAndroid.getAppContext()!.getPackageManager()!.getApplicationInfo(packageName, PackageManager.GET_META_DATA)
let metaData = appInfo.metaData
if (metaData == null) {
return "";
}
let adId = metaData.getString("DCLOUD_READ_PHONE_STATE")
if (adId == null) {
// 没有数据,说明是自定义基座,则读取自定义基座的配置
let customMetaId = metaData.getString("UTS_CUSTOM_LAUNCHER_META")
if (customMetaId == null) {
return ""
}
return "自定义基座[UTS_CUSTOM_LAUNCHER_META]:" + customMetaId;
}
// 标准基座
return "标准基座[DCLOUD_READ_PHONE_STATE]:" + adId;
}
/**
* 引用资源路径
*/
export function getLogoPath() : string {
return logo;
}
/**
* 音频播放器对象
*/
let globalPlayer : MediaPlayer | null = null;
/**
* 播放asset资源中的音频
*/
export function playAssetAudio() {
let assetManager = UTSAndroid.getAppContext()!.getAssets();
let afd = assetManager.openFd("free.mp3");
if (globalPlayer == null) {
globalPlayer = new MediaPlayer();
globalPlayer!.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
globalPlayer!.prepare();
globalPlayer!.start();
}
}
/**
* 停止播放asset资源中的音频
*/
export function stopAssetAudio() {
if (globalPlayer != null) {
globalPlayer!.stop();
globalPlayer = null;
}
}
@UTSAndroid.Suppress("DEPRECATION")
export function goOtherActivity(imageDone : (event : string) => void) : boolean {
// 检查相关权限是否已经具备
if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
// 不具备权限,申请权限,并且告知用户监听失败
ActivityCompat.requestPermissions(UTSAndroid.getUniActivity()!, arrayOf(Manifest.permission.CAMERA), 1002)
return false;
}
UTSAndroid.onAppActivityResult((requestCode : Int, resultCode : Int, data ?: Intent) => {
let eventName = "onAppActivityResult - requestCode:" + requestCode + " -resultCode:" + resultCode + " -data:" + JSON.stringify(data);
console.log(eventName);
if ((requestCode == 1001) && (resultCode == Activity.RESULT_OK)) {
if (data != null) {
let bundle = data.getExtras();
let mImageBitmap = bundle!.get("data") as Bitmap;
let bitmapPath = UTSAndroid.getUniActivity()!.getExternalCacheDir()!.getPath() + "/photo.png"
console.log(bitmapPath);
try {
mImageBitmap.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream(bitmapPath))
} catch (e) {
}
imageDone(bitmapPath);
}
}
});
let takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//resolveActivity 返回可处理 Intent 的第一个 Activity 组件
if (takePictureIntent.resolveActivity(UTSAndroid.getUniActivity()!.getPackageManager()) != null) {
UTSAndroid.getUniActivity()!.startActivityForResult(takePictureIntent, 1001);
}
return true;
}
/**
* 初始化应用生命周期监听
*
*/
export function initAppLifecycle(onLifecycleChange : (event : string) => void) {
/**
* application 内存不足的回调函数
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onapptrimmemory
*/
UTSAndroid.onAppTrimMemory((level : Number) => {
let eventName = "onAppTrimMemory - " + level;
onLifecycleChange(eventName);
console.log(eventName);
});
/**
* application 状态改变的回调函数
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onAppConfigChange
*/
UTSAndroid.onAppConfigChange((ret : UTSJSONObject) => {
let eventName = "onAppConfigChange - " + JSON.stringify(ret);
onLifecycleChange(eventName);
console.log(eventName);
});
/**
* activity 销毁生命周期回调
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivitydestroy
*/
UTSAndroid.onAppActivityDestroy(() => {
let eventName = "onAppActivityDestroy";
onLifecycleChange(eventName);
console.log(eventName);
});
/**
* activity 失去焦点生命周期回调
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivitypause
*/
UTSAndroid.onAppActivityPause(() => {
let eventName = "onAppActivityPause";
onLifecycleChange(eventName);
console.log(eventName);
});
/**
* activity 得到焦点的周期回调
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivityresume
*/
UTSAndroid.onAppActivityResume(() => {
let eventName = "onAppActivityResume";
onLifecycleChange(eventName);
console.log(eventName);
});
/**
* activity 回退物理按键事件回调
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivityback
*/
UTSAndroid.onAppActivityBack(() => {
let eventName = "onAppActivityBack";
onLifecycleChange(eventName);
console.log(eventName);
});
}
/**
* 取消注册生命周期函数
*/
export function unRegLifecycle() {
/**
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onapptrimmemory
*/
UTSAndroid.offAppTrimMemory();
/**
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onAppConfigChange
*/
UTSAndroid.offAppConfigChange();
/**
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivitydestroy
*/
UTSAndroid.offAppActivityDestroy();
/**
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivitypause
*/
UTSAndroid.offAppActivityPause();
/**
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivityresume
*/
UTSAndroid.offAppActivityResume();
/**
* activity 回退物理按键事件回调
*/
UTSAndroid.offAppActivityBack();
}
/**
* add since 2023-06-19
* 新增传参测试用例
*/
export function inputArray(input : Array<string>) : boolean {
let inputStr = JSON.stringify(input)
if ('["a","b","c"]' == inputStr) {
return true
}
return false
}
export type ParamOptions = {
title : string,
array : Array<string>
}
export function inputParam(option : ParamOptions) : boolean {
let inputStr = JSON.stringify(option)
console.log(inputStr)
if ('{"array":["1","2","3"],"title":"hello"}' == inputStr) {
return true
}
return false
}
export function returnArray() : Array<string> {
return ['1', '2', '3']
}
export function returnParam() : ParamOptions {
let ret : ParamOptions = {
title: "returnParam",
array: ['1', '2', '3']
}
return ret
}
export type ParamCallback = (res : ParamOptions) => void
export type ArrayCallback = (res : Array<string>) => void
export function callbackArray(callback : ArrayCallback) {
callback(['8', '8', '8'])
}
export function callbackParam(callback : ParamCallback) {
let ret : ParamOptions = {
title: "callbackParam",
array: ['4', '5', '6']
}
callback(ret)
}
/**
*
*/
export function quitApp(){
UTSAndroid.exit()
}
export class User {
private name : string;
private age : Int;
constructor(hostP : string, port : Int) {
this.name = hostP;
this.age = port;
}
describeSelf():string{
let text = "name = " + this.name + ";age = " + this.age
return text
}
}
export function arrayConvert():boolean{
// kotlin.collections.List 转换 Array
let kotlinList = mutableListOf("hello","world")
let utsArr1 = Array.fromNative(kotlinList)
if(utsArr1[0] != "hello"){
return false
}
// kotlin.Array 转换 Array
let kotlinArray = arrayOf("hello","world")
let utsArr2 = Array.fromNative(kotlinArray)
if(utsArr2[0] != "hello"){
return false
}
let b1 = byteArrayOf(-1,2,0,3,4,5)
let c1 = Array.fromNative(b1)
if(c1[0] != (-1 as Number).toByte()){
return false
}
let b2 = longArrayOf(-1,2,0,3,4,5)
let c2 = Array.fromNative(b2)
if(c2[0] != (-1 as Number).toLong()){
return false
}
let b3 = shortArrayOf(-1,2,0,3,4,5)
let c3 = Array.fromNative(b3)
if(c3[0] != (-1 as Number).toShort()){
return false
}
let b4 = intArrayOf(-1,2,0,3,4,5)
let c4 = Array.fromNative(b4)
if(c4[0] != (-1 as Number).toInt()){
return false
}
return true
}
export function openFileWithProvider(){
let file = new File(UTSAndroid.getResourcePath("static/logo.png"))
const uri = UTSAndroid.getFileProviderUri(file)
console.log("uri",uri.toString())
const intent = new Intent(Intent.ACTION_VIEW, uri)
// 添加权限标志
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
const context = UTSAndroid.getUniActivity()!;
context.startActivity(intent);
}
export class DefaultParamTest {
static execute(msg : String = "123") : string {
return msg
}
execute2(msg : String = "456") : string {
return msg
}
}
export function defaultParamFunc(msg : string = "789"):string {
return msg
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

@@ -1,234 +0,0 @@
import { UIImageView , UIImage , UIScreen } from 'UIKit';
import { DispatchQueue } from 'Dispatch';
import { UTSiOS } from "DCloudUTSFoundation";
export function addViewToDecorView() { }
export function removeViewToDecorView() { }
export function initAppLifecycle() { }
export function getLogoPath() {}
export function playAssetAudio(){}
/**
* 定时任务参数封装
*/
export type TimerOptions = {
/**
* 定时任务开始的回调
* @res 回调参数
*/
start: (res: string) => void;
/**
* 定时任务执行的回调
* @res 回调参数
*/
work: (res: string) => void;
};
export type TimerResult = {
name : string;
taskId ?: number;
};
/**
* 执行延时任务
*/
export function doTimerTask(opts:TimerOptions): TimerResult {
opts.start('doTimerTask start');
setTimeout(function() {
opts.work("doTimerTask work");
}, 2000);
const result: TimerResult = {
name: "doTimerTask"
}
return result
}
/**
* 执行周期任务
*/
export function doIntervalTask(opts:TimerOptions): TimerResult {
let taskRet = setInterval(function() {
opts.work("doIntervalTask work");
}, 2000);
opts.start('doIntervalTask start');
const result: TimerResult = {
name: "doIntervalTask",
taskId: taskRet
}
return result
}
/**
* 清除周期任务
*/
export function clearIntervalTask(taskId:number):TimerResult {
clearInterval(taskId);
const result: TimerResult = {
name: "clearIntervalTask"
}
return result
}
/*
* 保存全局数据信息
*/
class AdvanceModuleGloabInfo {
static imageView?: UIImageView = null
}
/**
* 将h5资源路径转成app本地资源路径
*/
export function getResourcePath(path: string) {
const imagePath = UTSiOS.getResourcePath(path)
console.log(imagePath)
if (AdvanceModuleGloabInfo.imageView == null) {
let vc = UTSiOS.getCurrentViewController()
// uts方法默认会在子线程中执行,涉及 UI 操作必须在主线程中运行,通过 DispatchQueue.main.async 方法可将代码在主线程中运行
DispatchQueue.main.async(execute=():void => {
// 创建imageView
let imageView = new UIImageView()
let image = new UIImage(contentsOfFile = imagePath)
imageView.image = image
// 添加imageView并设置frame
vc.view.addSubview(imageView)
let imageSize: CGFloat = 80.0
let midx = (UIScreen.main.bounds.size.width - imageSize) / 2
let midy = (UIScreen.main.bounds.size.height - imageSize) / 2
imageView.frame = CGRect(x = midx, y = midy, width = imageSize, height = imageSize)
AdvanceModuleGloabInfo.imageView = imageView
})
}
}
export function removeExampleImageView() {
DispatchQueue.main.async(execute=():void => {
if (AdvanceModuleGloabInfo.imageView != null) {
AdvanceModuleGloabInfo.imageView!.removeFromSuperview()
AdvanceModuleGloabInfo.imageView = null
}
})
}
/**
* add since 2023-06-19
* 新增传参测试用例
*/
export function inputArray(input : Array<string>) : boolean {
let inputStr = JSON.stringify(input)
if ('["a","b","c"]' == inputStr) {
return true
}
return false
}
export type ParamOptions = {
title : string,
array : Array<string>
}
export function inputParam(option : ParamOptions) : boolean {
console.log(option, "传入的参数")
let inputStr = JSON.stringify(option)
console.log(inputStr, 'stringify option')
if ('{"array":[1,2,3],"title":"hello"}' == inputStr) {
return true
}
return false
}
export function returnArray() : Array<string> {
return ['1', '2', '3']
}
export function returnParam() : ParamOptions {
let ret : ParamOptions = {
title: "returnParam",
array: ['1', '2', '3']
}
return ret
}
export type ParamCallback = (res : ParamOptions) => void
export type ArrayCallback = (res : Array<string>) => void
export function callbackArray(callback : ArrayCallback) {
callback(['8', '8', '8'])
}
export function callbackParam(callback : ParamCallback) {
let ret : ParamOptions = {
title: "callbackParam",
array: ['4', '5', '6']
}
callback(ret)
}
/**
* 打印测试方法
*/
export function logStrTest() {
console.log("logStrTest 字符串打印测试")
}
export function logFloatTest() {
console.log(3.1415926)
}
export function logIntTest() {
console.log(2023)
}
export function logObjectTest(){
let ret : ParamOptions = {
title: "logObjectTest",
array: ['1', '2', '3']
}
console.log(ret)
}
export function logFunctionTest(){
let testFun = function(){
console.log("testFun")
}
console.log(testFun)
}
export class User {
private name : string;
private age : Int;
constructor(hostP : string, port : Int) {
this.name = hostP;
this.age = port;
}
describeSelf():string{
let text = "name = " + this.name + ";age = " + `${this.age}`
return text
}
}
@@ -1,5 +0,0 @@
export function addViewToDecorView() { }
export function removeViewToDecorView() { }
export function initAppLifecycle() { }
export function getLogoPath() {}
export function playAssetAudio(){}
@@ -1,81 +0,0 @@
{
"id": "uni-alert",
"displayName": "uni-alert",
"version": "1.0.0",
"description": "uni-alert",
"keywords": [
"uni-alert"
],
"repository": "",
"engines": {
"HBuilderX": "^3.6.11"
},
"dcloudext": {
"type": "uts",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "",
"data": "",
"permissions": ""
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "u",
"aliyun": "u"
},
"client": {
"Vue": {
"vue2": "u",
"vue3": "u"
},
"App": {
"app-android": "u",
"app-ios": "u"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
},
"H5-pc": {
"Chrome": "u",
"IE": "u",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
},
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}
@@ -1,5 +0,0 @@
# uni-alert
### 开发文档
[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html)
[UTS 原生插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html)
[Hello UTS](https://gitcode.net/dcloud/hello-uts/-/tree/dev)
@@ -1,93 +0,0 @@
import Toast from 'android.widget.Toast';
import AlertDialog from 'android.app.AlertDialog';
import DialogInterface from 'android.content.DialogInterface';
import EditText from 'android.widget.EditText';
@UTSAndroid.Suppress("UNUSED_PARAMETER")
export function showAlert(_title : string | null, _message : string | null, _result : (index : Number) => void) {
let uiRunable = new DialogUIRunnable(null, _title!, _message!, "", false);
UTSAndroid.getUniActivity()!.runOnUiThread(uiRunable)
}
@UTSAndroid.Suppress("UNUSED_PARAMETER")
export function showPrompt(_title : string | null, _message : string | null, _placeholder : string | null, success : (content : string) => void) {
let uiRunable = new DialogUIRunnable(success, _title!, _message!, _placeholder!, true);
UTSAndroid.getUniActivity()!.runOnUiThread(uiRunable)
}
/**
* 用户输入对话框监听器
*/
class DialogListener implements DialogInterface.OnClickListener {
inputET : EditText
callback : (content : string) => void
constructor(et : EditText, cb : (content : string) => void) {
super();
this.callback = cb;
this.inputET = et;
}
override onClick(_dialog : DialogInterface, _arg1 : Int) : void {
//数据获取
let input = this.inputET.getText().toString()
this.callback(input);
Toast.makeText(UTSAndroid.getUniActivity(), input,
Toast.LENGTH_LONG).show();
}
}
/**
* Dialog ui任务封装
*/
class DialogUIRunnable implements Runnable {
callback ?: (content : string) => void = null
title : string
message : string
placeholder : string
needInput : boolean
constructor(success ?: (content : string) => void, title : string, message : string, placeholder : string, needInput : boolean) {
super();
if (success != null) {
this.callback = success
}
this.title = title
this.message = message
this.placeholder = placeholder
this.needInput = needInput
}
override run() : void {
if (this.needInput) {
let et = new EditText(UTSAndroid.getUniActivity());
et.setText(this.placeholder);
new AlertDialog.Builder(UTSAndroid.getUniActivity())
.setTitle(this.title)
.setMessage(this.message)
.setIcon(android.R.drawable.ic_dialog_info).setView(et)
.setPositiveButton("确定", new DialogListener(et, this.callback!))
.setNegativeButton("取消", null).show();
} else {
// new AlertDialog.Builder(UTSAndroid.getUniActivity())
// .setTitle(this.title)
// .setMessage(this.message)
// .setIcon(android.R.drawable.ic_dialog_info)
// .setNegativeButton("取消", null).show();
uni.showModal({
title:"测试弹窗"
})
}
}
};
@@ -1,63 +0,0 @@
import { UIAlertController , UIAlertAction , UITextField } from "UIKit"
import { UTSiOS } from "DCloudUTSFoundation"
import { DispatchQueue } from 'Dispatch';
export function showAlert(title: string|null, message: string|null, result: (index: Number) => void) {
// uts方法默认会在子线程中执行,涉及 UI 操作必须在主线程中运行,通过 DispatchQueue.main.async 方法可将代码在主线程中运行
DispatchQueue.main.async(execute=():void => {
// 初始化 UIAlertController 实例对象 alert
let alert = new UIAlertController(title=title,message=message,preferredStyle=UIAlertController.Style.alert)
// 创建 UIAlertAction 按钮
let okAction = new UIAlertAction(title="确认", style=UIAlertAction.Style.default, handler=(action: UIAlertAction):void => {
// 点击按钮的回调方法
result(0)
})
// 创建 UIAlertAction 按钮
let cancelAction = new UIAlertAction(title="取消", style=UIAlertAction.Style.cancel, handler=(action: UIAlertAction):void => {
// 点击按钮的回调方法
result(1)
})
// 将 UIAlertAction 添加到 alert 上
alert.addAction(okAction)
alert.addAction(cancelAction)
// 打开 alert 弹窗
UTSiOS.getCurrentViewController().present(alert, animated= true)
})
}
export function showPrompt(title: string|null, message: string|null,placeholder: string|null, result: (content: string)=>void) {
// uts方法默认会在子线程中执行,涉及 UI 操作必须在主线程中运行,通过 DispatchQueue.main.async 方法可将代码在主线程中运行
DispatchQueue.main.async(execute=():void => {
// 初始化 UIAlertController 实例对象 alert
let alert = new UIAlertController(title=title,message=message,preferredStyle=UIAlertController.Style.alert)
// 在 alert 上添加输入框
alert.addTextField(configurationHandler=(tf: UITextField):void => {
// 添加成功的回调
// 设置输入框的 placeholder
tf.placeholder = placeholder
})
// 创建 UIAlertAction 按钮
let okAction = new UIAlertAction(title="确认", style=UIAlertAction.Style.default, handler=(action: UIAlertAction):void => {
// 点击按钮的回调方法
// 获取输入框中的内容
let tf = alert.textFields?.[0]
if (tf != null) {
result(tf!.text != null ? tf!.text! : "没有输入任何内容")
}
})
// 将 UIAlertAction 添加到 alert 上
alert.addAction(okAction)
// 打开 alert 弹窗
UTSiOS.getCurrentViewController().present(alert, animated= true)
})
}
@@ -1,81 +0,0 @@
{
"id": "uts-animation-view",
"displayName": "uts-animation-view",
"version": "1.0.0",
"description": "uts-animation-view",
"keywords": [
"animation-view","uts-animation-view","lottie"
],
"repository": "",
"engines": {
"HBuilderX": "^3.94"
},
"dcloudext": {
"type": "uts",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "",
"data": "",
"permissions": ""
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "u",
"aliyun": "u"
},
"client": {
"Vue": {
"vue2": "u",
"vue3": "u"
},
"App": {
"app-android": "u",
"app-ios": "u"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
},
"H5-pc": {
"Chrome": "u",
"IE": "u",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
},
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}
@@ -1,5 +0,0 @@
# animation-view
### 开发文档
[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html)
[UTS 原生插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html)
[Hello UTS](https://gitcode.net/dcloud/hello-uts/-/tree/dev)
@@ -1,8 +0,0 @@
{
"dependencies": [
"com.airbnb.android:lottie:5.2.0",
"androidx.appcompat:appcompat:1.0.0"
],
"minSdkVersion": 21
}
@@ -1,20 +0,0 @@
/**
* 判断当前的基座是否已经集成了sdk, 即是否是自定义基座
*/
export function checkHasLottieIntegration():boolean{
let hasIntegration = true
try{
let xClass = Class.forName("com.airbnb.lottie.LottieDrawable")
console.log(xClass);
}catch(e:Exception){
hasIntegration = false;
}
if(!hasIntegration){
return false;
}
return true
}
@@ -1,214 +0,0 @@
<template>
<view class="defaultStyles">
</view>
</template>
<script lang="uts">
import Animator from 'android.animation.Animator'
import TextUtils from 'android.text.TextUtils'
import View from 'android.view.View'
import LottieAnimationView from 'com.airbnb.lottie.LottieAnimationView'
import LottieDrawable from 'com.airbnb.lottie.LottieDrawable'
import FileInputStream from 'java.io.FileInputStream'
class CustomAnimListener implements Animator.AnimatorListener {
comp: UTSComponent < LottieAnimationView >
constructor(com: UTSComponent < LottieAnimationView > ) {
super();
this.comp = com
}
override onAnimationStart(animation: Animator) {}
override onAnimationEnd(animation: Animator, isReverse: Boolean) {
this.comp.$emit("bindended")
}
override onAnimationEnd(animation: Animator) {}
override onAnimationCancel(animation: Animator) {}
override onAnimationRepeat(animation: Animator) {}
}
//原生提供以下属性或方法的实现
export default {
name: "uts-animation-view",
/**
* 当播放到末尾时触发 ended 事件(自然播放结束会触发回调,循环播放结束及手动停止动画不会触发)
*/
emits: ['bindended'],
props: {
/**
* 动画资源地址,目前只支持绝对路径
*/
"path": {
type: String,
default: ""
},
/**
* 动画是否自动播放
*/
"autoplay": {
type: Boolean,
default: false
},
/**
* 动画是否循环播放
*/
"loop": {
type: Boolean,
default: false
},
/**
* 是否隐藏动画
*/
"hidden": {
type: Boolean,
default: false
},
/**
* 动画操作,可取值 play、pause、stop
*/
"action": {
type: String,
default: "stop"
}
},
data() {
return {
}
},
watch: {
"path": {
handler(newPath: string) {
if(this.$el != null){
let lottieAnimationView = this.$el!
if (!TextUtils.isEmpty(newPath)) {
if (newPath.startsWith("http://") || newPath.startsWith("https://")) {
lottieAnimationView.setAnimationFromUrl(newPath)
} else {
// 正式打包会放在asset中,需要特殊处理
let realJsonPath = UTSAndroid.getResourcePath(newPath)
if(realJsonPath.startsWith("/android_asset")){
lottieAnimationView.setAnimation(realJsonPath.substring(15))
}else{
lottieAnimationView.setAnimation(new FileInputStream(realJsonPath),newPath)
}
}
}
if (this.autoplay) {
lottieAnimationView.playAnimation()
}
}
},
immediate: false
},
"loop": {
handler(newLoop: Boolean) {
if(this.$el != null){
if (newLoop) {
this.$el!.repeatCount = Int.MAX_VALUE
} else {
// 不循环则设置成1次
this.$el!.repeatCount = 0
}
if (this.autoplay) {
this.$el!.playAnimation()
}
}
},
immediate: false
},
"autoplay": {
handler(newValue: boolean) {
if(this.$el != null){
if (newValue) {
this.$el!.playAnimation()
}
}
},
immediate: false
},
"action": {
handler(newAction: string) {
if (newAction == "play" || newAction == "pause" || newAction == "stop") {
if(this.$el != null){
if (this.action == "play") {
this.$el!.playAnimation()
} else if (this.action == "pause") {
this.$el!.pauseAnimation()
} else if (this.action == "stop") {
this.$el!.cancelAnimation()
this.$el!.clearAnimation()
}
}
} else {
// 非法入参,不管
}
},
immediate: false
},
"hidden": {
handler(newValue: boolean) {
if(this.$el != null){
if (newValue) {
this.$el!.visibility = View.GONE
} else {
this.$el!.visibility = View.VISIBLE
}
}
},
immediate: false
},
},
methods: {
setRepeatMode(repeat: string) {
if(this.$el != null){
if ("RESTART" == repeat) {
this.$el!.repeatMode = LottieDrawable.RESTART
} else if ("REVERSE" == repeat) {
this.$el!.repeatMode = LottieDrawable.RESTART
}
}
},
},
NVLoad(): LottieAnimationView {
let lottieAnimationView = new LottieAnimationView($androidContext)
return lottieAnimationView
},
NVLoaded() {
if(this.$el != null){
this.$el!.repeatMode = LottieDrawable.RESTART;
this.$el!.visibility = View.GONE
this.$el!.repeatCount = 0
this.$el!.addAnimatorListener(new CustomAnimListener(this))
}
}
}
</script>
<style>
/* 定义默认样式值, 组件使用者没有配置时使用 */
.defaultStyles {
width: 750rpx;
height: 240rpx;
}
</style>

Some files were not shown because too many files have changed in this diff Show More