Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-api
提交
5acb4df9
U
uni-api
项目概览
DCloud
/
uni-api
通知
670
Star
23
Fork
12
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-api
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
5acb4df9
编写于
10月 27, 2023
作者:
taohebin@dcloud.io
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into alpha
上级
50d0aaf3
00b4e27a
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
126 addition
and
41 deletion
+126
-41
.hbuilderx/launch.json
.hbuilderx/launch.json
+3
-2
uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts
uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts
+3
-2
uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts
uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts
+1
-3
uni_modules/uni-getbatteryinfo/utssdk/interface.uts
uni_modules/uni-getbatteryinfo/utssdk/interface.uts
+13
-1
uni_modules/uni-getbatteryinfo/utssdk/unierror.uts
uni_modules/uni-getbatteryinfo/utssdk/unierror.uts
+34
-0
uni_modules/uni-installApk/changelog.md
uni_modules/uni-installApk/changelog.md
+2
-0
uni_modules/uni-installApk/package.json
uni_modules/uni-installApk/package.json
+1
-1
uni_modules/uni-installApk/utssdk/app-android/index.uts
uni_modules/uni-installApk/utssdk/app-android/index.uts
+3
-2
uni_modules/uni-installApk/utssdk/interface.uts
uni_modules/uni-installApk/utssdk/interface.uts
+41
-30
uni_modules/uni-installApk/utssdk/unierror.uts
uni_modules/uni-installApk/utssdk/unierror.uts
+25
-0
未找到文件。
.hbuilderx/launch.json
浏览文件 @
5acb4df9
...
...
@@ -14,8 +14,9 @@
},
{
"bundleId"
:
"io.dcloud.test123456"
,
"certificateFile"
:
"/Users/lizhongyi/Desktop/文件/证书/dev_123.p12"
,
"certificateProfileFile"
:
"/Users/lizhongyi/Desktop/文件/证书/io_dcloud_test123456.mobileprovision"
,
"certificateFile"
:
"/Users/lizhongyi/Desktop/newProfiles/dev_123.p12"
,
"certificateProfileFile"
:
"/Users/lizhongyi/Desktop/newProfiles/wildcard.mobileprovision"
,
"runSignStatus"
:
1
,
"type"
:
"uni-app:app-ios"
}
]
...
...
uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts
浏览文件 @
5acb4df9
...
...
@@ -5,6 +5,7 @@ import { GetBatteryInfo, GetBatteryInfoOptions, GetBatteryInfoSuccess, GetBatter
import IntentFilter from 'android.content.IntentFilter';
import Intent from 'android.content.Intent';
import { GetBatteryInfoFailImpl } from '../unierror';
/**
* 异步获取电量
...
...
@@ -33,8 +34,8 @@ export const getBatteryInfo : GetBatteryInfo = function (options : GetBatteryInf
}
options.success?.(res)
options.complete?.(res)
} else {
const res = new UniError("uni-getBatteryInfo", 1001, "getBatteryInfo:fail getAppContext is null")
} else {
let res = new GetBatteryInfoFailImpl(1001);
options.fail?.(res)
options.complete?.(res)
}
...
...
uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts
浏览文件 @
5acb4df9
// 引用 iOS 原生平台 api
import { UIDevice } from "UIKit";
import { Int } from 'Swift';
import { GetBatteryInfo, GetBatteryInfoSuccess, GetBatteryInfoResult, GetBatteryInfoSync } from '../interface.uts';
/**
* 导出 获取电量方法
*/
...
...
@@ -15,7 +13,7 @@ export const getBatteryInfo : GetBatteryInfo = function (options) {
// 返回数据
const res : GetBatteryInfoSuccess = {
errMsg: "getBatteryInfo:ok",
level:
new Int
(UIDevice.current.batteryLevel * 100),
level:
Number
(UIDevice.current.batteryLevel * 100),
isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,
};
options.success?.(res);
...
...
uni_modules/uni-getbatteryinfo/utssdk/interface.uts
浏览文件 @
5acb4df9
...
...
@@ -55,7 +55,19 @@ export type GetBatteryInfoResult = {
* 是否正在充电中
*/
isCharging : boolean
}
}
/**
* 错误码
* - 1001 getAppContext is null
*/
export type GetBatteryInfoErrorCode = 1001 ;
/**
* myApi 的错误回调参数
*/
export interface GetBatteryInfoFail extends IUniError {
errCode : GetBatteryInfoErrorCode
};
/**
* 获取电量信息
...
...
uni_modules/uni-getbatteryinfo/utssdk/unierror.uts
0 → 100644
浏览文件 @
5acb4df9
import { GetBatteryInfoErrorCode, GetBatteryInfoFail } from "./interface.uts"
/**
* 错误主题
*/
export const UniErrorSubject = 'uni-getBatteryInfo';
/**
* 错误信息
* @UniError
*/
export const UniErrors : Map<GetBatteryInfoErrorCode, string> = new Map([
/**
* 错误码及对应的错误信息
*/
[1001, 'getBatteryInfo:fail getAppContext is null'],
]);
/**
* 错误对象实现
*/
export class GetBatteryInfoFailImpl extends UniError implements GetBatteryInfoFail {
/**
* 错误对象构造函数
*/
constructor(errCode : GetBatteryInfoErrorCode) {
super();
this.errSubject = UniErrorSubject;
this.errCode = errCode;
this.errMsg = UniErrors[errCode] ?? "";
}
}
\ No newline at end of file
uni_modules/uni-installApk/changelog.md
浏览文件 @
5acb4df9
## 1.0.3(2023-10-27)
遵循UniError规范
## 1.0.2(2023-10-27)
修改文档
## 1.0.1(2023-10-27)
...
...
uni_modules/uni-installApk/package.json
浏览文件 @
5acb4df9
{
"id"
:
"uni-installApk"
,
"displayName"
:
"uni-installApk"
,
"version"
:
"1.0.
2
"
,
"version"
:
"1.0.
3
"
,
"description"
:
"uni-installApk"
,
"keywords"
:
[
"uni-installApk"
...
...
uni_modules/uni-installApk/utssdk/app-android/index.uts
浏览文件 @
5acb4df9
import { InstallApkOptions, InstallApkSuccess } from "../interface.uts"
import { InstallApkOptions, InstallApkSuccess } from "../interface.uts"
import { InstallApkFailImpl } from "../unierror.uts"
import Intent from 'android.content.Intent';
import Build from 'android.os.Build';
import File from 'java.io.File';
...
...
@@ -11,7 +12,7 @@ export function installApk(options : InstallApkOptions) : void {
const filePath = UTSAndroid.convert2AbsFullPath(options.filePath)
const apkFile = new File(filePath)
if (!apkFile.exists() && !apkFile.isFile()) {
let error = new
UniError("uni-installApk", -1, "filePath is illegal");
let error = new
InstallApkFailImpl(1300002);
options.fail?.(error)
options.complete?.(error)
return
...
...
uni_modules/uni-installApk/utssdk/interface.uts
浏览文件 @
5acb4df9
export interface Uni {
/**
* installApk()
* @description
* 安装apk
* @param {InstallApkOptions}
* @return {void}
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4",
* "uniVer": "3.94+",
* "unixVer": "3.94+"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* }
* }
* @example
```typescript
uni.installApk({
filePath: "/xx/xx/xx.apk",
complete: (res: any) => {
console.log("complete => " + JSON.stringify(res));
}
});
```
/**
* installApk()
* @description
* 安装apk
* @param {InstallApkOptions}
* @return {void}
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4",
* "uniVer": "3.94+",
* "unixVer": "3.94+"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* }
* }
* @example
```typescript
uni.installApk({
filePath: "/xx/xx/xx.apk",
complete: (res: any) => {
console.log("complete => " + JSON.stringify(res));
}
});
```
*/
installApk(options : InstallApkOptions) : void
}
...
...
@@ -39,7 +39,18 @@ export type InstallApkSuccess = {
}
export type InstallApkComplete = any
export type InstallApkSuccessCallback = (res : InstallApkSuccess) => void
export type InstallApkFailCallback = (err : UniError) => void
/**
* 错误码
* - 1300002 找不到文件
*/
export type InstallApkErrorCode = 1300002
/**
* 网络请求失败的错误回调参数
*/
export interface InstallApkFail extends IUniError {
errCode : InstallApkErrorCode
};
export type InstallApkFailCallback = (err : InstallApkFail) => void
export type InstallApkCompleteCallback = (res : InstallApkComplete) => void
export type InstallApkOptions = {
...
...
uni_modules/uni-installApk/utssdk/unierror.uts
0 → 100644
浏览文件 @
5acb4df9
import { InstallApkErrorCode, InstallApkFail } from "./interface.uts"
/**
* 错误主题
*/
export const UniErrorSubject = 'uni-installApk';
/**
* 错误码
* @UniError
*/
export const UniErrors : Map<InstallApkErrorCode, string> = new Map([
/**
* 找不到文件
*/
[1300002, 'No such file'],
]);
export class InstallApkFailImpl extends UniError implements InstallApkFail {
constructor(errCode : InstallApkErrorCode) {
super();
this.errSubject = UniErrorSubject;
this.errCode = errCode;
this.errMsg = UniErrors[errCode] ?? "";
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录