提交 5acb4df9 编写于 作者: taohebin@dcloud.io's avatar taohebin@dcloud.io

Merge branch 'dev' into alpha

...@@ -14,8 +14,9 @@ ...@@ -14,8 +14,9 @@
}, },
{ {
"bundleId" : "io.dcloud.test123456", "bundleId" : "io.dcloud.test123456",
"certificateFile" : "/Users/lizhongyi/Desktop/文件/证书/dev_123.p12", "certificateFile" : "/Users/lizhongyi/Desktop/newProfiles/dev_123.p12",
"certificateProfileFile" : "/Users/lizhongyi/Desktop/文件/证书/io_dcloud_test123456.mobileprovision", "certificateProfileFile" : "/Users/lizhongyi/Desktop/newProfiles/wildcard.mobileprovision",
"runSignStatus" : 1,
"type" : "uni-app:app-ios" "type" : "uni-app:app-ios"
} }
] ]
......
...@@ -5,6 +5,7 @@ import { GetBatteryInfo, GetBatteryInfoOptions, GetBatteryInfoSuccess, GetBatter ...@@ -5,6 +5,7 @@ import { GetBatteryInfo, GetBatteryInfoOptions, GetBatteryInfoSuccess, GetBatter
import IntentFilter from 'android.content.IntentFilter'; import IntentFilter from 'android.content.IntentFilter';
import Intent from 'android.content.Intent'; import Intent from 'android.content.Intent';
import { GetBatteryInfoFailImpl } from '../unierror';
/** /**
* 异步获取电量 * 异步获取电量
...@@ -33,8 +34,8 @@ export const getBatteryInfo : GetBatteryInfo = function (options : GetBatteryInf ...@@ -33,8 +34,8 @@ export const getBatteryInfo : GetBatteryInfo = function (options : GetBatteryInf
} }
options.success?.(res) options.success?.(res)
options.complete?.(res) options.complete?.(res)
} else { } else {
const res = new UniError("uni-getBatteryInfo", 1001, "getBatteryInfo:fail getAppContext is null") let res = new GetBatteryInfoFailImpl(1001);
options.fail?.(res) options.fail?.(res)
options.complete?.(res) options.complete?.(res)
} }
......
// 引用 iOS 原生平台 api // 引用 iOS 原生平台 api
import { UIDevice } from "UIKit"; import { UIDevice } from "UIKit";
import { Int } from 'Swift';
import { GetBatteryInfo, GetBatteryInfoSuccess, GetBatteryInfoResult, GetBatteryInfoSync } from '../interface.uts'; import { GetBatteryInfo, GetBatteryInfoSuccess, GetBatteryInfoResult, GetBatteryInfoSync } from '../interface.uts';
/** /**
* 导出 获取电量方法 * 导出 获取电量方法
*/ */
...@@ -15,7 +13,7 @@ export const getBatteryInfo : GetBatteryInfo = function (options) { ...@@ -15,7 +13,7 @@ export const getBatteryInfo : GetBatteryInfo = function (options) {
// 返回数据 // 返回数据
const res : GetBatteryInfoSuccess = { const res : GetBatteryInfoSuccess = {
errMsg: "getBatteryInfo:ok", errMsg: "getBatteryInfo:ok",
level: new Int(UIDevice.current.batteryLevel * 100), level: Number(UIDevice.current.batteryLevel * 100),
isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging, isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,
}; };
options.success?.(res); options.success?.(res);
......
...@@ -55,7 +55,19 @@ export type GetBatteryInfoResult = { ...@@ -55,7 +55,19 @@ export type GetBatteryInfoResult = {
* 是否正在充电中 * 是否正在充电中
*/ */
isCharging : boolean isCharging : boolean
} }
/**
* 错误码
* - 1001 getAppContext is null
*/
export type GetBatteryInfoErrorCode = 1001 ;
/**
* myApi 的错误回调参数
*/
export interface GetBatteryInfoFail extends IUniError {
errCode : GetBatteryInfoErrorCode
};
/** /**
* 获取电量信息 * 获取电量信息
......
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
## 1.0.3(2023-10-27)
遵循UniError规范
## 1.0.2(2023-10-27) ## 1.0.2(2023-10-27)
修改文档 修改文档
## 1.0.1(2023-10-27) ## 1.0.1(2023-10-27)
......
{ {
"id": "uni-installApk", "id": "uni-installApk",
"displayName": "uni-installApk", "displayName": "uni-installApk",
"version": "1.0.2", "version": "1.0.3",
"description": "uni-installApk", "description": "uni-installApk",
"keywords": [ "keywords": [
"uni-installApk" "uni-installApk"
......
import { InstallApkOptions, InstallApkSuccess } from "../interface.uts" import { InstallApkOptions, InstallApkSuccess } from "../interface.uts"
import { InstallApkFailImpl } from "../unierror.uts"
import Intent from 'android.content.Intent'; import Intent from 'android.content.Intent';
import Build from 'android.os.Build'; import Build from 'android.os.Build';
import File from 'java.io.File'; import File from 'java.io.File';
...@@ -11,7 +12,7 @@ export function installApk(options : InstallApkOptions) : void { ...@@ -11,7 +12,7 @@ export function installApk(options : InstallApkOptions) : void {
const filePath = UTSAndroid.convert2AbsFullPath(options.filePath) const filePath = UTSAndroid.convert2AbsFullPath(options.filePath)
const apkFile = new File(filePath) const apkFile = new File(filePath)
if (!apkFile.exists() && !apkFile.isFile()) { if (!apkFile.exists() && !apkFile.isFile()) {
let error = new UniError("uni-installApk", -1, "filePath is illegal"); let error = new InstallApkFailImpl(1300002);
options.fail?.(error) options.fail?.(error)
options.complete?.(error) options.complete?.(error)
return return
......
export interface Uni { export interface Uni {
/** /**
* installApk() * installApk()
* @description * @description
* 安装apk * 安装apk
* @param {InstallApkOptions} * @param {InstallApkOptions}
* @return {void} * @return {void}
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
* "osVer": "4.4", * "osVer": "4.4",
* "uniVer": "3.94+", * "uniVer": "3.94+",
* "unixVer": "3.94+" * "unixVer": "3.94+"
* }, * },
* "ios": { * "ios": {
* "osVer": "x", * "osVer": "x",
* "uniVer": "x", * "uniVer": "x",
* "unixVer": "x" * "unixVer": "x"
* } * }
* } * }
* } * }
* @example * @example
```typescript ```typescript
uni.installApk({ uni.installApk({
filePath: "/xx/xx/xx.apk", filePath: "/xx/xx/xx.apk",
complete: (res: any) => { complete: (res: any) => {
console.log("complete => " + JSON.stringify(res)); console.log("complete => " + JSON.stringify(res));
} }
}); });
``` ```
*/ */
installApk(options : InstallApkOptions) : void installApk(options : InstallApkOptions) : void
} }
...@@ -39,7 +39,18 @@ export type InstallApkSuccess = { ...@@ -39,7 +39,18 @@ export type InstallApkSuccess = {
} }
export type InstallApkComplete = any export type InstallApkComplete = any
export type InstallApkSuccessCallback = (res : InstallApkSuccess) => void 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 InstallApkCompleteCallback = (res : InstallApkComplete) => void
export type InstallApkOptions = { export type InstallApkOptions = {
......
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.
先完成此消息的编辑!
想要评论请 注册