Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
1f760b50
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1595
Star
27
Fork
9
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
2
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
Hello UTS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
2
Issue
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
1f760b50
编写于
8月 12, 2023
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(App): add scroll-view
上级
3561ff13
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
705 addition
and
653 deletion
+705
-653
pages/SyntaxCase/index.uvue
pages/SyntaxCase/index.uvue
+418
-369
pages/SyntaxCase/utsAndroid.uvue
pages/SyntaxCase/utsAndroid.uvue
+231
-229
pages/index/basicTest.uvue
pages/index/basicTest.uvue
+56
-55
未找到文件。
pages/SyntaxCase/index.uvue
浏览文件 @
1f760b50
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<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>
<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="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>
<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>
<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="testAll">点击测试所有</button>
<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="testAll">点击测试所有</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="ts">
import {
MAX,
testSync,
testSyncWithCallback,
testAsync,
Test,
request,
AsyncOptions,
TestOptions,
SyncOptions
} from "../../uni_modules/uts-syntaxcase";
const TRUE = 'true'
const FALSE = 'false'
const NULL = 'null'
import {
MAX,
testSync,
testSyncWithCallback,
testAsync,
Test,
request,
AsyncOptions,
TestOptions,
SyncOptions,
} from '../../uni_modules/uts-syntaxcase'
let test: Test | null = null
let id = 0
const TRUE = 'true'
const FALSE = 'false'
const NULL = 'null'
type TestResult = {
return ?: string,
success ?: string,
fail ?: string,
complete ?: string,
callback?: string,
prop?: string,
let test: Test | null = null
let id = 0
type TestResult = {
return?: string
success?: string
fail?: string
complete?: string
callback?: string
prop?: string
}
export default {
data() {
return {
// 'null' | 'true' | 'false'
testUtsSyncResult: 'null',
testUtsSyncWithCallbackResult: {
return: 'null',
success: 'null',
fail: 'null',
complete: 'null',
} as TestResult,
testUtsAsyncResult: {
return: 'null',
success: 'null',
fail: 'null',
complete: 'null',
} as TestResult,
testUtsClassConstructorResult: {
callback: 'null',
} as TestResult,
testUtsClassStaticPropResult: 'null',
testUtsClassStaticSyncWithCallbackResult: {
return: 'null',
success: 'null',
fail: 'null',
complete: 'null',
} as TestResult,
testUtsClassStaticAsyncResult: {
return: 'null',
success: 'null',
fail: 'null',
complete: 'null',
} as TestResult,
testUtsClassPropResult: 'null',
testUtsClassSyncWithCallbackResult: {
return: 'null',
success: 'null',
fail: 'null',
complete: 'null',
} as TestResult,
testUtsClassAsyncResult: {
return: 'null',
success: 'null',
fail: 'null',
complete: 'null',
} as TestResult,
testUtsClassInstanceResult: {
prop: 'null',
return: 'null',
success: 'null',
fail: 'null',
complete: 'null',
callback: 'null',
} as TestResult,
}
export default {
data() {
return {
// 'null' | 'true' | 'false'
testUtsSyncResult: 'null',
testUtsSyncWithCallbackResult: {
return: 'null',
success: 'null',
fail: 'null',
complete: 'null',
} as TestResult,
testUtsAsyncResult: {
return: 'null',
success: 'null',
fail: 'null',
complete: 'null',
} as TestResult,
testUtsClassConstructorResult: {
callback: 'null'
} as TestResult,
testUtsClassStaticPropResult: 'null',
testUtsClassStaticSyncWithCallbackResult: {
return: 'null',
success: 'null',
fail: 'null',
complete: 'null',
} as TestResult,
testUtsClassStaticAsyncResult: {
return: 'null',
success: 'null',
fail: 'null',
complete: 'null',
} as TestResult,
testUtsClassPropResult: 'null',
testUtsClassSyncWithCallbackResult: {
return: 'null',
success: 'null',
fail: 'null',
complete: 'null',
} as TestResult,
testUtsClassAsyncResult: {
return: 'null',
success: 'null',
fail: 'null',
complete: 'null',
} as TestResult,
testUtsClassInstanceResult: {
prop: 'null',
return: 'null',
success: 'null',
fail: 'null',
complete: 'null',
callback: 'null'
} as TestResult
}
},
methods: {
format(v: string | null) : string {
return v === "null" || v == null ? "--" : v === 'true' ? "通过" : "未通过";
},
methods: {
format(v: string | null): string {
return v === 'null' || v == null ? '--' : v === 'true' ? '通过' : '未通过'
},
testAll() {
this.testUtsSync()
this.testUtsSyncWithCallback()
// this.testUtsAsync();
this.testUtsClassConstructor()
this.testUtsClassStaticProp()
this.testUtsClassStaticSyncWithCallback()
// this.testUtsClassStaticAsync();
this.testUtsClassProp()
this.testUtsClassSyncWithCallback()
// this.testUtsClassAsync();
this.testUtsClassInstance()
},
testUtsSync() {
this.testUtsSyncResult = FALSE
try {
console.log('testSync("dcloud").msg', testSync('dcloud').msg)
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
},
testAll() {
this.testUtsSync();
this.testUtsSyncWithCallback();
// this.testUtsAsync();
this.testUtsClassConstructor();
this.testUtsClassStaticProp();
this.testUtsClassStaticSyncWithCallback();
// this.testUtsClassStaticAsync();
this.testUtsClassProp();
this.testUtsClassSyncWithCallback();
// this.testUtsClassAsync();
this.testUtsClassInstance();
fail: (res) => {
console.log('testSyncWithCallback.fail.callback', res)
// testUtsSyncWithCallbackResult.fail = TRUE;
},
testUtsSync() {
this.testUtsSyncResult = FALSE;
try {
console.log('testSync("dcloud").msg', testSync("dcloud").msg)
if (testSync("dcloud").msg == "hello dcloud") {
this.testUtsSyncResult = TRUE;
}
} catch (e) {
console.error("testUtsSync", e);
}
complete: (res) => {
console.log('testSyncWithCallback.complete.callback', res)
this.testUtsSyncWithCallbackResult.complete = TRUE
},
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;
},
} as AsyncOptions).name === "testSyncWithCallback"
) {
this.testUtsSyncWithCallbackResult.return = TRUE;
}
} catch (e) { }
} as AsyncOptions).name === 'testSyncWithCallback'
) {
this.testUtsSyncWithCallbackResult.return = TRUE
}
} catch (e) {}
},
// TODO uvue 暂不支持 async await
// 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;
// },
// } as AsyncOptions);
// if (res.name === "testAsync") {
// this.testUtsAsyncResult.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
},
} as TestOptions)
},
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
},
// TODO uvue 暂不支持 async await
// 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;
// },
// } as AsyncOptions);
// if (res.name === "testAsync") {
// this.testUtsAsyncResult.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
}
} as TestOptions)
fail: (res) => {
console.log('testStaticSyncWithCallback.fail.callback', res)
// testUtsClassStaticSyncWithCallbackResult.fail = TRUE;
},
testUtsClassStaticProp() {
this.testUtsClassStaticPropResult = FALSE
if (Test.type === 'Test') {
this.testUtsClassStaticPropResult = TRUE
}
complete: (res) => {
console.log('testStaticSyncWithCallback.complete.callback', res)
this.testUtsClassStaticSyncWithCallbackResult.complete = 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;
},
} as AsyncOptions).name === "testSyncWithCallback"
) {
this.testUtsClassStaticSyncWithCallbackResult.return = TRUE;
}
} catch (e) { }
} as AsyncOptions).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 != 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
// testUtsClassSyncWithCallbackResult.fail = FALSE;
this.testUtsClassSyncWithCallbackResult.complete = FALSE
if (
test!.testClassSyncWithCallback({
type: 'success',
success: (res) => {
console.log('testSyncWithCallback.success.callback', res)
this.testUtsClassSyncWithCallbackResult.success = TRUE
},
// 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 != null) {
this.testUtsClassConstructor()
}
this.testUtsClassPropResult = FALSE
if (test!.id > 0) {
this.testUtsClassPropResult = TRUE
}
fail: (res) => {
console.log('testSyncWithCallback.fail.callback', res)
// testUtsClassSyncWithCallbackResult.fail = TRUE;
},
testUtsClassSyncWithCallback() {
if (test != null) {
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;
},
} as AsyncOptions).name === "testSyncWithCallback"
) {
this.testUtsClassSyncWithCallbackResult.return = TRUE;
}
} catch (e) { }
complete: (res) => {
console.log('testSyncWithCallback.complete.callback', res)
this.testUtsClassSyncWithCallbackResult.complete = TRUE
},
// async testUtsClassAsync() {
// if (test != null) {
// 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 != null) {
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;
}
}
}
} as AsyncOptions).name === 'testSyncWithCallback'
) {
this.testUtsClassSyncWithCallbackResult.return = TRUE
}
}
</script>
\ No newline at end of file
} catch (e) {}
},
// async testUtsClassAsync() {
// if (test != null) {
// 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 != null) {
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
}
}
},
},
}
</script>
pages/SyntaxCase/utsAndroid.uvue
浏览文件 @
1f760b50
<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="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>
<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>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<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="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>
<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>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
import {
getAppContextTest,
getUniActivityTest,
getAppTempPathTest,
typeofClickTest,
gotoSystemPermissionActivityTest,
arrayPermissionFlowTest,
singlePermissionFlowTest,
dispatchAsyncTest,
convert2AbsFullPathTest,
unRegLifecycle,
initAppLifecycle,
gotoCameraTake,
getDeviceInfoTest,
privacyStateTest
} from '@/uni_modules/uts-platform-api'
import {
getAppContextTest,
getUniActivityTest,
getAppTempPathTest,
typeofClickTest,
gotoSystemPermissionActivityTest,
arrayPermissionFlowTest,
singlePermissionFlowTest,
dispatchAsyncTest,
convert2AbsFullPathTest,
unRegLifecycle,
initAppLifecycle,
gotoCameraTake,
getDeviceInfoTest,
privacyStateTest,
} from '@/uni_modules/uts-platform-api'
/**
* 测试在页面生命周期之外,使用api
*/
export default {
data() {
return {
text: '',
selectImage: '',
}
},
onLoad: function () {
let that = this
initAppLifecycle(function (eventLog) {
// 展示捕捉到的声明周期日志
let nextLine = that.text + eventLog
that.text = nextLine
let nextLineFlag = that.text + '\n'
that.text = nextLineFlag
})
},
methods: {
privacyStateClick() {
privacyStateTest(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()
},
getAppContextClick() {
if (getAppContextTest()) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败',
})
}
},
/**
* 测试在页面生命周期之外,使用api
*/
export default {
data() {
return {
text: '',
selectImage:''
}
},
onLoad:function(){
let that = this;
initAppLifecycle(function(eventLog){
// 展示捕捉到的声明周期日志
let nextLine = that.text + eventLog;
that.text = nextLine;
let nextLineFlag = that.text + '\n';
that.text = nextLineFlag
});
},
methods: {
privacyStateClick(){
privacyStateTest(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();
},
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: '测试失败',
})
}
},
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
})
}
})
}
}
}
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>
\ No newline at end of file
.testButton {
width: 100%;
}
</style>
pages/index/basicTest.uvue
浏览文件 @
1f760b50
<template>
<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
>
<!-- #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>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="ts">
import {
runTests,
Result
} from '../../uni_modules/uts-tests'
import { runTests, Result } from '../../uni_modules/uts-tests'
export default {
data() {
return {
title: 'UTS基础语法',
resultArray: [] as Result[],
result: {} as UTSJSONObject,
names: [] as string[]
}
},
onReady() {
this.test()
},
methods: {
test() {
this.result = runTests()
const resultMap = this.result.toMap()
resultMap.forEach((res, name) => {
this.names.push(name)
this.resultArray.push(res as Result)
})
}
}
export default {
data() {
return {
title: 'UTS基础语法',
resultArray: [] as Result[],
result: {} as UTSJSONObject,
names: [] as string[],
}
},
onReady() {
this.test()
},
methods: {
test() {
this.result = runTests()
const resultMap = this.result.toMap()
resultMap.forEach((res, name) => {
this.names.push(name)
this.resultArray.push(res as Result)
})
},
},
}
</script>
<style>
@import '@/common/uni-uvue.css';
.content {
min-height: 100%;
padding: 32rpx;
}
<style>
@import '@/common/uni-uvue.css';
.content {
min-height: 100%;
padding: 32rpx;
}
.passed {
color: green;
}
.passed {
color: green;
}
.failed {
color: red;
}
.failed {
color: red;
}
.result {
margin-bottom: 20rpx;
}
</style>
\ No newline at end of file
.result {
margin-bottom: 20rpx;
}
</style>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录