diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json index ad7c2a6be83a79900b8cac13428e51381e113455..cc4f2a1a439679c447b2f3bbe509db8e8c8870c5 100644 --- a/.hbuilderx/launch.json +++ b/.hbuilderx/launch.json @@ -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" } ] diff --git a/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts b/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts index 060043b8662663d4b6ce54b71974de7089599503..5ae056d96e3d41349089f07a07c6bfbb6fd30864 100644 --- a/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts +++ b/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts @@ -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) } diff --git a/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts b/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts index e33ab29913aa1586d6a6cbfd1bda3fa4438a8932..de45bdc454fef51d0f63de5581140db8c2809c7c 100644 --- a/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts +++ b/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts @@ -1,9 +1,7 @@ // 引用 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); diff --git a/uni_modules/uni-getbatteryinfo/utssdk/interface.uts b/uni_modules/uni-getbatteryinfo/utssdk/interface.uts index d674221a16620c90639a24de95efbe59177ffa9d..9c7f25fbf6873eb1983882b722ee8bfbfda8b2a0 100644 --- a/uni_modules/uni-getbatteryinfo/utssdk/interface.uts +++ b/uni_modules/uni-getbatteryinfo/utssdk/interface.uts @@ -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 +}; /** * 获取电量信息 diff --git a/uni_modules/uni-getbatteryinfo/utssdk/unierror.uts b/uni_modules/uni-getbatteryinfo/utssdk/unierror.uts new file mode 100644 index 0000000000000000000000000000000000000000..511c66cc0f6627e4e5e72b478fec1163c56ce92c --- /dev/null +++ b/uni_modules/uni-getbatteryinfo/utssdk/unierror.uts @@ -0,0 +1,34 @@ +import { GetBatteryInfoErrorCode, GetBatteryInfoFail } from "./interface.uts" +/** + * 错误主题 + */ +export const UniErrorSubject = 'uni-getBatteryInfo'; + + +/** + * 错误信息 + * @UniError + */ +export const UniErrors : Map = 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 diff --git a/uni_modules/uni-installApk/changelog.md b/uni_modules/uni-installApk/changelog.md index d499b3c6feb8d532491c70023605bdd386e23e01..f6c958315f645b5da63f7296755c1493e57d5c20 100644 --- a/uni_modules/uni-installApk/changelog.md +++ b/uni_modules/uni-installApk/changelog.md @@ -1,3 +1,5 @@ +## 1.0.3(2023-10-27) +遵循UniError规范 ## 1.0.2(2023-10-27) 修改文档 ## 1.0.1(2023-10-27) diff --git a/uni_modules/uni-installApk/package.json b/uni_modules/uni-installApk/package.json index 70bb882114e9c740743274b6aabe0c5a6944410d..c3889207923f11964792eb3bd7659e39427e6ab8 100644 --- a/uni_modules/uni-installApk/package.json +++ b/uni_modules/uni-installApk/package.json @@ -1,7 +1,7 @@ { "id": "uni-installApk", "displayName": "uni-installApk", - "version": "1.0.2", + "version": "1.0.3", "description": "uni-installApk", "keywords": [ "uni-installApk" diff --git a/uni_modules/uni-installApk/utssdk/app-android/index.uts b/uni_modules/uni-installApk/utssdk/app-android/index.uts index 4e2c22b95e58c7b3da2e7ea1b18d7dcbcc61f70a..cfdef2ed5ce2368b42ad73e9152d2dadf2ddc9cb 100644 --- a/uni_modules/uni-installApk/utssdk/app-android/index.uts +++ b/uni_modules/uni-installApk/utssdk/app-android/index.uts @@ -1,4 +1,5 @@ -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 diff --git a/uni_modules/uni-installApk/utssdk/interface.uts b/uni_modules/uni-installApk/utssdk/interface.uts index e377fb77286a01f13e640343a9a31c0751666805..35edfcd7eaeddfd4f192803385829389bac78689 100644 --- a/uni_modules/uni-installApk/utssdk/interface.uts +++ b/uni_modules/uni-installApk/utssdk/interface.uts @@ -1,33 +1,33 @@ 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 = { diff --git a/uni_modules/uni-installApk/utssdk/unierror.uts b/uni_modules/uni-installApk/utssdk/unierror.uts new file mode 100644 index 0000000000000000000000000000000000000000..a10c730d262388e3a2f945208c69f2cc66bee40c --- /dev/null +++ b/uni_modules/uni-installApk/utssdk/unierror.uts @@ -0,0 +1,25 @@ +import { InstallApkErrorCode, InstallApkFail } from "./interface.uts" + +/** + * 错误主题 + */ +export const UniErrorSubject = 'uni-installApk'; +/** + * 错误码 + * @UniError + */ +export const UniErrors : Map = 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