Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
7abc014a
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7abc014a
编写于
7月 14, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): update tests
上级
6e931a91
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
159 addition
and
4 deletion
+159
-4
packages/playground/uts/nativeplugins/test-uniplugin/android/index.ts
...yground/uts/nativeplugins/test-uniplugin/android/index.ts
+18
-0
packages/playground/uts/nativeplugins/test-uniplugin/android/src/io/dcloud/uniplugin/TestModule.uts
...-uniplugin/android/src/io/dcloud/uniplugin/TestModule.uts
+2
-2
packages/playground/uts/nativeplugins/test-uniplugin/android/uni-login.fun.ts
...uts/nativeplugins/test-uniplugin/android/uni-login.fun.ts
+10
-0
packages/playground/uts/nativeplugins/test-uniplugin/interface.fun.d.ts
...round/uts/nativeplugins/test-uniplugin/interface.fun.d.ts
+13
-0
packages/playground/uts/nativeplugins/test-uniplugin/interface.ts
.../playground/uts/nativeplugins/test-uniplugin/interface.ts
+19
-0
packages/playground/uts/nativeplugins/test-uniplugin/package.json
.../playground/uts/nativeplugins/test-uniplugin/package.json
+1
-0
packages/playground/uts/uni_modules/test-uniplugin/app-android/index.uts
...ound/uts/uni_modules/test-uniplugin/app-android/index.uts
+19
-0
packages/playground/uts/uni_modules/test-uniplugin/interface.uts
...s/playground/uts/uni_modules/test-uniplugin/interface.uts
+19
-0
packages/playground/uts/uni_modules/test-uniplugin/package.json
...es/playground/uts/uni_modules/test-uniplugin/package.json
+32
-0
packages/playground/uts/uni_modules/test-uniplugin/test.ts
packages/playground/uts/uni_modules/test-uniplugin/test.ts
+24
-0
packages/playground/uts/unpackage/nativeplugins/test-uniplugin-android/android/src/io/dcloud/uniplugin/TestModule.kt
...gin-android/android/src/io/dcloud/uniplugin/TestModule.kt
+2
-2
未找到文件。
packages/playground/uts/nativeplugins/test-uniplugin/android/index.ts
0 → 100644
浏览文件 @
7abc014a
import
IUniLogin
,
{
OnConnect
,
RegisterOptions
}
from
'
../interface
'
export
default
class
UniLogin
implements
IUniLogin
{
//@UniJSMethod({ uiThread: true })
login
(
name
:
string
,
code
:
number
)
{
console
.
log
(
name
,
code
)
}
// {"name":"fxy","callback1":{__type__:"fun",id:1},"callback2":{__type__:"fun",id:1}}
// => RegisterOptions
async
register
(
opts
:
RegisterOptions
)
{
opts
.
callback1
(
true
)
opts
.
callback2
(
true
)
opts
.
abc
.
callback3
(
true
)
}
onConnect
(
callback
:
OnConnect
)
{}
}
packages/playground/uts/nativeplugins/test-uniplugin/android/src/io/dcloud/uniplugin/TestModule.uts
浏览文件 @
7abc014a
...
...
@@ -4,12 +4,12 @@ import UniModule from "io.dcloud.feature.uniapp.common.UniModule";
import UniJSMethod from "io.dcloud.feature.uniapp.annotation.UniJSMethod";
import UniJSCallback from "io.dcloud.feature.uniapp.bridge.UniJSCallback";
import log from "./log";
export default class TestModule
extends UniModule()
{
export default class TestModule
implements UniLogin
{
TAG = "TestModule";
static REQUEST_CODE = 1000;
//run ui thread
@UniJSMethod({ uiThread: true })
testAsyncFunc(options: JSONObject, callback?: UniJSCallback) {
async
testAsyncFunc(options: JSONObject, callback?: UniJSCallback) {
log(this.TAG, "testAsyncFunc--$options");
if (callback != null) {
const data = new JSONObject();
...
...
packages/playground/uts/nativeplugins/test-uniplugin/android/uni-login.fun.ts
0 → 100644
浏览文件 @
7abc014a
import
{
login
as
Login
,
register
as
Register
}
from
'
../interface.fun
'
export
const
login
:
Login
=
(
name
,
code
)
=>
{
console
.
log
(
name
,
code
)
}
// import { login } from '@/uni_modules/uni-login'
// => const uniLogin = require('class')
// import { UniLogin, test } from '@/uni_modules/uni-login'
// new UniLogin()
packages/playground/uts/nativeplugins/test-uniplugin/interface.fun.d.ts
0 → 100644
浏览文件 @
7abc014a
import
{
RegisterOptions
,
OnConnect
}
from
'
./interface
'
export
interface
login
{
(
name
:
string
,
code
:
number
):
void
}
export
interface
register
{
(
opts
:
RegisterOptions
):
Promise
<
void
>
}
export
interface
onConnect
{
(
callback
:
OnConnect
):
void
}
packages/playground/uts/nativeplugins/test-uniplugin/interface.ts
0 → 100644
浏览文件 @
7abc014a
export
type
RegisterOptions
=
{
name
:
string
callback1
:
(
res
:
boolean
)
=>
void
callback2
:
(
res
:
boolean
)
=>
void
abc
:
{
callback3
:
(
res
:
boolean
)
=>
void
}
}
export
type
OnConnect
=
()
=>
void
export
default
interface
IUniLogin
{
login
:
(
name
:
string
,
code
:
number
)
=>
void
register
:
(
opts
:
RegisterOptions
)
=>
Promise
<
void
>
onConnect
:
(
callback
:
OnConnect
)
=>
void
}
// import UniLogin from '@uni_modules/uni-login'
// new UniLogin()
packages/playground/uts/nativeplugins/test-uniplugin/package.json
浏览文件 @
7abc014a
...
...
@@ -3,6 +3,7 @@
"id"
:
"DCloud-UTSPlugin"
,
"version"
:
"0.0.1"
,
"description"
:
"UTS示例插件"
,
"main"
:
"interface"
,
"_dp_type"
:
"nativeplugin"
,
"_dp_nativeplugin"
:{
"android"
:
{
...
...
packages/playground/uts/uni_modules/test-uniplugin/app-android/index.uts
0 → 100644
浏览文件 @
7abc014a
import IUniLogin, { OnConnect, RegisterOptions } from '../interface.uts'
export default class UniLogin implements IUniLogin {
//@UniJSMethod({ uiThread: true })
override login(name, code) {
console.log(name, code)
}
// {"name":"fxy","callback1":{__type__:"fun",id:1},"callback2":{__type__:"fun",id:1}}
// => RegisterOptions
async register(opts: RegisterOptions) {
opts.callback1(true)
opts.callback2(true)
opts.abc.callback3(true)
}
override onConnect(callback: OnConnect) {}
}
packages/playground/uts/uni_modules/test-uniplugin/interface.uts
0 → 100644
浏览文件 @
7abc014a
export type RegisterOptions = {
name: string
callback1: (res: boolean) => void
callback2: (res: boolean) => void
abc: {
callback3: (res: boolean) => void
}
}
export type OnConnect = () => void
export default interface IUniLogin {
login: (name: string, code: number) => void
register: (opts: RegisterOptions) => Promise<void>
onConnect: (callback: OnConnect) => void
}
// import UniLogin from '@uni_modules/uni-login'
// new UniLogin()
packages/playground/uts/uni_modules/test-uniplugin/package.json
0 → 100644
浏览文件 @
7abc014a
{
"name"
:
"UTS Plugin"
,
"id"
:
"DCloud-UTSPlugin"
,
"version"
:
"0.0.1"
,
"description"
:
"UTS示例插件"
,
"main"
:
"interface.uts"
,
"_dp_type"
:
"nativeplugin"
,
"_dp_nativeplugin"
:{
"android"
:
{
"plugins"
:
[
{
"type"
:
"module"
,
"name"
:
"DCloud-UTSPlugin"
,
"class"
:
"io.dcloud.uniplugin.TestModule"
},
{
"type"
:
"component"
,
"name"
:
"uts-richtext"
,
"class"
:
"io.dcloud.uniplugin.TestComponent"
}
],
"integrateType"
:
"uts"
,
"dependencies"
:[
{
"id"
:
"com.zzhoujay.richtext:richtext"
,
"source"
:
"implementation 'com.zzhoujay.richtext:richtext:3.0.7'"
}
],
"minSdkVersion"
:
21
}
}
}
\ No newline at end of file
packages/playground/uts/uni_modules/test-uniplugin/test.ts
0 → 100644
浏览文件 @
7abc014a
// 接口
interface
IUniLogin
{
login
():
void
}
// 父类/基类
class
BaseUniLogin
{
register
()
{}
}
// 子类实现
class
UniLogin
extends
BaseUniLogin
implements
IUniLogin
{
// 实现接口的方法,不能写 override 关键词,因为 override 关键词仅能在实现父类的属性或方法上使用
login
()
{}
// 实现或覆盖父类的方法,可写可不写 override
override
register
():
void
{}
}
async
function
testAsync
():
Promise
<
number
>
{
return
1
}
async
function
main
()
{
const
res
=
await
testAsync
()
return
res
}
packages/playground/uts/unpackage/nativeplugins/test-uniplugin-android/android/src/io/dcloud/uniplugin/TestModule.kt
浏览文件 @
7abc014a
...
...
@@ -5,10 +5,10 @@ import io.dcloud.feature.uniapp.common.UniModule;
import
io.dcloud.feature.uniapp.annotation.UniJSMethod;
import
io.dcloud.feature.uniapp.bridge.UniJSCallback;
import
io.dcloud.uniplugin.log.log;
open
class
TestModule
:
Uni
Module
()
{
open
class
TestModule
:
Uni
Login
{
open
var
TAG
=
"TestModule"
;
@UniJSMethod
(
uiThread
=
true
)
open
fun
testAsyncFunc
(
options
:
JSONObject
,
callback
:
UniJSCallback
?)
{
open
fun
async
testAsyncFunc
(
options
:
JSONObject
,
callback
:
UniJSCallback
?)
{
log
(
this
.
TAG
,
"testAsyncFunc--$options"
);
if
(
callback
!=
null
)
{
val
data
=
JSONObject
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录