Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
8f162371
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看板
提交
8f162371
编写于
7月 09, 2024
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
进阶语法测试页面支持uvue
上级
6a51990c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
447 addition
and
7 deletion
+447
-7
pages/SyntaxCase/index.uvue
pages/SyntaxCase/index.uvue
+447
-7
未找到文件。
pages/SyntaxCase/index.uvue
浏览文件 @
8f162371
<template>
<view>
<view>暂时不支持2.0 语法调用测试</view>
</view>
<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="testAll">点击测试所有</button>
</view>
<view style="height: 20px;"></view>
</scroll-view>
</template>
<script>
<script>
// #ifndef H5
import {
MAX,
testSync,
testSyncWithCallback,
testAsync,
AsyncOptions,
TestOptions,
SyncOptions,
testAsyncParam3,
Test,
request,
} 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
}
}
},
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();
},
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;
let option = new AsyncOptions(
"success",
(res:string) => {
console.log("testSyncWithCallback.success.callback", res);
this.testUtsSyncWithCallbackResult['success'] = true;
},
(res:string) => {
console.log("testSyncWithCallback.fail.callback", res);
// testUtsSyncWithCallbackResult.fail = true;
},
(res:string) => {
console.log("testSyncWithCallback.complete.callback", res);
this.testUtsSyncWithCallbackResult['complete'] = true;
},
)
if (
testSyncWithCallback(option)['name'] === "testSyncWithCallback"
// 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;
// },
// }).name === "testSyncWithCallback"
) {
this.testUtsSyncWithCallbackResult['return'] = true;
}
} catch (e) {}
},
async testUtsAsync():Promise<Void> {
this.testUtsAsyncResult['return'] = false;
this.testUtsAsyncResult['success'] = false;
// testUtsAsyncResult.fail = false;
this.testUtsAsyncResult['complete'] = false;
let option = new AsyncOptions(
"success",
(res:any) => {
console.log("testAsync.success.callback", res);
this.testUtsAsyncResult['success'] = true;
},
(res:any) => {
console.log("testAsync.fail.callback", res);
},
(res:any) => {
console.log("testAsync.complete.callback", res);
this.testUtsAsyncResult['complete'] = true;
},
)
try {
const res = await testAsync(option);
if (res.name === "testAsync") {
this.testUtsAsyncResult['return'] = true;
}
} catch (e) {}
return null
},
async testUtsAsyncMulitParam():Promise<Void> {
this.testUtsAsyncMulitParamResult['return'] = false;
this.testUtsAsyncMulitParamResult['success'] = false;
this.testUtsAsyncMulitParamResult['complete'] = false;
let option = AsyncOptions(
"success",
(res) => {
console.log("testUtsAsyncMulitParam.success.callback", res);
this.testUtsAsyncMulitParamResult['success'] = true;
},
(res) => {
console.log("testUtsAsyncMulitParam.fail.callback", res);
},
(res) => {
console.log("testUtsAsyncMulitParam.complete.callback", res);
this.testUtsAsyncMulitParamResult['complete'] = true;
},
)
try {
const res = await testAsyncParam3(100,"hello",option);
if (res.name === "testUtsAsyncMulitParam") {
this.testUtsAsyncMulitParamResult['return'] = true;
}
} catch (e) {}
return null
},
testUtsClassConstructor() {
this.testUtsClassConstructorResult['callback'] = false
id++
let option = TestOptions(
'name' + id,
(res) => {
console.log(res)
this.testUtsClassConstructorResult['callback'] = true
}
)
test = new Test(id, option)
},
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;
let option = AsyncOptions(
"success",
(res) => {
console.log("testStaticSyncWithCallback.success.callback", res);
this.testUtsClassStaticSyncWithCallbackResult['success'] = true;
},
(res) => {
console.log("testStaticSyncWithCallback.fail.callback", res);
// testUtsClassStaticSyncWithCallbackResult.fail = true;
},
(res) => {
console.log("testStaticSyncWithCallback.complete.callback", res);
this.testUtsClassStaticSyncWithCallbackResult['complete'] = true;
},
)
if (
Test.testClassStaticSyncWithCallback(option)['name'] === "testSyncWithCallback"
) {
this.testUtsClassStaticSyncWithCallbackResult['return'] = true;
}
} catch (e) {}
},
async testUtsClassStaticAsync():Promise<Void> {
this.testUtsClassStaticAsyncResult['return'] = false;
this.testUtsClassStaticAsyncResult['success'] = false;
this.testUtsClassStaticAsyncResult['complete'] = false;
let option = new AsyncOptions(
"success",
(res) => {
console.log("testAsync.success.callback", res);
this.testUtsClassStaticAsyncResult['success'] = true;
},
(res) => {
console.log("testAsync.fail.callback", res);
},
(res) => {
console.log("testAsync.complete.callback", res);
this.testUtsClassStaticAsyncResult['complete'] = true;
},
)
try {
const res = await Test.testClassStaticAsync(option);
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;
let option = new AsyncOptions(
"success",
(res) => {
console.log("testSyncWithCallback.success.callback", res);
this.testUtsClassSyncWithCallbackResult['success'] = true;
},
(res) => {
console.log("testSyncWithCallback.fail.callback", res);
// testUtsClassSyncWithCallbackResult.fail = true;
},
(res) => {
console.log("testSyncWithCallback.complete.callback", res);
this.testUtsClassSyncWithCallbackResult['complete'] = true;
},
)
if (
test!.testClassSyncWithCallback(option).name === "testSyncWithCallback"
) {
this.testUtsClassSyncWithCallbackResult['return'] = true;
}
} catch (e) {}
},
async testUtsClassAsync():Promise<Void> {
if (test == null) {
this.testUtsClassConstructor()
}
this.testUtsClassAsyncResult['return'] = false;
this.testUtsClassAsyncResult['success'] = false;
this.testUtsClassAsyncResult['complete'] = false;
let option = AsyncOptions(
"success",
(res) => {
console.log("testAsync.success.callback", res);
this.testUtsClassAsyncResult['success'] = true;
},
(res) => {
console.log("testAsync.fail.callback", res);
},
(res) => {
console.log("testAsync.complete.callback", res);
this.testUtsClassAsyncResult['complete'] = true;
},
)
try {
const res = await test!.testClassAsync(option);
console.log('res', res)
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;
}
})
let option = SyncOptions(
(res) => {
console.log("task.sync.success.callback", res);
this.testUtsClassInstanceResult['success'] = true;
},
(res) => {
console.log("task.sync.fail.callback", res);
},
(res) => {
console.log("task.sync.complete.callback", res);
this.testUtsClassInstanceResult['complete'] = true;
},
)
const res = task.sync(option)
if (res === 'sync') {
this.testUtsClassInstanceResult['return'] = true;
}
}
}
}
</script>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录