Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
9de6696c
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
9de6696c
编写于
11月 16, 2024
作者:
X
xty
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
uts dialogpage uni.$emit补充object类型测试例
上级
85b35ecb
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
332 addition
and
21 deletion
+332
-21
pages.json
pages.json
+7
-0
pages/API/dialog-page/uts-dialog-page.uvue
pages/API/dialog-page/uts-dialog-page.uvue
+29
-0
pages/API/event-bus/uts-event-bus.test.js
pages/API/event-bus/uts-event-bus.test.js
+19
-2
pages/API/event-bus/uts-event-bus.uvue
pages/API/event-bus/uts-event-bus.uvue
+53
-8
uni_modules/uts-dialogpage/changelog.md
uni_modules/uts-dialogpage/changelog.md
+0
-0
uni_modules/uts-dialogpage/package.json
uni_modules/uts-dialogpage/package.json
+82
-0
uni_modules/uts-dialogpage/readme.md
uni_modules/uts-dialogpage/readme.md
+6
-0
uni_modules/uts-dialogpage/utssdk/app-ios/config.json
uni_modules/uts-dialogpage/utssdk/app-ios/config.json
+3
-0
uni_modules/uts-dialogpage/utssdk/app-ios/index.uts
uni_modules/uts-dialogpage/utssdk/app-ios/index.uts
+65
-0
uni_modules/uts-dialogpage/utssdk/interface.uts
uni_modules/uts-dialogpage/utssdk/interface.uts
+6
-0
uni_modules/uts-dialogpage/utssdk/unierror.uts
uni_modules/uts-dialogpage/utssdk/unierror.uts
+39
-0
uni_modules/uts-eventbus/utssdk/app-ios/index.uts
uni_modules/uts-eventbus/utssdk/app-ios/index.uts
+23
-11
未找到文件。
pages.json
浏览文件 @
9de6696c
...
...
@@ -1932,6 +1932,13 @@
"navigationBarTitleText"
:
""
}
},
{
"path"
:
"pages/API/dialog-page/uts-dialog-page"
,
"style"
:
{
"navigationBarTitleText"
:
""
}
},
//
#endif
//
#ifdef
APP
{
...
...
pages/API/dialog-page/uts-dialog-page.uvue
0 → 100644
浏览文件 @
9de6696c
<template>
<view class="content">
<button @tap="doOpendDialogpage()">open dialogpage</button>
</view>
</template>
<script>
import { testOpenDialogPage, testCloseDialogPage } from '@/uni_modules/uts-dialogpage';
export default {
data() {
return {}
},
onLoad() {
},
methods: {
doOpendDialogpage() {
testOpenDialogPage("/pages/API/dialog-page/dialog-page")
}
}
}
</script>
<style>
.content {
flex: 1;
}
</style>
pages/API/event-bus/uts-event-bus.test.js
浏览文件 @
9de6696c
...
...
@@ -34,14 +34,31 @@ describe('event-bus', () => {
await
page
.
callMethod
(
'
JsOnUts
'
)
await
page
.
callMethod
(
'
emitFromUts
'
)
const
l1
=
(
await
page
.
data
()).
log
.
length
expect
(
l1
).
toBeGreaterThan
(
0
)
expect
(
l1
).
toBeGreaterThan
(
0
)
await
page
.
callMethod
(
'
clear
'
)
await
page
.
callMethod
(
'
emitUtsMessageUTSObject
'
)
const
data
=
await
page
.
data
()
console
.
log
(
data
)
expect
(
data
.
log
.
length
).
toBe
(
1
)
expect
(
data
.
log
[
0
].
name
).
toMatch
(
'
金运大厦
'
)
await
page
.
callMethod
(
'
clear
'
)
await
page
.
callMethod
(
'
emitUtsMessages
'
)
const
l12
=
(
await
page
.
data
()).
log
.
length
expect
(
l12
).
toBe
(
2
)
await
page
.
callMethod
(
'
clear
'
)
await
page
.
callMethod
(
'
emitUtsMessageNoArgument
'
)
const
l13
=
(
await
page
.
data
()).
log
.
length
expect
(
l13
).
toBe
(
0
)
await
page
.
callMethod
(
'
clear
'
)
await
page
.
callMethod
(
'
offUts
'
)
await
page
.
callMethod
(
'
emitFromUts
'
)
const
l2
=
(
await
page
.
data
()).
log
.
length
expect
(
l2
).
toBe
(
0
)
expect
(
l2
).
toBe
(
0
)
await
page
.
callMethod
(
'
clear
'
)
await
page
.
callMethod
(
'
UtsOnJS
'
)
...
...
pages/API/event-bus/uts-event-bus.uvue
浏览文件 @
9de6696c
...
...
@@ -4,11 +4,15 @@
<!-- #endif -->
<view>
<button @click="JsOnUts">1. js监听uts消息</button>
<button @click="emitFromUts">2. uts中触发监听</button>
<button @click="offUts">取消uts消息监听</button>
<button @click="emitFromUts">2. uts中触发监听</button>
<button @click="emitUtsMessageUTSObject">2.1 uts中触发监听(UTSJSONObject)</button>
<button @click="emitUtsMessages">2.2 uts中触发监听(多个参数)</button>
<button @click="emitUtsMessageNoArgument">2.3 uts中触发监听(无参数)</button>
<button @click="offUts">取消uts消息监听</button>
<button @click="UtsOnJS">1. uts监听js消息</button>
<button @click="emitFormJS">2 .js中触发监听</button>
<button @click="emitFormJS">2 .js中触发监听</button>
<button @click="emitFormJSObject">2.1 js中触发监听(UTSJSONObject)</button>
<button @click="offJs">取消js消息监听</button>
<button @click="clear">清空消息</button>
...
...
@@ -29,7 +33,10 @@
import {
onJsMessage,
offJsMessage,
emitUtsMessage,
emitUtsMessage,
emitUtsMessageUTSObject,
emitUtsMessageNoArgument,
emitUtsMessages,
getMessageChannel,
getRevJsMessage,
clearJsMessage,
...
...
@@ -44,10 +51,15 @@
}
},
methods: {
fn(res : string, res2 : string) {
console.log("on rev: " + res)
this.log.push(res)
this.log.push(res2)
fn(res : any, res2 : any) {
if (res != null){
console.log("on rev: " + JSON.stringify(res))
this.log.push(res)
}
if (res2 != null) {
console.log("on rev: " + JSON.stringify(res2))
this.log.push(res2)
}
},
fn2(res : string) {
this.log.push(res)
...
...
@@ -61,6 +73,25 @@
},
emitFromUts() {
emitUtsMessage("emit form uts")
},
emitUtsMessageUTSObject() {
emitUtsMessageUTSObject({
latitude: 39.951028,
longitude: 116.354662,
name: '金运大厦',
address: '西直门北大街xx号'
})
},
emitUtsMessages() {
emitUtsMessages({
latitude: 39.951028,
longitude: 116.354662,
name: '金运大厦',
address: '西直门北大街xx号'
}, "emit form uts")
},
emitUtsMessageNoArgument() {
emitUtsMessageNoArgument()
},
JsOnUtsOnce() {
uni.$once(getMessageChannel(), this.fn2)
...
...
@@ -82,6 +113,20 @@
if (msg && msg.length){
this.log.push(msg)
}
},
emitFormJSObject() {
clearJsMessage()
uni.$emit("JsMessage", {
latitude: 39.951028,
longitude: 116.354662,
name: '金运大厦form js',
address: '西直门北大街xx号 from js'
})
let msg = getRevJsMessage()
console.log("message:"+msg)
if (msg && msg.length){
this.log.push(msg)
}
},
clear() {
clearJsMessage()
...
...
uni_modules/uts-dialogpage/changelog.md
0 → 100644
浏览文件 @
9de6696c
uni_modules/uts-dialogpage/package.json
0 → 100644
浏览文件 @
9de6696c
{
"id"
:
"uts-dialogpage"
,
"displayName"
:
"uts-dialogpage"
,
"version"
:
"1.0.0"
,
"description"
:
"uts-dialogpage"
,
"keywords"
:
[
"uts-dialogpage"
],
"repository"
:
""
,
"engines"
:
{
"HBuilderX"
:
"^3.6.8"
},
"dcloudext"
:
{
"type"
:
"uts"
,
"sale"
:
{
"regular"
:
{
"price"
:
"0.00"
},
"sourcecode"
:
{
"price"
:
"0.00"
}
},
"contact"
:
{
"qq"
:
""
},
"declaration"
:
{
"ads"
:
""
,
"data"
:
""
,
"permissions"
:
""
},
"npmurl"
:
""
},
"uni_modules"
:
{
"dependencies"
:
[],
"encrypt"
:
[],
"platforms"
:
{
"cloud"
:
{
"tcb"
:
"u"
,
"aliyun"
:
"u"
,
"alipay"
:
"u"
},
"client"
:
{
"Vue"
:
{
"vue2"
:
"u"
,
"vue3"
:
"u"
},
"App"
:
{
"app-android"
:
"u"
,
"app-ios"
:
"u"
},
"H5-mobile"
:
{
"Safari"
:
"u"
,
"Android Browser"
:
"u"
,
"微信浏览器(Android)"
:
"u"
,
"QQ浏览器(Android)"
:
"u"
},
"H5-pc"
:
{
"Chrome"
:
"u"
,
"IE"
:
"u"
,
"Edge"
:
"u"
,
"Firefox"
:
"u"
,
"Safari"
:
"u"
},
"小程序"
:
{
"微信"
:
"u"
,
"阿里"
:
"u"
,
"百度"
:
"u"
,
"字节跳动"
:
"u"
,
"QQ"
:
"u"
,
"钉钉"
:
"u"
,
"快手"
:
"u"
,
"飞书"
:
"u"
,
"京东"
:
"u"
},
"快应用"
:
{
"华为"
:
"u"
,
"联盟"
:
"u"
}
}
}
}
}
\ No newline at end of file
uni_modules/uts-dialogpage/readme.md
0 → 100644
浏览文件 @
9de6696c
# uts-dialogpage
### 开发文档
[
UTS 语法
](
https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html
)
[
UTS API插件
](
https://uniapp.dcloud.net.cn/plugin/uts-plugin.html
)
[
UTS 组件插件
](
https://uniapp.dcloud.net.cn/plugin/uts-component.html
)
[
Hello UTS
](
https://gitcode.net/dcloud/hello-uts
)
\ No newline at end of file
uni_modules/uts-dialogpage/utssdk/app-ios/config.json
0 → 100644
浏览文件 @
9de6696c
{
"deploymentTarget"
:
"12"
}
uni_modules/uts-dialogpage/utssdk/app-ios/index.uts
0 → 100644
浏览文件 @
9de6696c
/**
* 引用 iOS 系统库,示例如下:
* import { UIDevice } from "UIKit";
* [可选实现,按需引入]
*/
// import {OpenDialogPageOptions,openDialogPage} from "DCloudUTSExtAPI";
/* 引入 interface.uts 文件中定义的变量 */
import { TestOpenDialogPage, TestCloseDialogPage } from '../interface.uts';
var curDialogPage : UniDialogPage | null = null
export const testOpenDialogPage : TestOpenDialogPage = function (url:string) {
// let utsJsonObj : DCloudUTSExtAPI.OpenDialogPageOptions = {
// url:"zhangsan"
// }
console.log("testOpenDialogPage")
// let option = new OpenDialogPageOptions({
// url:url
// })
let option = new OpenDialogPageOptions()
option.url = url
console.log(url)
option.animationType ="slide-in-left"
// option.parentPage = getCurrentPages()[0]
option.success = (arg : OpenDialogPageSuccess )=>{
console.log("success")
}
option.complete = (arg : OpenDialogPageComplete )=>{
console.log(arg)
}
option.fail = (arg : OpenDialogPageFail )=>{
console.log("fail")
}
curDialogPage = uni.openDialogPage(option)
}
export const testCloseDialogPage : TestCloseDialogPage = function () {
console.log("testCloseDialogPage")
if ( curDialogPage != null ){
let option = new CloseDialogPageOptions()
option.dialogPage = curDialogPage
option.success = (arg : CloseDialogPageSuccess )=>{
console.log("success")
}
option.complete = (arg : CloseDialogPageComplete )=>{
console.log(arg)
}
option.fail = (arg : CloseDialogPageFail )=>{
console.log("fail")
}
uni.closeDialogPage(option)
}
}
/**
* 更多插件开发的信息详见:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html
*/
uni_modules/uts-dialogpage/utssdk/interface.uts
0 → 100644
浏览文件 @
9de6696c
/**
* interface.uts
* uts插件接口定义文件,按规范定义接口文件可以在HBuilderX中更好的做到语法提示
*/
export type TestOpenDialogPage = (url:string)=>void
export type TestCloseDialogPage = ()=>void
\ No newline at end of file
uni_modules/uts-dialogpage/utssdk/unierror.uts
0 → 100644
浏览文件 @
9de6696c
/* 此规范为 uni 规范,可以按照自己的需要选择是否实现 */
import { MyApiErrorCode, MyApiFail } from "./interface.uts"
/**
* 错误主题
* 注意:错误主题一般为插件名称,每个组件不同,需要使用时请更改。
* [可选实现]
*/
export const UniErrorSubject = 'uts-api';
/**
* 错误信息
* @UniError
* [可选实现]
*/
export const MyAPIErrors : Map<MyApiErrorCode, string> = new Map([
/**
* 错误码及对应的错误信息
*/
[9010001, 'custom error mseeage1'],
[9010002, 'custom error mseeage2'],
]);
/**
* 错误对象实现
*/
export class MyApiFailImpl extends UniError implements MyApiFail {
/**
* 错误对象构造函数
*/
constructor(errCode : MyApiErrorCode) {
super();
this.errSubject = UniErrorSubject;
this.errCode = errCode;
this.errMsg = MyAPIErrors.get(errCode) ?? "";
}
}
uni_modules/uts-eventbus/utssdk/app-ios/index.uts
浏览文件 @
9de6696c
...
...
@@ -17,19 +17,30 @@ export function emitUtsMessage(arg : string) {
uni.$emit(MessageChannel, arg);
}
export function emitUtsMessageUTSObject(arg : UTSJSONObject) {
uni.$emit(MessageChannel, arg);
}
export function emitUtsMessages(arg : UTSJSONObject, arg2 : string ){
uni.$emit(MessageChannel, arg, arg2);
}
export function emitUtsMessageNoArgument(){
uni.$emit(MessageChannel);
}
var callbackId : NSNumber | null = null
export function onJsMessage (messageChannel : string ) {
revFromJS = ""
if (callbackId != null) {
uni.$off(messageChannel, callbackId!)
callbackId = null
callbackId
= null
}
callbackId = uni.$on(messageChannel, function (...spreadArgs : Any) {
if (spreadArgs.length > 0) {
let arg0 =
spreadArgs[0] as String | null
if (
arg0 != null ){
revFromJS = arg0!
;
let arg0 =
JSON.stringify(spreadArgs[0])
if (
typeof arg0 == "string" ) {
revFromJS = arg0!
}
}
})
...
...
@@ -39,20 +50,21 @@ export function onJsMessageOnce (messageChannel : string ) {
revFromJS = ""
uni.$once(messageChannel, function (...spreadArgs : Any) {
if (spreadArgs.length > 0) {
let arg0 =
spreadArgs[0] as String | null
if (
arg0 != null ){
revFromJS = arg0!
;
}
let arg0 =
JSON.stringify(spreadArgs[0])
if (
typeof arg0 == "string" ) {
revFromJS = arg0!
}
}
})
}
export function offJsMessage(messageChannel : string) {
if (callbackId != null) {
uni.$off(messageChannel, callbackId!)
uni.$off(messageChannel, callbackId!)
callbackId = null
}
}
export function clearJsMessage() {
revFromJS = ""
}
\ No newline at end of file
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录