Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
6fe36ca3
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看板
提交
6fe36ca3
编写于
7月 08, 2024
作者:
dcloud_wdl
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/alpha'
上级
531659aa
b0c0f736
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
176 addition
and
21 deletion
+176
-21
AndroidManifest.xml
AndroidManifest.xml
+9
-0
changelog.md
changelog.md
+6
-0
manifest.json
manifest.json
+2
-2
package.json
package.json
+1
-1
pages.json
pages.json
+1
-3
pages/SyntaxCase/utsAndroid.uvue
pages/SyntaxCase/utsAndroid.uvue
+10
-3
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
浏览文件 @
6fe36ca3
...
...
@@ -16,5 +16,14 @@
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
</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>
</manifest>
changelog.md
浏览文件 @
6fe36ca3
## 1.0.19
*
update 4.23.2024070309-alpha
## 1.0.17
*
update 4.22.2024062415-alpha
## 1.0.16
*
update 4.21.2024061818-alpha
...
...
manifest.json
浏览文件 @
6fe36ca3
...
...
@@ -2,8 +2,8 @@
"name"
:
"HelloUTS"
,
"appid"
:
"__UNI__70BE9D0"
,
"description"
:
""
,
"versionName"
:
"1.
0.9
"
,
"versionCode"
:
"1
09
"
,
"versionName"
:
"1.
1.0
"
,
"versionCode"
:
"1
10
"
,
"transformPx"
:
false
,
"uni-app-x"
:
{},
/*
5
+App特有相关
*/
...
...
package.json
浏览文件 @
6fe36ca3
...
...
@@ -2,7 +2,7 @@
"id"
:
"hello-uts-alpha"
,
"name"
:
"hello-uts-alpha"
,
"displayName"
:
"hello-uts-alpha"
,
"version"
:
"1.0.1
6
"
,
"version"
:
"1.0.1
9
"
,
"description"
:
"UTS插件示例项目"
,
"repository"
:
"https://gitcode.net/dcloud/hello-uts"
,
"keywords"
:
[
...
...
pages.json
浏览文件 @
6fe36ca3
...
...
@@ -158,7 +158,7 @@
}
//
#endif
//
#ifdef
APP
-Android
//
#ifdef
APP
,
{
"path"
:
"pages/SyntaxCase/utsAndroid"
,
...
...
@@ -168,8 +168,6 @@
}
}
//
#endif
//
#ifdef
APP-iOS
,
{
"path"
:
"pages/SyntaxCase/utsiOS"
,
...
...
pages/SyntaxCase/utsAndroid.uvue
浏览文件 @
6fe36ca3
<template>
<!--
#ifdef APP-ANDROID -->
<!--
#ifdef APP-ANDROID -->
<scroll-view style="flex: 1">
<view>
<view class="uni-padding-wrap uni-common-mt">
...
...
@@ -60,6 +60,7 @@
</template>
<script>
// #ifdef APP-ANDROID
import {
getAppContextTest,
getUniActivityTest,
...
...
@@ -77,6 +78,8 @@
getDeviceInfoTest,
privacyStateTest
} from '@/uni_modules/uts-platform-api'
// #endif
// #ifdef APP-ANDROID
import {
UTSAcvitiyLifeCycleCallback,
...
...
@@ -86,15 +89,15 @@
UTSActivityComponentCallback,
onCallbackChange
} from '@/uni_modules/uts-syntaxcase'
// #endif
import File from 'java.io.File';
import Intent from 'android.content.Intent';
// #endif
/**
* 测试在页面生命周期之外,使用api
*/
*/
export default {
data() {
return {
...
...
@@ -111,6 +114,7 @@
},
onLoad: function () {
// #ifdef APP-ANDROID
let that = this
initAppLifecycle(function (eventLog) {
// 展示捕捉到的声明周期日志
...
...
@@ -119,8 +123,10 @@
let nextLineFlag = that.text + '\n'
that.text = nextLineFlag
})
// #endif
},
methods: {
// #ifdef APP-ANDROID
privacyStateClick() {
privacyStateTest(function (ret, desc) {
if (ret) {
...
...
@@ -314,6 +320,7 @@
}
})
},
// #endif
// #ifdef APP-ANDROID
// #ifdef UNI-APP-X
activityCallback() {
...
...
uni_modules/uts-hello-component/utssdk/app-android/container.vue
浏览文件 @
6fe36ca3
...
...
@@ -4,15 +4,39 @@
</view>
</
template
>
<
script
lang=
"uts"
>
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
{
name
:
"
uts-hello-container
"
,
NVLoad
():
LinearLayout
{
let
contentLayout
=
new
LinearLayout
(
$androidContext
)
let
contentLayout
=
new
CustomLinearLayout
(
$androidContext
!
)
contentLayout
.
orientation
=
LinearLayout
.
VERTICAL
;
return
contentLayout
}
...
...
uni_modules/uts-hello-component/utssdk/app-android/index.vue
浏览文件 @
6fe36ca3
...
...
@@ -125,7 +125,10 @@
* [可选实现]
*/
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布局完成
...
...
uni_modules/uts-nativepage/utssdk/app-android/CustomAccessibilityService.uts
浏览文件 @
6fe36ca3
...
...
@@ -15,13 +15,10 @@ export class CustomAccessibilityService extends AccessibilityService {
override onAccessibilityEvent(event:AccessibilityEvent ):void {
if(event == null){
return ;
}
console.log("packagename",event!.getPackageName())
if("io.dcloud.uniappx" == event!.getPackageName()){
console.log("packagename",event.getPackageName())
if("io.dcloud.uniappx" == event.getPackageName()){
console.log("辅助服务消息:uniappx 基座打开")
}else if("io.dcloud.HBuilder" == event
!
.getPackageName()){
}else if("io.dcloud.HBuilder" == event.getPackageName()){
console.log("辅助服务消息:HBuilder 基座被打开")
}
}
...
...
uni_modules/uts-nativepage/utssdk/app-android/index.uts
浏览文件 @
6fe36ca3
...
...
@@ -382,7 +382,8 @@ function initShortCut() {
shortcutBuilder2.setIcon(IconCompat.createWithResource(UTSAndroid.getAppContext()!, R.drawable.icon_short))
shortcutBuilder2.setIntent(
new Intent(
"uts.sdk.modules.demo"
Intent.ACTION_VIEW,
Uri.parse("appuniappx://market/111")
)
)
let shortcut2 = shortcutBuilder2.build()
...
...
uni_modules/uts-tests/utssdk/JSON.uts
浏览文件 @
6fe36ca3
...
...
@@ -319,6 +319,13 @@ export function testJSON() : Result {
a: 1
}.toMap()
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', () => {
...
...
uni_modules/uts-tests/utssdk/Number.uts
浏览文件 @
6fe36ca3
...
...
@@ -59,7 +59,63 @@ export function testNumber() : Result {
expect(isFinite(1000 / 1)).toEqual(true);
expect(isFinite(910)).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', () => {
expect(Number.isInteger(12)).toEqual(true);
expect(Number.isInteger(12.01)).toEqual(false);
...
...
@@ -69,6 +125,15 @@ export function testNumber() : Result {
test('isNaN', () => {
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', () => {
...
...
uni_modules/uts-tests/utssdk/UTSJSONObject.uts
浏览文件 @
6fe36ca3
...
...
@@ -26,6 +26,24 @@ export function testUTSJSONObject() : Result {
// #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', () => {
// #ifdef APP-ANDROID
type User = {
...
...
uni_modules/uts-tests/utssdk/console.uts
浏览文件 @
6fe36ca3
import { describe, test, expect, expectNumber, Result } from './tests.uts'
function obtainInnerObject(obj:Any | null):UTSJSONObject{
let jsonStr = console.getLogV2(obj).slice(19,-17)
let a = JSON.parseArray(jsonStr)![0]
...
...
@@ -14,8 +13,29 @@ export function testConsole() : Result {
expect(obtainInnerObject(0.9).get("type")).toEqual("Double");
expect(obtainInnerObject(0.9).get("subType")).toEqual("number");
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
}
)
})
})
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录