Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
21bfe6e7
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看板
提交
21bfe6e7
编写于
8月 24, 2022
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify 进阶 tab
上级
54ec4951
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
184 addition
and
817 deletion
+184
-817
pages/tabBar/Advance/Advance.vue
pages/tabBar/Advance/Advance.vue
+69
-315
uni_modules/uts-advance/app-android/index.uts
uni_modules/uts-advance/app-android/index.uts
+25
-79
unpackage/dist/dev/app-plus/app-service.js
unpackage/dist/dev/app-plus/app-service.js
+70
-361
unpackage/dist/dev/app-plus/uni_modules/uts-advance/app-android/classes.dex
.../app-plus/uni_modules/uts-advance/app-android/classes.dex
+0
-0
unpackage/dist/dev/app-plus/uni_modules/uts-advance/app-android/index.kt
...dev/app-plus/uni_modules/uts-advance/app-android/index.kt
+19
-61
unpackage/dist/dev/app-plus/uni_modules/uts-advance/app-android/index.kt.map
...app-plus/uni_modules/uts-advance/app-android/index.kt.map
+1
-1
未找到文件。
pages/tabBar/Advance/Advance.vue
浏览文件 @
21bfe6e7
<
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>
<view>
<page-head
:title=
"title"
></page-head>
<view
class=
"uni-btn-v uni-common-mt"
>
<button
type=
"primary"
@
tap=
"testTimer"
>
延迟任务
</button>
<button
type=
"primary"
@
tap=
"testInterval"
>
定时任务
</button>
<button
type=
"primary"
@
tap=
"testClearInterval"
>
关闭定时任务
</button>
</view>
</view>
</
template
>
<
script
lang=
"ts"
setup
>
import
{
ref
,
reactive
}
from
"
vue
"
;
import
{
MAX
,
testSync
,
testSyncWithCallback
,
testAsync
,
Test
,
}
from
"
../../../uni_modules/uts-advance
"
;
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
)
{
}
}
<
script
>
import
{
doTimerTask
,
doIntervalTask
,
}
from
"
../../../uni_modules/uts-advance
"
;
export
default
{
data
()
{
return
{
title
:
'
UTS进阶示例
'
,
taskId
:
0
}
},
onUnload
:
function
(){
},
methods
:
{
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
);
},
}
}
</
script
>
const
testUtsClassPropResult
=
ref
<
boolean
|
null
>
(
null
);
function
testUtsClassProp
()
{
if
(
!
test
)
{
testUtsClassConstructor
()
}
testUtsClassPropResult
.
value
=
false
if
(
test
.
id
>
0
)
{
testUtsClassPropResult
.
value
=
true
}
}
<
style
>
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
>
</
style
>
uni_modules/uts-advance/app-android/index.uts
浏览文件 @
21bfe6e7
import { log } from "./utils.uts";
type
AsyncOptions
=
{
type
:
string
;
success
:
(
res
:
string
)
=>
void
;
fail
:
(
res
:
string
)
=>
void
;
complete
:
(
res
:
string
)
=>
void
;
type TimerOptions = {
start
: (res: string) => void;
work
: (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"
};
export function doTimerTask(opts:TimerOptions) {
opts.start('doTimerTask start');
setTimeout(function() {
opts.work("doTimerTask work");
}, 2000);
return { name: "doTimerTask" };
}
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
;
}
export function doIntervalTask(opts:TimerOptions) {
var taskRet = setInterval(function() {
opts.work("doIntervalTask work");
}, 2000);
opts.start('doIntervalTask start');
return { name: "doIntervalTask",taskId:taskRet};
}
unpackage/dist/dev/app-plus/app-service.js
浏览文件 @
21bfe6e7
此差异已折叠。
点击以展开。
unpackage/dist/dev/app-plus/uni_modules/uts-advance/app-android/classes.dex
浏览文件 @
21bfe6e7
无法预览此类型文件
unpackage/dist/dev/app-plus/uni_modules/uts-advance/app-android/index.kt
浏览文件 @
21bfe6e7
...
...
@@ -4,70 +4,28 @@ import kotlinx.coroutines.CoroutineScope;
import
kotlinx.coroutines.Deferred;
import
kotlinx.coroutines.Dispatchers;
import
io.dcloud.uts.*;
fun
log
(
msg
:
String
)
{
console
.
log
(
msg
,
"at uni_modules/uts-advance/app-android/utils.uts:2"
);
}
open
class
AsyncOptions
{
open
lateinit
var
type
:
String
;
open
lateinit
var
success
:
UTSCallback
;
open
lateinit
var
fail
:
UTSCallback
;
open
lateinit
var
complete
:
UTSCallback
;
}
val
MAX
=
100
;
fun
testSync
(
msg
:
String
):
UtsJSONObject
{
console
.
log
(
"log test"
,
"at uni_modules/uts-advance/app-android/index.uts:18"
);
log
(
"log test1"
);
open
class
TimerOptions
{
open
lateinit
var
start
:
UTSCallback
;
open
lateinit
var
work
:
UTSCallback
;
}
fun
doTimerTask
(
opts
:
TimerOptions
):
UtsJSONObject
{
opts
.
start
(
"doTimerTask start"
);
setTimeout
(
fun
()
{
opts
.
work
(
"doTimerTask work"
);
}
,
2000
);
return
object
:
UtsJSONObject
()
{
var
msg
=
"""hello ${msg}""
"
var
name
=
"doTimerTask
"
};
}
fun
testSyncError
()
{
val
arr
:
MutableList
<
String
>
=
mutableListOf
();
console
.
log
(
arr
[
1
],
"at uni_modules/uts-advance/app-android/index.uts:29"
);
}
fun
testSyncWithCallback
(
opts
:
AsyncOptions
):
UtsJSONObject
{
if
(
opts
.
type
==
"success"
)
opts
.
success
(
"success"
);
else
opts
.
fail
(
"fail"
);
opts
.
complete
(
"complete"
);
fun
doIntervalTask
(
opts
:
TimerOptions
):
UtsJSONObject
{
var
taskRet
=
setInterval
(
fun
()
{
opts
.
work
(
"doIntervalTask work"
);
}
,
2000
);
opts
.
start
(
"doIntervalTask start"
);
return
object
:
UtsJSONObject
()
{
var
name
=
"testSyncWithCallback"
};
}
suspend
fun
testAsync
(
opts
:
AsyncOptions
):
Deferred
<
UtsJSONObject
>
=
CoroutineScope
(
Dispatchers
.
Default
).
async
{
if
(
opts
.
type
==
"success"
)
opts
.
success
(
"success"
);
else
opts
.
fail
(
"fail"
);
opts
.
complete
(
"complete"
);
return
@async
object
:
UtsJSONObject
()
{
var
name
=
"testAsync"
var
name
=
"doIntervalTask"
var
taskId
=
taskRet
};
}
open
class
TestOptions
{
open
lateinit
var
name
:
String
;
open
lateinit
var
callback
:
UTSCallback
;
}
open
class
Test
{
open
var
id
:
Number
;
open
var
name
:
String
;
constructor
(
id
:
Number
,
options
:
TestOptions
){
this
.
id
=
id
;
this
.
name
=
options
.
name
;
options
.
callback
(
"Test.constructor"
);
}
open
fun
testClassSyncWithCallback
(
opts
:
AsyncOptions
):
UtsJSONObject
{
return
testSyncWithCallback
(
opts
);
}
open
suspend
fun
testClassAsync
(
opts
:
AsyncOptions
):
Deferred
<
UtsJSONObject
>
=
CoroutineScope
(
Dispatchers
.
Default
).
async
{
val
res
=
testAsync
(
opts
).
await
();
return
@async
res
;
}
companion
object
{
var
type
:
String
=
"Test"
;
fun
testClassStaticSyncWithCallback
(
opts
:
AsyncOptions
):
UtsJSONObject
{
return
testSyncWithCallback
(
opts
);
}
suspend
fun
testClassStaticAsync
(
opts
:
AsyncOptions
):
Deferred
<
UtsJSONObject
>
=
CoroutineScope
(
Dispatchers
.
Default
).
async
{
val
res
=
testAsync
(
opts
).
await
();
return
@async
res
;
}
}
}
unpackage/dist/dev/app-plus/uni_modules/uts-advance/app-android/index.kt.map
浏览文件 @
21bfe6e7
{
"version"
:
3
,
"sources"
:
[
"
\\\\
?
\\
D:
\\
Do
\\
Source
\\
hello-uts
\\
uni_modules
\\
uts-advance
\\
app-android
\\
utils.uts"
,
"
\\\\
?
\\
D:
\\
Do
\\
Source
\\
hello-uts
\\
uni_modules
\\
uts-advance
\\
app-android
\\
index.uts"
],
"sourcesContent"
:
[
"export function log(msg: string) {\n console.log(msg);
\n
}
\n
"
,
"import { log } from
\"
./utils.uts
\"
;
\n
type AsyncOptions = {\n type: string;
\n
success: (res: string) => void;
\n
fail: (res: string) => void;
\n
complete: (res: string) => void;
\n
};
\n
/**
\n
* 导出一个属性
\n
*/
\n
export const MAX = 100;
\n\n
/**
\n
* 导出一个同步方法
\n
* @returns
\n
*/
\n
export function testSync(msg: string) {\n console.log(
\"
log test
\"
);
\n
log(
\"
log test1
\"
);
\n
return {\n msg: `hello ${msg}`,
\n
};
\n
}
\n
/**
\n
* 导出一个同步方法(触发了数组越界异常)
\n
*/
\n
export function testSyncError() {\n const arr: string[] = [];
\n
console.log(arr[1]);
\n
}
\n
/**
\n
* 导出一个带callback的同步方法
\n
* @param opts
\n
*/
\n
export function testSyncWithCallback(opts: AsyncOptions) {\n if (opts.type ==
\"
success
\"
) {\n opts.success(
\"
success
\"
);
\n
} else {\n opts.fail(
\"
fail
\"
);
\n
}
\n
opts.complete(
\"
complete
\"
);
\n
return { name:
\"
testSyncWithCallback
\"
};
\n
}
\n
/**
\n
* 导出一个异步方法
\n
* @returns
\n
*/
\n
export async function testAsync(opts: AsyncOptions) {\n if (opts.type ==
\"
success
\"
) {\n opts.success(
\"
success
\"
);
\n
} else {\n opts.fail(
\"
fail
\"
);
\n
}
\n
opts.complete(
\"
complete
\"
);
\n
return { name:
\"
testAsync
\"
};
\n
}
\n\n
type TestOptions = {\n name: string;
\n
callback: (res: string) => void;
\n
};
\n\n
export class Test {\n id: number;
\n
name: string;
\n
static type: string =
\"
Test
\"
;
\n
constructor(id: number, options: TestOptions) {\n this.id = id;
\n
this.name = options.name;
\n
options.callback(
\"
Test.constructor
\"
);
\n
}
\n
static testClassStaticSyncWithCallback(opts: AsyncOptions): UtsJSONObject {\n return testSyncWithCallback(opts);
\n
}
\n
static async testClassStaticAsync(opts: AsyncOptions): Promise<UtsJSONObject> {\n const res = await testAsync(opts);
\n
return res;
\n
}
\n
testClassSyncWithCallback(opts: AsyncOptions): UtsJSONObject {\n return testSyncWithCallback(opts);
\n
}
\n
async testClassAsync(opts: AsyncOptions): Promise<UtsJSONObject> {\n const res = await testAsync(opts);
\n
return res;
\n
}
\n
}
\n
"
],
"names"
:
[],
"mappings"
:
";;;;;;AAAO,IAAS,GAAG,CAAC,GAAW,EAAN,MAAM,EAAE;IAC/B,OAAO,CAAC,GAAG,CAAC,GAAG,uDAAC,CAAC;;ACAC,WAAf,YAAY;IACf,kBAAA,IAAI,EAAE,MAAM,CAAC;IACb,kBAAA,OAAO,EAAA,WAAuB,CAAC;IAC/B,kBAAA,IAAI,EAAA,WAAuB,CAAC;IAC5B,kBAAA,QAAQ,EAAA,WAAuB,CAAC;CACjC,AAAC;AAIK,IAAM,GAAG,GAAG,GAAG,AAAC;AAMhB,IAAS,QAAQ,CAAC,GAAW,EAAN,MAAM,iBAAE;IACpC,OAAO,CAAC,GAAG,CAAC,UAAU,wDAAC,CAAC;IACxB,IAAI,WAAW,CAAC,CAAC;IACjB,OAAO;QACL,IAAA,GAAG,GAAE,GAAC,MAAM,EAAE,GAAG,CAAC,GAAC;KACpB,CAAC;;AAKG,IAAS,aAAa,GAAG;IAC9B,IAAM,GAAG,cAAE,MAAM,IAAK,eAAE,AAAC;IACzB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,wDAAC,CAAC;;AAMf,IAAS,oBAAoB,CAAC,IAAkB,EAAZ,YAAY,iBAAE;IACvD,IAAI,IAAI,CAAC,IAAI,IAAI,SAAS,EACxB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;SAExB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEpB,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC1B,OAAO;QAAE,IAAA,IAAI,GAAE,sBAAsB;KAAE,CAAC;;AAMnC,YAAe,SAAS,CAAC,IAAkB,EAAZ,YAAY,uEAAE;IAClD,IAAI,IAAI,CAAC,IAAI,IAAI,SAAS,EACxB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;SAExB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEpB,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC1B,aAAO;QAAE,IAAA,IAAI,GAAE,WAAW;KAAE,CAAC;;AAGZ,WAAd,WAAW;IACd,kBAAA,IAAI,EAAE,MAAM,CAAC;IACb,kBAAA,QAAQ,EAAA,WAAuB,CAAC;CACjC,AAAC;AAEK,WAAM,IAAI;IACf,SAAA,EAAE,EAAE,MAAM,CAAC;IACX,SAAA,IAAI,EAAE,MAAM,CAAC;IAEb,YAAY,EAAU,EAAN,MAAM,EAAE,OAAoB,EAAX,WAAW,CAAE;QAC5C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;;IASvC,SAAA,yBAAyB,CAAC,IAAkB,EAAZ,YAAY,GAAG,aAAa,CAAC;QAC3D,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC;;IAEpC,iBAAM,cAAc,CAAC,IAAkB,EAAZ,YAAY,GAAG,QAAO,CAAC,aAAa,8CAAE;QAC/D,IAAM,GAAG,GAAG,AAAM,SAAS,CAAC,IAAI,CAAC,QAAA,AAAC;QAClC,aAAO,GAAG,CAAC;;;QAlBb,IAAO,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;QAM7B,IAAO,+BAA+B,CAAC,IAAkB,EAAZ,YAAY,GAAG,aAAa,CAAC;YACxE,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC;;QAEpC,YAAa,oBAAoB,CAAC,IAAkB,EAAZ,YAAY,GAAG,QAAO,CAAC,aAAa,8CAAE;YAC5E,IAAM,GAAG,GAAG,AAAM,SAAS,CAAC,IAAI,CAAC,QAAA,AAAC;YAClC,aAAO,GAAG,CAAC;;;CASd"
}
\ No newline at end of file
{"version":3,"sources":["\\\\?\\D:\\Do\\Source\\hello-uts\\uni_modules\\uts-advance\\app-android\\index.uts"],"sourcesContent":["import { log } from \"./utils.uts\";\n\r\n\r\ntype TimerOptions = {\r\n start: (res: string) => void;\n work: (res: string) => void;\n};\r\n\r\n\r\n\nexport function doTimerTask(opts:TimerOptions) {\r\n\topts.start('doTimerTask start');\r\n\tsetTimeout(function() {\r\n\t\topts.work(\"doTimerTask work\");\r\n\t}, 2000);\n \n return { name: \"doTimerTask\" };\n}\r\n\r\n\r\nexport function doIntervalTask(opts:TimerOptions) {\r\n\t\r\n\tvar taskRet = setInterval(function() {\r\n\t\topts.work(\"doIntervalTask work\");\r\n\t}, 2000);\r\n\topts.start('doIntervalTask start');\r\n \n return { name: \"doIntervalTask\",taskId:taskRet};\n}\r\n\r\n\n\r\n"],"names":[],"mappings":";;;;;;AAGoB,WAAf,YAAY;IACf,kBAAA,KAAK,EAAA,WAAuB,CAAC;IAC7B,kBAAA,IAAI,EAAA,WAAuB,CAAC;CAC7B,AAAC;AAIK,IAAS,WAAW,CAAC,IAAiB,EAAZ,YAAY,iBAAE;IAC9C,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAChC,UAAU,CAAC,MAAW;QACrB,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;;IAC9B,EAAE,IAAI,CAAC,CAAC;IAER,OAAO;QAAE,IAAA,IAAI,GAAE,aAAa;KAAE,CAAC;;AAI1B,IAAS,cAAc,CAAC,IAAiB,EAAZ,YAAY,iBAAE;IAEjD,IAAI,OAAO,GAAG,WAAW,CAAC,MAAW;QACpC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;;IACjC,EAAE,IAAI,CAAC,AAAC;IACT,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAElC,OAAO;QAAE,IAAA,IAAI,GAAE,gBAAgB;QAAC,IAAA,MAAM,GAAC,OAAO;KAAC,CAAC"}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录