Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
765d571d
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看板
提交
765d571d
编写于
6月 25, 2024
作者:
DCloud-yyl
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into alpha
上级
f3b6fdad
3de775b0
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
158 addition
and
14 deletion
+158
-14
AndroidManifest.xml
AndroidManifest.xml
+9
-0
manifest.json
manifest.json
+2
-2
uni_modules/uts-hello-component/utssdk/app-android/container.vue
...ules/uts-hello-component/utssdk/app-android/container.vue
+25
-1
uni_modules/uts-hello-component/utssdk/app-android/index.vue
uni_modules/uts-hello-component/utssdk/app-android/index.vue
+4
-1
uni_modules/uts-nativepage/utssdk/app-android/CustomAccessibilityService.uts
...ivepage/utssdk/app-android/CustomAccessibilityService.uts
+3
-6
uni_modules/uts-nativepage/utssdk/app-android/index.uts
uni_modules/uts-nativepage/utssdk/app-android/index.uts
+2
-1
uni_modules/uts-tests/utssdk/JSON.uts
uni_modules/uts-tests/utssdk/JSON.uts
+7
-0
uni_modules/uts-tests/utssdk/Number.uts
uni_modules/uts-tests/utssdk/Number.uts
+65
-0
uni_modules/uts-tests/utssdk/UTSJSONObject.uts
uni_modules/uts-tests/utssdk/UTSJSONObject.uts
+18
-0
uni_modules/uts-tests/utssdk/console.uts
uni_modules/uts-tests/utssdk/console.uts
+23
-3
未找到文件。
AndroidManifest.xml
浏览文件 @
765d571d
...
@@ -16,5 +16,14 @@
...
@@ -16,5 +16,14 @@
<category
android:name=
"android.intent.category.DEFAULT"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
</intent-filter>
</activity>
</activity>
<!--meta-data-->
<activity
android:name=
"io.dcloud.uniapp.UniLaunchProxyActivity"
android:exported=
"true"
>
<intent-filter>
<action
android:name=
"android.intent.action.VIEW"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<category
android:name=
"android.intent.category.BROWSABLE"
/>
<data
android:scheme=
"appuniappx"
/>
</intent-filter>
</activity>
</application>
</application>
</manifest>
</manifest>
manifest.json
浏览文件 @
765d571d
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
"name"
:
"HelloUTS"
,
"name"
:
"HelloUTS"
,
"appid"
:
"__UNI__70BE9D0"
,
"appid"
:
"__UNI__70BE9D0"
,
"description"
:
""
,
"description"
:
""
,
"versionName"
:
"1.
0.9
"
,
"versionName"
:
"1.
1.0
"
,
"versionCode"
:
"1
09
"
,
"versionCode"
:
"1
10
"
,
"transformPx"
:
false
,
"transformPx"
:
false
,
"uni-app-x"
:
{},
"uni-app-x"
:
{},
/*
5
+App特有相关
*/
/*
5
+App特有相关
*/
...
...
uni_modules/uts-hello-component/utssdk/app-android/container.vue
浏览文件 @
765d571d
...
@@ -4,15 +4,39 @@
...
@@ -4,15 +4,39 @@
</view>
</view>
</
template
>
</
template
>
<
script
lang=
"uts"
>
<
script
lang=
"uts"
>
import
LinearLayout
from
'
android.widget.LinearLayout
'
import
LinearLayout
from
'
android.widget.LinearLayout
'
import
Context
from
'
android.content.Context
'
import
View
from
'
android.view.View
'
/**
* 自定义android布局组件,可以实现监听显示状态等复杂的功能
*/
class
CustomLinearLayout
extends
LinearLayout
{
constructor
(
context
:
Context
)
{
super
(
context
)
}
override
onWindowVisibilityChanged
(
visibility
:
kotlin
.
Int
){
if
(
visibility
==
View
.
VISIBLE
){
console
.
log
(
"
可见状态
"
,
visibility
)
}
else
if
(
visibility
==
INVISIBLE
||
visibility
==
GONE
){
console
.
log
(
"
不可见状态
"
,
visibility
)
}
}
}
//原生提供以下属性或方法的实现
//原生提供以下属性或方法的实现
export
default
{
export
default
{
name
:
"
uts-hello-container
"
,
name
:
"
uts-hello-container
"
,
NVLoad
():
LinearLayout
{
NVLoad
():
LinearLayout
{
let
contentLayout
=
new
LinearLayout
(
$androidContext
)
let
contentLayout
=
new
CustomLinearLayout
(
$androidContext
!
)
contentLayout
.
orientation
=
LinearLayout
.
VERTICAL
;
contentLayout
.
orientation
=
LinearLayout
.
VERTICAL
;
return
contentLayout
return
contentLayout
}
}
...
...
uni_modules/uts-hello-component/utssdk/app-android/index.vue
浏览文件 @
765d571d
...
@@ -125,7 +125,10 @@
...
@@ -125,7 +125,10 @@
* [可选实现]
* [可选实现]
*/
*/
NVLoaded
()
{
NVLoaded
()
{
// 组件内可以调用 UTSAndroid 内置方法
console
.
log
(
"
UTSAndroid.devicePX2px(1080) :
"
,
UTSAndroid
.
devicePX2px
(
1080
))
console
.
log
(
"
UTSAndroid.rpx2px(1080) :
"
,
UTSAndroid
.
rpx2px
(
1080
))
console
.
log
(
"
UTSAndroid.appJSBundleUrl() :
"
,
UTSAndroid
.
appJSBundleUrl
())
},
},
/**
/**
* 原生View布局完成
* 原生View布局完成
...
...
uni_modules/uts-nativepage/utssdk/app-android/CustomAccessibilityService.uts
浏览文件 @
765d571d
...
@@ -15,13 +15,10 @@ export class CustomAccessibilityService extends AccessibilityService {
...
@@ -15,13 +15,10 @@ export class CustomAccessibilityService extends AccessibilityService {
override onAccessibilityEvent(event:AccessibilityEvent ):void {
override onAccessibilityEvent(event:AccessibilityEvent ):void {
if(event == null){
console.log("packagename",event.getPackageName())
return ;
if("io.dcloud.uniappx" == event.getPackageName()){
}
console.log("packagename",event!.getPackageName())
if("io.dcloud.uniappx" == event!.getPackageName()){
console.log("辅助服务消息:uniappx 基座打开")
console.log("辅助服务消息:uniappx 基座打开")
}else if("io.dcloud.HBuilder" == event
!
.getPackageName()){
}else if("io.dcloud.HBuilder" == event.getPackageName()){
console.log("辅助服务消息:HBuilder 基座被打开")
console.log("辅助服务消息:HBuilder 基座被打开")
}
}
}
}
...
...
uni_modules/uts-nativepage/utssdk/app-android/index.uts
浏览文件 @
765d571d
...
@@ -382,7 +382,8 @@ function initShortCut() {
...
@@ -382,7 +382,8 @@ function initShortCut() {
shortcutBuilder2.setIcon(IconCompat.createWithResource(UTSAndroid.getAppContext()!, R.drawable.icon_short))
shortcutBuilder2.setIcon(IconCompat.createWithResource(UTSAndroid.getAppContext()!, R.drawable.icon_short))
shortcutBuilder2.setIntent(
shortcutBuilder2.setIntent(
new Intent(
new Intent(
"uts.sdk.modules.demo"
Intent.ACTION_VIEW,
Uri.parse("appuniappx://market/111")
)
)
)
)
let shortcut2 = shortcutBuilder2.build()
let shortcut2 = shortcutBuilder2.build()
...
...
uni_modules/uts-tests/utssdk/JSON.uts
浏览文件 @
765d571d
...
@@ -319,6 +319,13 @@ export function testJSON() : Result {
...
@@ -319,6 +319,13 @@ export function testJSON() : Result {
a: 1
a: 1
}.toMap()
}.toMap()
expect(map.get('a')).toEqual(1)
expect(map.get('a')).toEqual(1)
const json = `{"result":true, "count":42}`;
const obj = JSON.parse(json) as UTSJSONObject;
let retStr = JSON.stringify(obj)
// #ifdef APP-ANDROID
expect(retStr).toEqual('{"result":true,"count":42}')
// #endif
})
})
test('parse Map', () => {
test('parse Map', () => {
...
...
uni_modules/uts-tests/utssdk/Number.uts
浏览文件 @
765d571d
...
@@ -59,7 +59,63 @@ export function testNumber() : Result {
...
@@ -59,7 +59,63 @@ export function testNumber() : Result {
expect(isFinite(1000 / 1)).toEqual(true);
expect(isFinite(1000 / 1)).toEqual(true);
expect(isFinite(910)).toEqual(true);
expect(isFinite(910)).toEqual(true);
expect(isFinite(0)).toEqual(true);
expect(isFinite(0)).toEqual(true);
// #ifdef APP-ANDROID
let aj2 = JSON.parse('{"a":1}') as UTSJSONObject;
let aNumber = aj2['a'] as UTSNumber
expect(isFinite(aNumber)).toEqual(true);
expect(UTSNumber.isFinite(aNumber)).toEqual(true);
expect(UTSNumber.isFinite(11.00)).toEqual(true);
expect(UTSNumber.isFinite(Double.POSITIVE_INFINITY)).toEqual(false);
// #endif
})
})
test('number-from-json-parse', () => {
type A = {
a:number
}
let aj = JSON.parse<A>('{"a":1}');
expect(aj?.a == 1).toEqual(true);
expect(aj?.a == 1 as number).toEqual(true);
expect(aj?.a == 1.0).toEqual(true);
expect(aj?.a == 1.0 as number).toEqual(true);
// #ifdef APP-ANDROID
expect(aj?.a === 1).toEqual(true);
expect(aj?.a === 1 as number).toEqual(true);
expect(aj?.a === 1.0).toEqual(true);
expect(aj?.a === 1.0 as number).toEqual(true);
let ki:Int = 1;
let kd:Double = 1.0;
let kf:Float = (1.0).toFloat();
expect(aj?.a == ki).toEqual(true);
expect(aj?.a == kd).toEqual(true);
expect(aj?.a == kf).toEqual(true);
expect(aj?.a === ki).toEqual(true);
expect(aj?.a === kd).toEqual(true);
expect(aj?.a === kf).toEqual(true);
// 对比JSON.parse 和 new 得到的对象属性
let newA = A(1)
expect(aj?.a == newA.a).toEqual(true);
expect(aj?.a === newA.a).toEqual(true);
newA.a = 1.0
expect(aj?.a == newA.a).toEqual(true);
expect(aj?.a === newA.a).toEqual(true);
newA.a = 1.1
expect(aj?.a == newA.a).toEqual(false);
expect(aj?.a === newA.a).toEqual(false);
let a10 = JSON.parse("10")
let b10 = JSON.parse("10")
let c10 = JSON.parse("10.0")
expect(a10 == b10).toEqual(true);
expect(a10 == c10).toEqual(true);
let aj2 = JSON.parse<A>('{"a":1}');
expect(aj?.a == aj2?.a).toEqual(true);
// #endif
})
test('isInteger', () => {
test('isInteger', () => {
expect(Number.isInteger(12)).toEqual(true);
expect(Number.isInteger(12)).toEqual(true);
expect(Number.isInteger(12.01)).toEqual(false);
expect(Number.isInteger(12.01)).toEqual(false);
...
@@ -69,6 +125,15 @@ export function testNumber() : Result {
...
@@ -69,6 +125,15 @@ export function testNumber() : Result {
test('isNaN', () => {
test('isNaN', () => {
expect(isNaN(0)).toEqual(false);
expect(isNaN(0)).toEqual(false);
// #ifdef APP-ANDROID
let aj2 = JSON.parse('{"a":1}') as UTSJSONObject;
let aNumber = aj2['a'] as UTSNumber
expect(isNaN(aNumber)).toEqual(false);
expect(UTSNumber.isNaN(aNumber)).toEqual(false);
expect(UTSNumber.isNaN(11)).toEqual(false);
expect(UTSNumber.isNaN(null)).toEqual(false);
expect(UTSNumber.isNaN(1 / 0)).toEqual(false);
// #endif
})
})
test('toPrecision', () => {
test('toPrecision', () => {
...
...
uni_modules/uts-tests/utssdk/UTSJSONObject.uts
浏览文件 @
765d571d
...
@@ -26,6 +26,24 @@ export function testUTSJSONObject() : Result {
...
@@ -26,6 +26,24 @@ export function testUTSJSONObject() : Result {
// #endif
// #endif
})
})
test('setvalue-after-get', () => {
// #ifdef APP-ANDROID
let obj = {
"cars":[
{
name:"car1",
value:100
}
]
}
let cars = obj.getArray<UTSJSONObject>("cars")
cars![0].set("value",20)
let firstCar = obj.getJSON("cars[0]")
expect(firstCar!['value']).toEqual(20);
// #endif
})
test('assign-withtype', () => {
test('assign-withtype', () => {
// #ifdef APP-ANDROID
// #ifdef APP-ANDROID
type User = {
type User = {
...
...
uni_modules/uts-tests/utssdk/console.uts
浏览文件 @
765d571d
import { describe, test, expect, expectNumber, Result } from './tests.uts'
import { describe, test, expect, expectNumber, Result } from './tests.uts'
function obtainInnerObject(obj:Any | null):UTSJSONObject{
function obtainInnerObject(obj:Any | null):UTSJSONObject{
let jsonStr = console.getLogV2(obj).slice(19,-17)
let jsonStr = console.getLogV2(obj).slice(19,-17)
let a = JSON.parseArray(jsonStr)![0]
let a = JSON.parseArray(jsonStr)![0]
...
@@ -14,8 +13,29 @@ export function testConsole() : Result {
...
@@ -14,8 +13,29 @@ export function testConsole() : Result {
expect(obtainInnerObject(0.9).get("type")).toEqual("Double");
expect(obtainInnerObject(0.9).get("type")).toEqual("Double");
expect(obtainInnerObject(0.9).get("subType")).toEqual("number");
expect(obtainInnerObject(0.9).get("subType")).toEqual("number");
expect(obtainInnerObject(0.9).get("value")).toEqual("0.9");
expect(obtainInnerObject(0.9).get("value")).toEqual("0.9");
// #endif
// #ifdef UNI-APP-X && APP-ANDROID
let pageInstance = new io.dcloud.uniapp.vue.ComponentInternalInstance()
expect(obtainInnerObject(pageInstance).get("className")).toEqual("io.dcloud.uniapp.vue.ComponentInternalInstance");
expect(obtainInnerObject(pageInstance).get("type")).toEqual("object");
// #endif
})
test('console-number-from-JSON-parse', () => {
// #ifdef APP-ANDROID
let aj2 = JSON.parse('{"a":1}') as UTSJSONObject;
console.log(aj2!['a'])
expect(obtainInnerObject(aj2!['a']).get("type")).toEqual("number");
expect(obtainInnerObject(aj2!['a']).get("subType")).toEqual("number");
// #endif
// #endif
}
)
})
})
})
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录