Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
5381b4ff
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1598
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看板
提交
5381b4ff
编写于
10月 11, 2023
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修復 hello-uts uniapp-x 模式下编译失败的问题
上级
9d01dd81
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
9 addition
and
501 deletion
+9
-501
pages/SyntaxCase/index.uvue
pages/SyntaxCase/index.uvue
+5
-441
pages/component/helloView.uvue
pages/component/helloView.uvue
+1
-5
pages/resource/fileRead.uvue
pages/resource/fileRead.uvue
+3
-55
未找到文件。
pages/SyntaxCase/index.uvue
浏览文件 @
5381b4ff
<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>
<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>
<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>暂时不支持2.0 语法调用测试</view>
</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'
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,
}
},
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
},
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) {}
},
// 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
},
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) {}
},
// 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
},
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() {
// 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>
<script>
</script>
\ No newline at end of file
pages/component/helloView.uvue
浏览文件 @
5381b4ff
<template>
<view>
<uts-hello-view buttonText="点击按钮内容" style="width:375px;height: 375px;background-color: aqua;"></uts-hello-view>
<uts-hello-container>
<text>文本组件</text>
<image src="../../static/logo.png" mode="aspectFit"></image>
</uts-hello-container>
暂时不支持 todo
</view>
</template>
...
...
pages/resource/fileRead.uvue
浏览文件 @
5381b4ff
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="getImageBase64">读取图片base64</button>
<button type="primary" @tap="getFileText">读取文本内容</button>
</view>
</view>
</template>
<script>
import {getFileSystemManager} from '@/uni_modules/uts-file-manager'
export default {
data() {
return {
title: '文件读取示例',
logo:""
title: '文件读取示例-todo',
}
},
methods: {
getImageBase64:function(e){
let fileManager = getFileSystemManager()
fileManager.readFile({
encoding:'base64',
filePath:'static/logo.png',
success:function(res){
console.log("success")
console.log(res)
},
fail:function(res){
console.log('fail')
console.log(res)
},
complete:function(res){
console.log("complete")
console.log(res)
}
})
},
getFileText:function(e){
let fileManager = getFileSystemManager()
fileManager.writeFile({
filePath:'/test/1.txt',
data:'锄禾日当午,汗滴禾下土,谁知盘中餐,粒粒皆辛苦',
success:function(res){
fileManager.readFile({
encoding:'utf-8',
filePath:res.filePath,
success:function(res){
console.log("success")
console.log(res)
},
fail:function(res){
console.log('fail')
},
complete:function(res){
console.log("complete")
}
})
},
fail:function(res){
console.log('fail')
},
complete:function(res){
console.log("complete")
}
})
}
}
}
</script>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录