Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
820d5548
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看板
提交
820d5548
编写于
9月 01, 2022
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove .hx .vite folder
上级
3df5c928
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
461 addition
and
22 deletion
+461
-22
.gitignore
.gitignore
+2
-0
.hbuilderx/launch.json
.hbuilderx/launch.json
+0
-16
.vite/deps/package.json
.vite/deps/package.json
+0
-1
pages.json
pages.json
+8
-2
pages/SyntaxCase/index.vue
pages/SyntaxCase/index.vue
+319
-0
pages/advance/advance.vue
pages/advance/advance.vue
+10
-2
uni_modules/uni-getbatteryinfo/package.json
uni_modules/uni-getbatteryinfo/package.json
+1
-1
uni_modules/uni-getbatteryinfo/readme.md
uni_modules/uni-getbatteryinfo/readme.md
+23
-0
uni_modules/uts-syntaxcase/package.json
uni_modules/uts-syntaxcase/package.json
+9
-0
uni_modules/uts-syntaxcase/utssdk/app-android/index.uts
uni_modules/uts-syntaxcase/utssdk/app-android/index.uts
+86
-0
uni_modules/uts-syntaxcase/utssdk/app-android/utils.uts
uni_modules/uts-syntaxcase/utssdk/app-android/utils.uts
+3
-0
未找到文件。
.gitignore
浏览文件 @
820d5548
/unpackage
/.hbuilderx
/.vite
\ No newline at end of file
.hbuilderx/launch.json
已删除
100644 → 0
浏览文件 @
3df5c928
{
//
launch.json
配置了启动调试时相关设置,configurations下节点名称可为
app-plus/h
5
/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp
-360
/
//
launchtype项可配置值为local或remote
,
local代表前端连本地云函数,remote代表前端连云端云函数
"version"
:
"0.0"
,
"configurations"
:
[{
"app-plus"
:
{
"launchtype"
:
"local"
},
"default"
:
{
"launchtype"
:
"local"
},
"type"
:
"uniCloud"
}
]
}
.vite/deps/package.json
已删除
100644 → 0
浏览文件 @
3df5c928
{
"type"
:
"module"
}
\ No newline at end of file
pages.json
浏览文件 @
820d5548
...
...
@@ -8,7 +8,6 @@
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
}
},
{
...
...
@@ -18,7 +17,6 @@
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"pages/SystemAPI/SystemAPI"
,
...
...
@@ -55,6 +53,14 @@
"enablePullDownRefresh"
:
false
}
},{
"path"
:
"pages/SyntaxCase/index"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
}
}
],
...
...
pages/SyntaxCase/index.vue
0 → 100644
浏览文件 @
820d5548
<
template
>
<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=
"testAll"
>
点击测试所有
</button>
</
template
>
<
script
lang=
"ts"
setup
>
import
{
ref
,
reactive
}
from
"
vue
"
;
import
{
MAX
,
testSync
,
testSyncWithCallback
,
testAsync
,
Test
,
}
from
"
../../uni_modules/uts-syntaxcase
"
;
console
.
log
(
"
MAX
"
,
MAX
);
const
testUtsSyncResult
=
ref
<
boolean
|
null
>
(
null
);
interface
Result
{
return
:
boolean
|
null
;
success
:
boolean
|
null
;
fail
:
boolean
|
null
;
complete
:
boolean
|
null
;
}
const
testUtsSyncWithCallbackResult
=
reactive
<
Result
>
({
return
:
null
,
success
:
null
,
fail
:
null
,
complete
:
null
,
});
const
testUtsAsyncResult
=
reactive
<
Result
>
({
return
:
null
,
success
:
null
,
fail
:
null
,
complete
:
null
,
});
function
testAll
()
{
testUtsSync
();
testUtsSyncWithCallback
();
testUtsAsync
();
testUtsClassConstructor
();
testUtsClassStaticProp
();
testUtsClassStaticSyncWithCallback
();
testUtsClassStaticAsync
();
testUtsClassProp
();
testUtsClassSyncWithCallback
();
testUtsClassAsync
();
}
function
testUtsSync
()
{
testUtsSyncResult
.
value
=
false
;
try
{
if
(
testSync
(
"
dcloud
"
).
msg
===
"
hello dcloud
"
)
{
testUtsSyncResult
.
value
=
true
;
}
}
catch
(
e
)
{
console
.
error
(
"
testUtsSync
"
,
e
);
}
}
function
testUtsSyncWithCallback
()
{
try
{
testUtsSyncWithCallbackResult
.
return
=
false
;
testUtsSyncWithCallbackResult
.
success
=
false
;
// testUtsSyncWithCallbackResult.fail = false;
testUtsSyncWithCallbackResult
.
complete
=
false
;
if
(
testSyncWithCallback
({
type
:
"
success
"
,
success
(
res
)
{
console
.
log
(
"
testSyncWithCallback.success.callback
"
,
res
);
testUtsSyncWithCallbackResult
.
success
=
true
;
},
fail
(
res
)
{
console
.
log
(
"
testSyncWithCallback.fail.callback
"
,
res
);
// testUtsSyncWithCallbackResult.fail = true;
},
complete
(
res
)
{
console
.
log
(
"
testSyncWithCallback.complete.callback
"
,
res
);
testUtsSyncWithCallbackResult
.
complete
=
true
;
},
}).
name
===
"
testSyncWithCallback
"
)
{
testUtsSyncWithCallbackResult
.
return
=
true
;
}
}
catch
(
e
)
{
}
}
async
function
testUtsAsync
()
{
testUtsAsyncResult
.
return
=
false
;
testUtsAsyncResult
.
success
=
false
;
// testUtsAsyncResult.fail = false;
testUtsAsyncResult
.
complete
=
false
;
try
{
const
res
=
await
testAsync
({
type
:
"
success
"
,
success
(
res
)
{
console
.
log
(
"
testAsync.success.callback
"
,
res
);
testUtsAsyncResult
.
success
=
true
;
},
fail
(
res
)
{
console
.
log
(
"
testAsync.fail.callback
"
,
res
);
},
complete
(
res
)
{
console
.
log
(
"
testAsync.complete.callback
"
,
res
);
testUtsAsyncResult
.
complete
=
true
;
},
});
if
(
res
.
name
===
"
testAsync
"
)
{
testUtsAsyncResult
.
return
=
true
;
}
}
catch
(
e
)
{
}
}
function
format
(
v
:
boolean
|
null
)
{
return
v
==
null
?
"
--
"
:
v
?
"
通过
"
:
"
未通过
"
;
}
let
test
:
Test
let
id
=
0
const
testUtsClassConstructorResult
=
reactive
<
{
callback
:
boolean
|
null
}
>
({
callback
:
null
});
function
testUtsClassConstructor
()
{
testUtsClassConstructorResult
.
callback
=
false
id
++
test
=
new
Test
(
id
,
{
name
:
'
name
'
+
id
,
callback
:
(
res
)
=>
{
console
.
log
(
res
)
testUtsClassConstructorResult
.
callback
=
true
}
})
}
const
testUtsClassStaticPropResult
=
ref
<
boolean
|
null
>
(
null
);
function
testUtsClassStaticProp
()
{
testUtsClassStaticPropResult
.
value
=
false
if
(
Test
.
type
===
'
Test
'
)
{
testUtsClassStaticPropResult
.
value
=
true
}
}
const
testUtsClassStaticSyncWithCallbackResult
=
reactive
<
Result
>
({
return
:
null
,
success
:
null
,
fail
:
null
,
complete
:
null
,
});
function
testUtsClassStaticSyncWithCallback
()
{
try
{
testUtsClassStaticSyncWithCallbackResult
.
return
=
false
;
testUtsClassStaticSyncWithCallbackResult
.
success
=
false
;
// testUtsClassStaticSyncWithCallbackResult.fail = false;
testUtsClassStaticSyncWithCallbackResult
.
complete
=
false
;
if
(
Test
.
testClassStaticSyncWithCallback
({
type
:
"
success
"
,
success
(
res
)
{
console
.
log
(
"
testStaticSyncWithCallback.success.callback
"
,
res
);
testUtsClassStaticSyncWithCallbackResult
.
success
=
true
;
},
fail
(
res
)
{
console
.
log
(
"
testStaticSyncWithCallback.fail.callback
"
,
res
);
// testUtsClassStaticSyncWithCallbackResult.fail = true;
},
complete
(
res
)
{
console
.
log
(
"
testStaticSyncWithCallback.complete.callback
"
,
res
);
testUtsClassStaticSyncWithCallbackResult
.
complete
=
true
;
},
}).
name
===
"
testSyncWithCallback
"
)
{
testUtsClassStaticSyncWithCallbackResult
.
return
=
true
;
}
}
catch
(
e
)
{
}
}
const
testUtsClassStaticAsyncResult
=
reactive
<
Result
>
({
return
:
null
,
success
:
null
,
fail
:
null
,
complete
:
null
,
});
async
function
testUtsClassStaticAsync
()
{
testUtsClassStaticAsyncResult
.
return
=
false
;
testUtsClassStaticAsyncResult
.
success
=
false
;
// testUtsClassStaticAsyncResult.fail = false;
testUtsClassStaticAsyncResult
.
complete
=
false
;
try
{
const
res
=
await
Test
.
testClassStaticAsync
({
type
:
"
success
"
,
success
(
res
)
{
console
.
log
(
"
testAsync.success.callback
"
,
res
);
testUtsClassStaticAsyncResult
.
success
=
true
;
},
fail
(
res
)
{
console
.
log
(
"
testAsync.fail.callback
"
,
res
);
},
complete
(
res
)
{
console
.
log
(
"
testAsync.complete.callback
"
,
res
);
testUtsClassStaticAsyncResult
.
complete
=
true
;
},
});
if
(
res
.
name
===
"
testAsync
"
)
{
testUtsClassStaticAsyncResult
.
return
=
true
;
}
}
catch
(
e
)
{
}
}
const
testUtsClassPropResult
=
ref
<
boolean
|
null
>
(
null
);
function
testUtsClassProp
()
{
if
(
!
test
)
{
testUtsClassConstructor
()
}
testUtsClassPropResult
.
value
=
false
if
(
test
.
id
>
0
)
{
testUtsClassPropResult
.
value
=
true
}
}
const
testUtsClassSyncWithCallbackResult
=
reactive
<
Result
>
({
return
:
null
,
success
:
null
,
fail
:
null
,
complete
:
null
,
});
function
testUtsClassSyncWithCallback
()
{
if
(
!
test
)
{
testUtsClassConstructor
()
}
try
{
testUtsClassSyncWithCallbackResult
.
return
=
false
;
testUtsClassSyncWithCallbackResult
.
success
=
false
;
// testUtsClassSyncWithCallbackResult.fail = false;
testUtsClassSyncWithCallbackResult
.
complete
=
false
;
if
(
test
.
testClassSyncWithCallback
({
type
:
"
success
"
,
success
(
res
)
{
console
.
log
(
"
testSyncWithCallback.success.callback
"
,
res
);
testUtsClassSyncWithCallbackResult
.
success
=
true
;
},
fail
(
res
)
{
console
.
log
(
"
testSyncWithCallback.fail.callback
"
,
res
);
// testUtsClassSyncWithCallbackResult.fail = true;
},
complete
(
res
)
{
console
.
log
(
"
testSyncWithCallback.complete.callback
"
,
res
);
testUtsClassSyncWithCallbackResult
.
complete
=
true
;
},
}).
name
===
"
testSyncWithCallback
"
)
{
testUtsClassSyncWithCallbackResult
.
return
=
true
;
}
}
catch
(
e
)
{
}
}
const
testUtsClassAsyncResult
=
reactive
<
Result
>
({
return
:
null
,
success
:
null
,
fail
:
null
,
complete
:
null
,
});
async
function
testUtsClassAsync
()
{
if
(
!
test
)
{
testUtsClassConstructor
()
}
testUtsClassAsyncResult
.
return
=
false
;
testUtsClassAsyncResult
.
success
=
false
;
// testUtsClassAsyncResult.fail = false;
testUtsClassAsyncResult
.
complete
=
false
;
try
{
const
res
=
await
test
.
testClassAsync
({
type
:
"
success
"
,
success
(
res
)
{
console
.
log
(
"
testAsync.success.callback
"
,
res
);
testUtsClassAsyncResult
.
success
=
true
;
},
fail
(
res
)
{
console
.
log
(
"
testAsync.fail.callback
"
,
res
);
},
complete
(
res
)
{
console
.
log
(
"
testAsync.complete.callback
"
,
res
);
testUtsClassAsyncResult
.
complete
=
true
;
},
});
if
(
res
.
name
===
"
testAsync
"
)
{
testUtsClassAsyncResult
.
return
=
true
;
}
}
catch
(
e
)
{
}
}
</
script
>
pages/advance/advance.vue
浏览文件 @
820d5548
...
...
@@ -7,15 +7,19 @@
<button
type=
"primary"
@
tap=
"testClearInterval"
>
关闭定时任务
</button>
</view>
<view
class=
"uni-btn-v uni-common-mt"
>
<button
type=
"primary"
@
tap=
"testSyntax"
>
进阶语法示例
</button>
</view>
<view
class=
"uni-btn-v uni-common-mt"
>
<button
type=
"primary"
@
tap=
"testAddToDecorView"
>
添加TextView至视图顶层
</button>
<button
type=
"primary"
@
tap=
"testRemoveToDecorView"
>
移除视图顶层的TextView
</button>
<button
type=
"primary"
@
tap=
"testResource"
>
资源加载示例
</button>
<button
type=
"primary"
@
tap=
"testLifecyle"
>
activity生命周期监听
</button>
</view>
</view>
</
template
>
<
script
>
...
...
@@ -95,7 +99,11 @@
url
:
'
/pages/lifecycle/lifecycle
'
})
},
testSyntax
:
function
()
{
uni
.
navigateTo
({
url
:
'
/pages/SyntaxCase/index
'
})
},
}
}
...
...
uni_modules/uni-getbatteryinfo/package.json
浏览文件 @
820d5548
...
...
@@ -2,7 +2,7 @@
"id"
:
"uni-getbatteryinfo"
,
"displayName"
:
"uni-getbatteryinfo"
,
"version"
:
"1.0.0"
,
"description"
:
"使用uts开发,实现
在
多个平台获取电量信息"
,
"description"
:
"使用uts开发,实现多个平台获取电量信息"
,
"keywords"
:
[
"battery"
],
...
...
uni_modules/uni-getbatteryinfo/readme.md
浏览文件 @
820d5548
...
...
@@ -2,6 +2,8 @@
## 使用文档
```
ts
// 引用插件
import
getBatteryInfo
from
"
@/uni_modules/uni-getbatteryinfo
"
;
...
...
@@ -17,3 +19,24 @@
})
```
### 参数
Object object
|属性|类型|必填|说明|
|----|---|----|----|
|success|function|否|接口调用成功的回调函数|
|fail|function|否|接口调用失败的回调函数|
|complete|function|否|接口调用结束的回调函数(调用成功、失败都会执行)|
object.success 回调函数
|属性|类型|说明|
|----|---|----|
|level|number|设备电量,范围 1 - 100|
|isCharging|boolean|是否正在充电中|
uni_modules/uts-syntaxcase/package.json
0 → 100644
浏览文件 @
820d5548
{
"name"
:
"test-uts"
,
"id"
:
"test-uts"
,
"version"
:
"0.0.1"
,
"description"
:
"UTS示例插件"
,
"uni_modules"
:
{
"type"
:
"uts"
}
}
uni_modules/uts-syntaxcase/utssdk/app-android/index.uts
0 → 100644
浏览文件 @
820d5548
import
{
log
}
from
"./utils.uts"
;
type
AsyncOptions
=
{
type
:
string
;
success
:
(
res
:
string
)
=>
void
;
fail
:
(
res
:
string
)
=>
void
;
complete
:
(
res
:
string
)
=>
void
;
};
/**
* 导出一个属性
*/
export
const
MAX
=
100
;
/**
* 导出一个同步方法
* @returns
*/
export
function
testSync
(
msg
:
string
)
{
console
.
log
(
"log test"
);
log
(
"log test1"
);
return
{
msg
:
`hello ${msg}`
,
};
}
/**
* 导出一个同步方法(触发了数组越界异常)
*/
export
function
testSyncError
()
{
const
arr
:
string
[]
=
[];
console
.
log
(
arr
[
1
]);
}
/**
* 导出一个带callback的同步方法
* @param opts
*/
export
function
testSyncWithCallback
(
opts
:
AsyncOptions
)
{
if
(
opts
.
type
==
"success"
)
{
opts
.
success
(
"success"
);
}
else
{
opts
.
fail
(
"fail"
);
}
opts
.
complete
(
"complete"
);
return
{
name
:
"testSyncWithCallback"
};
}
/**
* 导出一个异步方法
* @returns
*/
export
async
function
testAsync
(
opts
:
AsyncOptions
)
{
if
(
opts
.
type
==
"success"
)
{
opts
.
success
(
"success"
);
}
else
{
opts
.
fail
(
"fail"
);
}
opts
.
complete
(
"complete"
);
return
{
name
:
"testAsync"
};
}
type
TestOptions
=
{
name
:
string
;
callback
:
(
res
:
string
)
=>
void
;
};
export
class
Test
{
id
:
number
;
name
:
string
;
static
type
:
string
=
"Test"
;
constructor
(
id
:
number
,
options
:
TestOptions
)
{
this
.
id
=
id
;
this
.
name
=
options
.
name
;
options
.
callback
(
"Test.constructor"
);
}
static
testClassStaticSyncWithCallback
(
opts
:
AsyncOptions
)
:
UTSJSONObject
{
return
testSyncWithCallback
(
opts
);
}
static
async
testClassStaticAsync
(
opts
:
AsyncOptions
)
:
Promise
<
UTSJSONObject
>
{
const
res
=
await
testAsync
(
opts
);
return
res
;
}
testClassSyncWithCallback
(
opts
:
AsyncOptions
)
:
UTSJSONObject
{
return
testSyncWithCallback
(
opts
);
}
async
testClassAsync
(
opts
:
AsyncOptions
)
:
Promise
<
UTSJSONObject
>
{
const
res
=
await
testAsync
(
opts
);
return
res
;
}
}
uni_modules/uts-syntaxcase/utssdk/app-android/utils.uts
0 → 100644
浏览文件 @
820d5548
export function log(msg: string) {
console.log(msg);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录