diff --git a/uni_modules/uni-exit/utssdk/interface.uts b/uni_modules/uni-exit/utssdk/interface.uts index e821a27e14f0c14064fbe4c1daa3abc1c44a3b9c..aae2adc5b3ded0e2c7b1dfb4af8214ffdf03abb2 100644 --- a/uni_modules/uni-exit/utssdk/interface.uts +++ b/uni_modules/uni-exit/utssdk/interface.uts @@ -61,14 +61,12 @@ export interface Uni { * "android": { * "osVer": "5.0", * "uniVer": "3.8.15", - * "unixVer": "3.9.0", - * "utsPlugin": "3.9.0" + * "unixVer": "3.9.0" * }, * "ios": { * "osVer": "x", * "uniVer": "x", - * "unixVer": "x", - * "utsPlugin": "x" + * "unixVer": "x" * } * }, * "web": { diff --git a/uni_modules/uni-fileSystemManager/package.json b/uni_modules/uni-fileSystemManager/package.json index 751b7babe78e6d46860bf96293f85fde1b90d38d..94e2f8ba7d10b3c33b06caa624fddd72e3125f8d 100644 --- a/uni_modules/uni-fileSystemManager/package.json +++ b/uni_modules/uni-fileSystemManager/package.json @@ -37,7 +37,7 @@ "getFileSystemManager": { "name": "getFileSystemManager", "app": { - "js": true, + "js": false, "kotlin": true, "swift": false } diff --git a/uni_modules/uni-fileSystemManager/utssdk/app-android/FileDescriptorUtil.uts b/uni_modules/uni-fileSystemManager/utssdk/app-android/FileDescriptorUtil.uts index cec6a188094ec662b80636043a6bb055b6c86709..9b223f9245f0d4be717d52193903d91ade87ef28 100644 --- a/uni_modules/uni-fileSystemManager/utssdk/app-android/FileDescriptorUtil.uts +++ b/uni_modules/uni-fileSystemManager/utssdk/app-android/FileDescriptorUtil.uts @@ -1,7 +1,7 @@ import File from 'java.io.File' import ParcelFileDescriptor from 'android.os.ParcelFileDescriptor' import { OpenFileOptions, OpenFileSuccessResult, OpenFileSyncOptions } from '../interface'; -import { UniErrorSubject,FileSystemManagerFailImpl,FileSystemManagerUniErrors } from '../unierror'; +import { UniErrorSubject, UniErrors } from '../unierror'; export class FileDescriptorUtil { public openMap : Map = new Map() @@ -28,12 +28,12 @@ export class FileDescriptorUtil { case 'ax': //类似于 'a',但如果路径存在,则失败 { if (file.exists()) { - let err = new FileSystemManagerFailImpl(1301005); + let err = new UniError(UniErrorSubject, 1301005, UniErrors.get(1301005)!); options.fail?.(err) options.complete?.(err) } else { if (file.parentFile?.exists() == false) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)!); options.fail?.(err) options.complete?.(err) return @@ -66,7 +66,7 @@ export class FileDescriptorUtil { case 'ax+': //类似于 'a+',但如果路径存在,则失败 { if (file.exists()) { - let err = new FileSystemManagerFailImpl(1301005); + let err = new UniError(UniErrorSubject, 1301005, UniErrors.get(1301005)!); options.fail?.(err) options.complete?.(err) } else { @@ -84,7 +84,7 @@ export class FileDescriptorUtil { case 'r': //打开文件用于读取。 如果文件不存在,则会发生异常 { if (!file.exists()) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)!); options.fail?.(err) options.complete?.(err) } else { @@ -104,7 +104,7 @@ export class FileDescriptorUtil { case 'r+': //打开文件用于读取和写入。 如果文件不存在,则会发生异常 { if (!file.exists()) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)!); options.fail?.(err) options.complete?.(err) } else { @@ -136,7 +136,7 @@ export class FileDescriptorUtil { case 'wx'://类似于 'w',但如果路径存在,则失败 { if (file.exists()) { - let err = new FileSystemManagerFailImpl(1301005); + let err = new UniError(UniErrorSubject, 1301005, UniErrors.get(1301005)!); options.fail?.(err) options.complete?.(err) } else { @@ -168,7 +168,7 @@ export class FileDescriptorUtil { case 'wx+': // 类似于 'w+',但如果路径存在,则失败 { if (file.exists()) { - let err = new FileSystemManagerFailImpl(1301005); + let err = new UniError(UniErrorSubject, 1301005, UniErrors.get(1301005)!); options.fail?.(err) options.complete?.(err) } else { @@ -187,7 +187,7 @@ export class FileDescriptorUtil { } } } catch (e) { - let err = new FileSystemManagerFailImpl(1300201); + let err = new UniError(UniErrorSubject, 1300201, UniErrors.get(1300201)! + ":" + e + " " + options.filePath); options.fail?.(err) options.complete?.(err) } @@ -206,10 +206,10 @@ export class FileDescriptorUtil { case 'ax': //类似于 'a',但如果路径存在,则失败 { if (file.exists()) { - throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1301005]}`) + throw new Error(`${msgPrefix}${UniErrors[1301005]}`) } else { if (file.parentFile?.exists() == false) { - throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1300002]}`) + throw new Error(`${msgPrefix}${UniErrors[1300002]}`) } else { file.createNewFile() let fd = this.open_a(file) @@ -228,7 +228,7 @@ export class FileDescriptorUtil { case 'ax+': //类似于 'a+',但如果路径存在,则失败 { if (file.exists()) { - throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1301005]}`) + throw new Error(`${msgPrefix}${UniErrors[1301005]}`) } else { let fd = this.open_ax(file) this.openMap.set(fd, file) @@ -238,7 +238,7 @@ export class FileDescriptorUtil { case 'r': //打开文件用于读取。 如果文件不存在,则会发生异常 { if (!file.exists()) { - throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1300002]}`) + throw new Error(`${msgPrefix}${UniErrors[1300002]}`) } else { let mode = ParcelFileDescriptor.MODE_READ_ONLY let pfd = ParcelFileDescriptor.open(file, mode); @@ -251,7 +251,7 @@ export class FileDescriptorUtil { case 'r+': //打开文件用于读取和写入。 如果文件不存在,则会发生异常 { if (!file.exists()) { - throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1300002]}`) + throw new Error(`${msgPrefix}${UniErrors[1300002]}`) } else { let mode = ParcelFileDescriptor.MODE_READ_WRITE let pfd = ParcelFileDescriptor.open(file, mode); @@ -270,7 +270,7 @@ export class FileDescriptorUtil { case 'wx'://类似于 'w',但如果路径存在,则失败 { if (file.exists()) { - throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1301005]}`) + throw new Error(`${msgPrefix}${UniErrors[1301005]}`) } else { let fd = this.open_w(file) this.openMap.set(fd, file) @@ -289,7 +289,7 @@ export class FileDescriptorUtil { case 'wx+': // 类似于 'w+',但如果路径存在,则失败 { if (file.exists()) { - throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1301005]}`) + throw new Error(`${msgPrefix}${UniErrors[1301005]}`) } else { let mode = ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_READ_WRITE | ParcelFileDescriptor.MODE_TRUNCATE let pfd = ParcelFileDescriptor.open(file, mode); diff --git a/uni_modules/uni-fileSystemManager/utssdk/app-android/index.uts b/uni_modules/uni-fileSystemManager/utssdk/app-android/index.uts index 0d27a8bf2c4f504dbda4eb325af123637b7d26e5..42ba37e7e1fc4f06ba320ebb9da17d5512df219c 100644 --- a/uni_modules/uni-fileSystemManager/utssdk/app-android/index.uts +++ b/uni_modules/uni-fileSystemManager/utssdk/app-android/index.uts @@ -1,7 +1,7 @@ import { WriteFileOptions, ReadFileOptions, MkDirOptions, RmDirOptions, TruncateFileOptions, UnLinkOptions, ReadDirOptions, AccessOptions, RenameOptions, GetFileInfoOptions, CopyFileOptions, StatOptions, AppendFileOptions, OpenFileOptions, OpenFileSuccessCallback, OpenFileSuccessResult, SaveFileOptions, UnzipFileOptions, GetSavedFileListOptions, ReadCompressedFileOptions, ReadCompressedFileResult, RemoveSavedFileOptions, WriteOptions, WriteResult, OpenFileSyncOptions, WriteSyncOptions, CloseOptions, CloseSyncOptions, FStatOptions, FStatSuccessResult, FTruncateFileOptions, FTruncateFileSyncOptions, FStatSyncOptions, ReadZipEntryOptions, ZipFileItem, ReadZipEntryCallback, EntriesResult } from "../interface.uts" import { ReadFileSuccessResult, FileManagerSuccessResult, ReadDirSuccessResult, AccessSuccessResult, SaveFileSuccessResult, GetFileInfoSuccessResult, StatSuccessResult, FileStats, Stats, GetSavedFileListResult } from "../interface.uts" import { GetFileSystemManager, FileSystemManager } from "../interface.uts" -import { FileSystemManagerFailImpl, FileSystemManagerUniErrorSubject, FileSystemManagerUniErrors, UniErrors } from "../unierror.uts" +import { UniErrorSubject, UniErrors } from "../unierror.uts" import { FileDescriptorUtil } from "./FileDescriptorUtil" import File from "java.io.File" import Base64 from "android.util.Base64" @@ -18,7 +18,6 @@ import Option from 'android.app.VoiceInteractor.PickOptionRequest.Option'; import FileDescriptor from 'java.io.FileDescriptor'; import ParcelFileDescriptor from 'android.os.ParcelFileDescriptor'; import ByteBuffer from 'java.nio.ByteBuffer'; -import InputStream from 'java.io.InputStream'; class AndroidStats implements Stats, io.dcloud.uts.log.LogSelf, io.dcloud.uts.json.IJsonStringify { /** @@ -97,7 +96,7 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(filePath, true) if (!isSandyBox) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.path); options.fail?.(err) options.complete?.(err) }, null) @@ -111,7 +110,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 文件不存在 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.path); options.fail?.(err) options.complete?.(err) }, null) @@ -179,14 +178,14 @@ class AndroidFileSystemManager implements FileSystemManager { let tempRecursive = recursive let isSandyBox = isSandyBoxPath(filePath, true) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1300013)!) + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1300013)!) } let targetFile = new File(filePath) if (!targetFile.exists()) { /** * 文件不存在 */ - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!); + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!); } if (tempRecursive == true && targetFile.isDirectory()) { // 如果当前是目录,并且设置 则需要遍历所有子目录 @@ -234,7 +233,7 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(filePath, true) if (!isSandyBox) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) }, null) @@ -248,7 +247,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 文件不存在 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) }, null) @@ -260,7 +259,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 文件是个目录 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl( 1300021); + let err = new UniError(UniErrorSubject, 1300021, UniErrors.get(1300021)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) }, null) @@ -275,7 +274,7 @@ class AndroidFileSystemManager implements FileSystemManager { * invalid digestAlgorithm */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300022); + let err = new UniError(UniErrorSubject, 1300022, UniErrors.get(1300022)! + ":invalid digestAlgorithm " + options.digestAlgorithm); options.fail?.(err) options.complete?.(err) }, null) @@ -341,57 +340,57 @@ class AndroidFileSystemManager implements FileSystemManager { byteArray = new ByteArray(byteLen) assetStream.read(byteArray); } catch (e) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300201, msgPrefix + FileSystemManagerUniErrors.get(1300201)!); + throw new UniError(UniErrorSubject, 1300201, msgPrefix + UniErrors.get(1300201)!); } // 检查目标文件 let newFilePath = UTSAndroid.convert2AbsFullPath(destPath) let isSandyBox = isSandyBoxPath(newFilePath, false) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1300013)!); + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1300013)!); } let newFile = new File(newFilePath) if (newFile.getParentFile() != null && !newFile.getParentFile()!.exists()) { /** * 父文件不存在 */ - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!) } newFile.writeBytes(byteArray) if (!newFile.exists()) { // 调用系统api 失败 - throw new UniError(FileSystemManagerUniErrorSubject, 1300201, msgPrefix + FileSystemManagerUniErrors.get(1300201)!) + throw new UniError(UniErrorSubject, 1300201, msgPrefix + UniErrors.get(1300201)!) } } else { let isSandyBox = isSandyBoxPath(filePath, true) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1300013)!) + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1300013)!) } let targetFile = new File(filePath) if (!targetFile.exists()) { /** * 文件不存在 */ - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!) } // 检查目标文件 let newFilePath = UTSAndroid.convert2AbsFullPath(destPath) isSandyBox = isSandyBoxPath(newFilePath, false) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1300013)!) + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1300013)!) } let newFile = new File(newFilePath) if (newFile.getParentFile() != null && !newFile.getParentFile()!.exists()) { /** * 父文件不存在 */ - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!) } let copyRetFile = targetFile.copyTo(newFile, true) if (!copyRetFile.exists()) { // 调用系统api 失败 - throw new UniError(FileSystemManagerUniErrorSubject, 1300201, msgPrefix + FileSystemManagerUniErrors.get(1300201)!) + throw new UniError(UniErrorSubject, 1300201, msgPrefix + UniErrors.get(1300201)!) } } } @@ -422,7 +421,7 @@ class AndroidFileSystemManager implements FileSystemManager { if (exceptionInfo != null) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300201); + let err = new UniError(UniErrorSubject, 1300201, UniErrors.get(1300201)! + ":" + exceptionInfo.message); options.fail?.(err) options.complete?.(err) }, null) @@ -435,7 +434,7 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(newFilePath, false) if (!isSandyBox) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.destPath); options.fail?.(err) options.complete?.(err) }, null) @@ -447,7 +446,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 父文件不存在 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.destPath); options.fail?.(err) options.complete?.(err) }, null) @@ -457,7 +456,7 @@ class AndroidFileSystemManager implements FileSystemManager { if (!newFile.exists()) { // 调用系统api 失败 currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300201); + let err = new UniError(UniErrorSubject, 1300201, UniErrors.get(1300201)!); options.fail?.(err) options.complete?.(err) }, null) @@ -476,7 +475,7 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(filePath, true) if (!isSandyBox) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.srcPath); options.fail?.(err) options.complete?.(err) }, null) @@ -488,7 +487,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 文件不存在 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.srcPath); options.fail?.(err) options.complete?.(err) }, null) @@ -499,7 +498,7 @@ class AndroidFileSystemManager implements FileSystemManager { isSandyBox = isSandyBoxPath(newFilePath, false) if (!isSandyBox) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.destPath); options.fail?.(err) options.complete?.(err) }, null) @@ -511,7 +510,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 父文件不存在 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.destPath); options.fail?.(err) options.complete?.(err) }) @@ -522,7 +521,7 @@ class AndroidFileSystemManager implements FileSystemManager { if (!copyRetFile.exists()) { // 调用系统api 失败 currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300201); + let err = new UniError(UniErrorSubject, 1300201, UniErrors.get(1300201)!); options.fail?.(err) options.complete?.(err) }) @@ -548,7 +547,7 @@ class AndroidFileSystemManager implements FileSystemManager { let filePath = UTSAndroid.convert2AbsFullPath(oldPath) let isSandyBox = isSandyBoxPath(filePath, false) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1301003)!); + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1301003)!); } let targetFile = new File(filePath) @@ -556,12 +555,12 @@ class AndroidFileSystemManager implements FileSystemManager { /** * 文件不存在 */ - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!) } let newFilePath = UTSAndroid.convert2AbsFullPath(newPath) isSandyBox = isSandyBoxPath(newFilePath, false) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1300013)!) + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1300013)!) } let newFile = new File(newFilePath) @@ -569,14 +568,14 @@ class AndroidFileSystemManager implements FileSystemManager { /** * 父文件不存在 */ - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!) } let renameRet = targetFile.renameTo(newFile) if (!renameRet) { // 调用系统api 失败 - throw new UniError(FileSystemManagerUniErrorSubject, 1300201, msgPrefix + FileSystemManagerUniErrors.get(1300201)!) + throw new UniError(UniErrorSubject, 1300201, msgPrefix + UniErrors.get(1300201)!) } } @@ -589,7 +588,7 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(filePath, false) if (!isSandyBox) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.oldPath); options.fail?.(err) options.complete?.(err) }) @@ -602,7 +601,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 文件不存在 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.oldPath); options.fail?.(err) options.complete?.(err) }) @@ -612,7 +611,7 @@ class AndroidFileSystemManager implements FileSystemManager { isSandyBox = isSandyBoxPath(newFilePath, false) if (!isSandyBox) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.newPath); options.fail?.(err) options.complete?.(err) }) @@ -625,7 +624,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 父文件不存在 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.newPath); options.fail?.(err) options.complete?.(err) }) @@ -637,7 +636,7 @@ class AndroidFileSystemManager implements FileSystemManager { if (!renameRet) { // 调用系统api 失败 currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300201); + let err = new UniError(UniErrorSubject, 1300201, UniErrors.get(1300201)!); options.fail?.(err) options.complete?.(err) }) @@ -661,14 +660,14 @@ class AndroidFileSystemManager implements FileSystemManager { let targetFile = new File(filePath) let isSandyBox = isSandyBoxPath(filePath, true) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1300013)!) + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1300013)!) } if (!targetFile.exists()) { /** * 文件不存在,或者不是文件夹,异常 */ - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!) } } @@ -683,7 +682,7 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(filePath, true) if (!isSandyBox) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.path); options.fail?.(err) options.complete?.(err) }) @@ -695,7 +694,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 文件不存在,或者不是文件夹,异常 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.path); options.fail?.(err) options.complete?.(err) }) @@ -721,7 +720,7 @@ class AndroidFileSystemManager implements FileSystemManager { let filePath = UTSAndroid.convert2AbsFullPath(dirPath) let isSandyBox = isSandyBoxPath(filePath, true) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1300013)!) + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1300013)!) } let targetFile = new File(filePath) @@ -729,7 +728,7 @@ class AndroidFileSystemManager implements FileSystemManager { /** * 文件不存在,或者不是文件夹,异常 */ - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!) } return UTSArray.fromNative(targetFile.list()!) } @@ -742,7 +741,7 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(filePath, true) if (!isSandyBox) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.dirPath); options.fail?.(err) options.complete?.(err) }) @@ -755,7 +754,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 文件不存在,或者不是文件夹,异常 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.dirPath); options.fail?.(err) options.complete?.(err) }) @@ -778,14 +777,14 @@ class AndroidFileSystemManager implements FileSystemManager { let targetFile = new File(filePath) let isSandyBox = isSandyBoxPath(filePath, false) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1300013)!) + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1300013)!) } if (!targetFile.exists() || !targetFile.isDirectory()) { /** * 文件不存在 或者 文件是不是文件夹 */ - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!) } @@ -794,13 +793,13 @@ class AndroidFileSystemManager implements FileSystemManager { let childList = targetFile.list() if (childList != null && childList.size > 0) { // 存在子目录 - throw new UniError(FileSystemManagerUniErrorSubject, 1300066, msgPrefix + FileSystemManagerUniErrors.get(1300066)!) + throw new UniError(UniErrorSubject, 1300066, msgPrefix + UniErrors.get(1300066)!) } } else { let delRet = targetFile.deleteRecursively() if (!delRet) { // 调用系统api 失败 - throw new UniError(FileSystemManagerUniErrorSubject, 1300201, msgPrefix + FileSystemManagerUniErrors.get(1300201)!) + throw new UniError(UniErrorSubject, 1300201, msgPrefix + UniErrors.get(1300201)!) } } } @@ -808,31 +807,31 @@ class AndroidFileSystemManager implements FileSystemManager { public mkdirSync(dirPath : string, recursive : boolean) : void { let msgPrefix = "mkdirSync:fail " if (dirPath.isEmpty()) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300066, msgPrefix + FileSystemManagerUniErrors.get(1300066)!) + throw new UniError(UniErrorSubject, 1300066, msgPrefix + UniErrors.get(1300066)!) } let filePath = UTSAndroid.convert2AbsFullPath(dirPath) let isSandyBox = isSandyBoxPath(filePath, false) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1300013)!) + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1300013)!) } let targetFile = new File(filePath) if (targetFile.exists()) { /** * 文件已经存在,则无法继续创建 */ - throw new UniError(FileSystemManagerUniErrorSubject, 1301005, msgPrefix + FileSystemManagerUniErrors.get(1301005)!) + throw new UniError(UniErrorSubject, 1301005, msgPrefix + UniErrors.get(1301005)!) } if (!recursive) { // 没有设置递归创建 if (targetFile.getParentFile() == null || !targetFile.getParentFile()!.exists()) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!) } else { // 父文件夹存在,则继续创建 let mkRet = targetFile.mkdir() if (!mkRet) { // 调用系统api 失败 - throw new UniError(FileSystemManagerUniErrorSubject, 1300201, msgPrefix + FileSystemManagerUniErrors.get(1300201)!) + throw new UniError(UniErrorSubject, 1300201, msgPrefix + UniErrors.get(1300201)!) } } } else { @@ -840,7 +839,7 @@ class AndroidFileSystemManager implements FileSystemManager { let mkRet = targetFile.mkdirs() if (!mkRet) { // 调用系统api 失败 - throw new UniError(FileSystemManagerUniErrorSubject, 1300201, msgPrefix + FileSystemManagerUniErrors.get(1300201)!) + throw new UniError(UniErrorSubject, 1300201, msgPrefix + UniErrors.get(1300201)!) } } } @@ -856,7 +855,7 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(filePath, false) if (!isSandyBox) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.dirPath); options.fail?.(err) options.complete?.(err) }) @@ -868,7 +867,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 文件不存在 或者 文件是不是文件夹 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.dirPath); options.fail?.(err) options.complete?.(err) }) @@ -882,7 +881,7 @@ class AndroidFileSystemManager implements FileSystemManager { if (childList != null && childList.size > 0) { // 存在子目录 currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300066); + let err = new UniError(UniErrorSubject, 1300066, UniErrors.get(1300066)! + ":" + options.dirPath); options.fail?.(err) options.complete?.(err) }) @@ -894,7 +893,7 @@ class AndroidFileSystemManager implements FileSystemManager { if (!delRet) { // 调用系统api 失败 currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300201); + let err = new UniError(UniErrorSubject, 1300201, UniErrors.get(1300201)! + ":" + options.dirPath); options.fail?.(err) options.complete?.(err) }) @@ -923,7 +922,7 @@ class AndroidFileSystemManager implements FileSystemManager { if (options.dirPath.isEmpty()) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300066); + let err = new UniError(UniErrorSubject, 1300066, UniErrors.get(1300066)!); options.fail?.(err) options.complete?.(err) }) @@ -934,7 +933,7 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(filePath, false) if (!isSandyBox) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.dirPath); options.fail?.(err) options.complete?.(err) }) @@ -947,7 +946,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 文件已经存在,则无法继续创建 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1301005); + let err = new UniError(UniErrorSubject, 1301005, UniErrors.get(1301005)! + ":" + options.dirPath); options.fail?.(err) options.complete?.(err) }) @@ -958,7 +957,7 @@ class AndroidFileSystemManager implements FileSystemManager { // 没有设置递归创建 if (targetFile.getParentFile() == null || !targetFile.getParentFile()!.exists()) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.dirPath); options.fail?.(err) options.complete?.(err) }) @@ -969,7 +968,7 @@ class AndroidFileSystemManager implements FileSystemManager { if (!mkRet) { // 调用系统api 失败 currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300201); + let err = new UniError(UniErrorSubject, 1300201, UniErrors.get(1300201)! + ":" + options.dirPath); options.fail?.(err) options.complete?.(err) }) @@ -983,7 +982,7 @@ class AndroidFileSystemManager implements FileSystemManager { if (!mkRet) { // 调用系统api 失败 currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300201); + let err = new UniError(UniErrorSubject, 1300201, UniErrors.get(1300201)! + ":" + options.dirPath); options.fail?.(err) options.complete?.(err) }) @@ -1011,19 +1010,19 @@ class AndroidFileSystemManager implements FileSystemManager { let temFilePath = UTSAndroid.convert2AbsFullPath(filePath) let isSandyBox = isSandyBoxPath(temFilePath, false) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1300013)!) + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1300013)!) } let targetFile = new File(temFilePath) if (!targetFile.exists()) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!) } // 文件存在,则进行删除操作 let delRet = targetFile.delete() if (!delRet) { // 调用系统api 删除失败 - throw new UniError(FileSystemManagerUniErrorSubject, 1300201, msgPrefix + FileSystemManagerUniErrors.get(1300201)!) + throw new UniError(UniErrorSubject, 1300201, msgPrefix + UniErrors.get(1300201)!) } } @@ -1041,7 +1040,7 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(filePath, false) if (!isSandyBox) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) }) @@ -1051,7 +1050,7 @@ class AndroidFileSystemManager implements FileSystemManager { let targetFile = new File(filePath) if (!targetFile.exists()) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) }) @@ -1063,7 +1062,7 @@ class AndroidFileSystemManager implements FileSystemManager { if (!delRet) { // 调用系统api 删除失败 currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300201); + let err = new UniError(UniErrorSubject, 1300201, UniErrors.get(1300201)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) }) @@ -1092,7 +1091,7 @@ class AndroidFileSystemManager implements FileSystemManager { tempEncoding = "utf-8" } if (tempEncoding.toLowerCase() != 'base64' && tempEncoding.toLowerCase() != 'utf-8' && tempEncoding.toLowerCase() != 'ascii') { - throw new UniError(FileSystemManagerUniErrorSubject, 1200002, msgPrefix + FileSystemManagerUniErrors.get(1200002)!) + throw new UniError(UniErrorSubject, 1200002, msgPrefix + UniErrors.get(1200002)!) } let tempFilePath = UTSAndroid.convert2AbsFullPath(filePath) if (tempFilePath.startsWith("/android_asset/")) { @@ -1104,7 +1103,7 @@ class AndroidFileSystemManager implements FileSystemManager { byteArray = new ByteArray(byteLen) assetStream.read(byteArray); } catch (e : Exception) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300201, msgPrefix + FileSystemManagerUniErrors.get(1300201)! + ":" + filePath) + throw new UniError(UniErrorSubject, 1300201, msgPrefix + UniErrors.get(1300201)! + ":" + filePath) } if (tempEncoding.toLowerCase() == 'base64') { @@ -1130,18 +1129,18 @@ class AndroidFileSystemManager implements FileSystemManager { let targetFile = new File(tempFilePath) if (!targetFile.exists()) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)! + ":" + filePath); + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)! + ":" + filePath); } if (targetFile.isDirectory()) { - throw new UniError(FileSystemManagerUniErrorSubject, 1301003, msgPrefix + FileSystemManagerUniErrors.get(1301003)! + ":" + filePath); + throw new UniError(UniErrorSubject, 1301003, msgPrefix + UniErrors.get(1301003)! + ":" + filePath); } /** * 文件超过100M,会超过应用内存 */ if (targetFile.length() > 100 * 1024 * 1024) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300202, msgPrefix + FileSystemManagerUniErrors.get(1300202)! + ":" + filePath); + throw new UniError(UniErrorSubject, 1300202, msgPrefix + UniErrors.get(1300202)! + ":" + filePath); } if (tempEncoding.toLowerCase() == 'base64') { @@ -1167,7 +1166,7 @@ class AndroidFileSystemManager implements FileSystemManager { // 判断type 是否合法 if (options.encoding.toLowerCase() != 'base64' && options.encoding.toLowerCase() != 'utf-8' && options.encoding.toLowerCase() != 'ascii') { - let err = new FileSystemManagerFailImpl(1200002); + let err = new UniError(UniErrorSubject, 1200002, UniErrors.get(1200002)!); options.fail?.(err) options.complete?.(err) return @@ -1200,7 +1199,7 @@ class AndroidFileSystemManager implements FileSystemManager { if (exceptionInfo != null) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300201); + let err = new UniError(UniErrorSubject, 1300201, UniErrors.get(1300201)! + ":" + exceptionInfo.message); options.fail?.(err) options.complete?.(err) }) @@ -1238,7 +1237,7 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(filePath, true) if (!isSandyBox) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) }) @@ -1248,7 +1247,7 @@ class AndroidFileSystemManager implements FileSystemManager { let targetFile = new File(filePath) if (!targetFile.exists()) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) }) @@ -1257,7 +1256,7 @@ class AndroidFileSystemManager implements FileSystemManager { if (targetFile.isDirectory()) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1301003); + let err = new UniError(UniErrorSubject, 1301003, UniErrors.get(1301003)!); options.fail?.(err) options.complete?.(err) }) @@ -1269,7 +1268,7 @@ class AndroidFileSystemManager implements FileSystemManager { */ if (targetFile.length() > 100 * 1024 * 1024) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300202); + let err = new UniError(UniErrorSubject, 1300202, UniErrors.get(1300202)!); options.fail?.(err) options.complete?.(err) }) @@ -1312,7 +1311,7 @@ class AndroidFileSystemManager implements FileSystemManager { let msgPrefix = "writeFileSync:fail " let tempEncoding = encoding if (tempEncoding.toLowerCase() != 'base64' && tempEncoding.toLowerCase() != 'utf-8' && tempEncoding.toLowerCase() != 'ascii') { - throw new UniError(FileSystemManagerUniErrorSubject, 1200002, msgPrefix + FileSystemManagerUniErrors.get(1200002)!) + throw new UniError(UniErrorSubject, 1200002, msgPrefix + UniErrors.get(1200002)!) } // 判断type 是否合法 @@ -1320,13 +1319,13 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(tempFilePath, false) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1300013)!) + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1300013)!) } let nextFile = new File(tempFilePath) if (nextFile.exists() && nextFile.isDirectory()) { - throw new UniError(FileSystemManagerUniErrorSubject, 1301003, msgPrefix + FileSystemManagerUniErrors.get(1301003)!) + throw new UniError(UniErrorSubject, 1301003, msgPrefix + UniErrors.get(1301003)!) } /** @@ -1364,7 +1363,7 @@ class AndroidFileSystemManager implements FileSystemManager { public writeFile(options : WriteFileOptions) { if (options.encoding.toLowerCase() != 'base64' && options.encoding.toLowerCase() != 'utf-8' && options.encoding.toLowerCase() != 'ascii') { - let err = new FileSystemManagerFailImpl(1200002); + let err = new UniError(UniErrorSubject, 1200002, UniErrors.get(1200002)!); options.fail?.(err) options.complete?.(err) return @@ -1375,7 +1374,7 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(filePath, false) if (!isSandyBox) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) return @@ -1385,7 +1384,7 @@ class AndroidFileSystemManager implements FileSystemManager { if (nextFile.exists() && nextFile.isDirectory()) { // 出错了,目标文件已存在,并且是个目录 - let err = new FileSystemManagerFailImpl(1301003); + let err = new UniError(UniErrorSubject, 1301003, UniErrors.get(1301003)!); options.fail?.(err) options.complete?.(err) return @@ -1440,20 +1439,20 @@ class AndroidFileSystemManager implements FileSystemManager { let msgPrefix = "appendFileSync:fail " let tempEncoding = encoding if (tempEncoding.toLowerCase() != 'base64' && tempEncoding.toLowerCase() != 'utf-8' && tempEncoding.toLowerCase() != 'ascii') { - throw new UniError(FileSystemManagerUniErrorSubject, 1200002, msgPrefix + FileSystemManagerUniErrors.get(1200002)!) + throw new UniError(UniErrorSubject, 1200002, msgPrefix + UniErrors.get(1200002)!) } // 判断type 是否合法 let tempFilePath = UTSAndroid.convert2AbsFullPath(filePath) let isSandyBox = isSandyBoxPath(tempFilePath, false) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1300013)!) + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1300013)!) } let nextFile = new File(tempFilePath) if (!nextFile.exists()) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!) } else if (nextFile.isDirectory()) { // 出错了,目标文件已存在,并且是个目录 - throw new UniError(FileSystemManagerUniErrorSubject, 1301003, msgPrefix + FileSystemManagerUniErrors.get(1301003)!) + throw new UniError(UniErrorSubject, 1301003, msgPrefix + UniErrors.get(1301003)!) } // 写入文本,根据不同的编码内容写入不同的数据 if (tempEncoding.toLowerCase() == 'ascii') { @@ -1478,7 +1477,7 @@ class AndroidFileSystemManager implements FileSystemManager { public appendFile(options : AppendFileOptions) { if (options.encoding.toLowerCase() != 'base64' && options.encoding.toLowerCase() != 'utf-8' && options.encoding.toLowerCase() != 'ascii') { - let err = new FileSystemManagerFailImpl(1200002); + let err = new UniError(UniErrorSubject, 1200002, UniErrors.get(1200002)!); options.fail?.(err) options.complete?.(err) return @@ -1489,7 +1488,7 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(filePath, false) if (!isSandyBox) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) return @@ -1499,13 +1498,13 @@ class AndroidFileSystemManager implements FileSystemManager { if (!nextFile.exists()) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)!); options.fail?.(err) options.complete?.(err) return } else if (nextFile.isDirectory()) { // 出错了,目标文件已存在,并且是个目录 - let err = new FileSystemManagerFailImpl(1301003); + let err = new UniError(UniErrorSubject, 1301003, UniErrors.get(1301003)!); options.fail?.(err) options.complete?.(err) return @@ -1557,7 +1556,7 @@ class AndroidFileSystemManager implements FileSystemManager { && optFlag != 'w+' && optFlag != 'wx' && optFlag != 'wx+') { - let err = new FileSystemManagerFailImpl(1302003); + let err = new UniError(UniErrorSubject, 1302003, UniErrors.get(1302003)!); options.fail?.(err) options.complete?.(err) return @@ -1567,7 +1566,7 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(filePath, false) if (!isSandyBox) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) return @@ -1590,14 +1589,14 @@ class AndroidFileSystemManager implements FileSystemManager { && optFlag != 'w+' && optFlag != 'wx' && optFlag != 'wx+') { - throw new UniError(FileSystemManagerUniErrorSubject, 1302003, msgPrefix + FileSystemManagerUniErrors.get(1302003)!) + throw new UniError(UniErrorSubject, 1302003, msgPrefix + UniErrors.get(1302003)!) } let filePath = UTSAndroid.convert2AbsFullPath(options.filePath) let isSandyBox = isSandyBoxPath(filePath, false) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1300013)!) + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1300013)!) } return this.fileDesUtil.openSync(options, new File(filePath)) } @@ -1611,7 +1610,7 @@ class AndroidFileSystemManager implements FileSystemManager { if (!isSandyBox) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.tempFilePath); options.fail?.(err) options.complete?.(err) }, null) @@ -1623,7 +1622,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 文件不存在 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.tempFilePath); options.fail?.(err) options.complete?.(err) }, null) @@ -1638,7 +1637,7 @@ class AndroidFileSystemManager implements FileSystemManager { isSandyBox = isSandyBoxPath(newFilePath, false) if (!isSandyBox) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) }, null) @@ -1651,7 +1650,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 父文件不存在 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) }, null) @@ -1662,7 +1661,7 @@ class AndroidFileSystemManager implements FileSystemManager { if (!copyRetFile.exists()) { // 调用系统api 失败 currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300201); + let err = new UniError(UniErrorSubject, 1300201, UniErrors.get(1300201)!); options.fail?.(err) options.complete?.(err) }, null) @@ -1687,14 +1686,14 @@ class AndroidFileSystemManager implements FileSystemManager { let isSandyBox = isSandyBoxPath(tfPath, true) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1300013)!) + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1300013)!) } let targetFile = new File(tfPath) if (!targetFile.exists()) { /** * 文件不存在 */ - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!) } let fp = filePath if (fp == null) { @@ -1704,7 +1703,7 @@ class AndroidFileSystemManager implements FileSystemManager { let newFilePath = UTSAndroid.convert2AbsFullPath(fp + targetFile.getName()) isSandyBox = isSandyBoxPath(newFilePath, false) if (!isSandyBox) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300013, msgPrefix + FileSystemManagerUniErrors.get(1300013)!) + throw new UniError(UniErrorSubject, 1300013, msgPrefix + UniErrors.get(1300013)!) } let newFile = new File(newFilePath) console.log(newFile.getPath()) @@ -1712,13 +1711,13 @@ class AndroidFileSystemManager implements FileSystemManager { /** * 父文件不存在 */ - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!) } let copyRetFile = targetFile.copyTo(newFile, true) if (!copyRetFile.exists()) { // 调用系统api 失败 - throw new UniError(FileSystemManagerUniErrorSubject, 1300201, msgPrefix + FileSystemManagerUniErrors.get(1300201)!) + throw new UniError(UniErrorSubject, 1300201, msgPrefix + UniErrors.get(1300201)!) } targetFile.delete() return newFilePath @@ -1727,73 +1726,56 @@ class AndroidFileSystemManager implements FileSystemManager { let msgPrefix = "unzip:fail " // 检查来源文件 let zipFilePath = UTSAndroid.convert2AbsFullPath(options.zipFilePath) - + let isSandyBox = isSandyBoxPath(zipFilePath, true) let currentDispatcher = UTSAndroid.getDispatcher("main") UTSAndroid.getDispatcher('io').async(function (_) { - let is:InputStream; + if (!isSandyBox) { + currentDispatcher.async(function (_) { + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.zipFilePath); + options.fail?.(err) + options.complete?.(err) + }, null) + return + } + let zipFile = new File(zipFilePath) + if (!zipFile.exists()) { + /** + * 文件不存在 + */ + currentDispatcher.async(function (_) { + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.zipFilePath); + options.fail?.(err) + options.complete?.(err) + }, null) + return + } + let targetPath = UTSAndroid.convert2AbsFullPath(options.targetPath) - if (zipFilePath.startsWith("/android_asset/")) { - try { - let assetName = zipFilePath.substring("/android_asset/".length) - is = UTSAndroid.getAppContext()!.getResources().getAssets().open(assetName); - } catch (e : Exception) { - /** - * 文件不存在 - */ - currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); - options.fail?.(err) - options.complete?.(err) - }, null) - return - } - } else { - let isSandyBox = isSandyBoxPath(zipFilePath, true) - if (!isSandyBox) { - currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); - options.fail?.(err) - options.complete?.(err) - }, null) - return - } - let zipFile = new File(zipFilePath) - if (!zipFile.exists()) { - /** - * 文件不存在 - */ - currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); - options.fail?.(err) - options.complete?.(err) - }, null) - return - } - - isSandyBox = isSandyBoxPath(targetPath, true) - let targetFile = new File(targetPath) - if (!isSandyBox) { - currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300013); - options.fail?.(err) - options.complete?.(err) - }, null) - return - - } - if (!targetFile.exists() || !targetFile.isDirectory()) { - currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); - options.fail?.(err) - options.complete?.(err) - }, null) - return - } - is = new FileInputStream(zipFile); + isSandyBox = isSandyBoxPath(targetPath, true) + let targetFile = new File(targetPath) + if (!isSandyBox) { + currentDispatcher.async(function (_) { + let err = new UniError(UniErrorSubject, 1300013, UniErrors.get(1300013)! + ":" + options.zipFilePath); + options.fail?.(err) + options.complete?.(err) + }, null) + return + } - + if (!targetFile.exists() || !targetFile.isDirectory()) { + currentDispatcher.async(function (_) { + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + options.zipFilePath); + options.fail?.(err) + options.complete?.(err) + }, null) + return + } + + try { + let is = new FileInputStream(zipFile); let zis = new ZipInputStream(new BufferedInputStream(is)); + console.log(zipFile.getPath()) let buffer = new ByteArray(1024) let count : number = 0; let ze = zis.getNextEntry() @@ -1837,7 +1819,7 @@ class AndroidFileSystemManager implements FileSystemManager { } catch (e : Exception) { console.log(e.message) currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300201); + let err = new UniError(UniErrorSubject, 1300201, UniErrors.get(1300201)! + ":" + options.zipFilePath); options.fail?.(err) options.complete?.(err) }, null) @@ -1859,7 +1841,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 文件不存在,或者不是文件夹,异常 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + filePath); options.fail?.(err) options.complete?.(err) }, null) @@ -1900,7 +1882,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 文件不存在,或者是文件夹,异常 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + filePath); options.fail?.(err) options.complete?.(err) }, null) @@ -1936,7 +1918,7 @@ class AndroidFileSystemManager implements FileSystemManager { /** * 文件不存在,或者是文件夹,异常 */ - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!) } let content = targetFile.readText() @@ -1949,58 +1931,38 @@ class AndroidFileSystemManager implements FileSystemManager { readCompressedFile(options : ReadCompressedFileOptions) { let currentDispatcher = UTSAndroid.getDispatcher("main") UTSAndroid.getDispatcher('io').async(function (_) { - let success : ReadCompressedFileResult = { - data: "" - } - let is:InputStream let filePath = UTSAndroid.convert2AbsFullPath(options.filePath) - if (filePath.startsWith("/android_asset/")) { - try { - let assetName = filePath.substring("/android_asset/".length) - is = UTSAndroid.getAppContext()!.getResources().getAssets().open(assetName); - - } catch (e : Exception) { - /** - * 文件不存在,或者是文件夹,异常 - */ - currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); - options.fail?.(err) - options.complete?.(err) - }, null) - return - } - } else { - let targetFile = new File(filePath) - if (!targetFile.exists() || targetFile.isDirectory()) { - /** - * 文件不存在,或者是文件夹,异常 - */ - currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); - options.fail?.(err) - options.complete?.(err) - }, null) - return - } - if (options.compressionAlgorithm != 'br') { - currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1301111); - options.fail?.(err) - options.complete?.(err) - }, null) - return - } - is = new FileInputStream(targetFile) + let targetFile = new File(filePath) + if (!targetFile.exists() || targetFile.isDirectory()) { + /** + * 文件不存在,或者是文件夹,异常 + */ + currentDispatcher.async(function (_) { + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + filePath); + options.fail?.(err) + options.complete?.(err) + }, null) + return + } + if (options.compressionAlgorithm != 'br') { + currentDispatcher.async(function (_) { + let err = new UniError(UniErrorSubject, 1301111, UniErrors.get(1301111)! + ":" + filePath); + options.fail?.(err) + options.complete?.(err) + }, null) + return + } + let success : ReadCompressedFileResult = { + data: "" } try { - let brInput = new BrotliInputStream(is) + let brInput = new BrotliInputStream(new FileInputStream(targetFile)) success.data = new String(brInput.readBytes()) brInput.close() } catch (e : Exception) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300201); + let err = new UniError(UniErrorSubject, 1300201, UniErrors.get(1300201)! + ":" + filePath); options.fail?.(err) options.complete?.(err) }, null) @@ -2016,36 +1978,23 @@ class AndroidFileSystemManager implements FileSystemManager { readCompressedFileSync(filePath : string, compressionAlgorithm : string) : string { let msgPrefix = "readCompressedFileSync:fail " let tempFilePath = UTSAndroid.convert2AbsFullPath(filePath) - let is : InputStream - if (tempFilePath.startsWith("/android_asset/")) { - try { - let assetName = tempFilePath.substring("/android_asset/".length) - is = UTSAndroid.getAppContext()!.getResources().getAssets().open(assetName); - - } catch (e : Exception) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) - } - } else { - let targetFile = new File(tempFilePath) - if (!targetFile.exists() || targetFile.isDirectory()) { - /** - * 文件不存在,或者是文件夹,异常 - */ - throw new UniError(FileSystemManagerUniErrorSubject, 1300002, msgPrefix + FileSystemManagerUniErrors.get(1300002)!) - } - if (compressionAlgorithm != 'br') { - throw new UniError(FileSystemManagerUniErrorSubject, 1301111, msgPrefix + FileSystemManagerUniErrors.get(1301111)!) - } - is = new FileInputStream(targetFile) + let targetFile = new File(tempFilePath) + if (!targetFile.exists() || targetFile.isDirectory()) { + /** + * 文件不存在,或者是文件夹,异常 + */ + throw new UniError(UniErrorSubject, 1300002, msgPrefix + UniErrors.get(1300002)!) + } + if (compressionAlgorithm != 'br') { + throw new UniError(UniErrorSubject, 1301111, msgPrefix + UniErrors.get(1301111)!) } let data : string - try { - let brInput = new BrotliInputStream(is) + let brInput = new BrotliInputStream(new FileInputStream(targetFile)) data = new String(brInput.readBytes()) brInput.close() } catch (e : Exception) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300201, msgPrefix + FileSystemManagerUniErrors.get(1300201)!) + throw new UniError(UniErrorSubject, 1300201, msgPrefix + UniErrors.get(1300201)!) } return data } @@ -2061,7 +2010,7 @@ class AndroidFileSystemManager implements FileSystemManager { * 文件不存在,或者是文件夹,异常 */ currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300002); + let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)! + ":" + filePath); options.fail?.(err) options.complete?.(err) }, null) @@ -2081,7 +2030,7 @@ class AndroidFileSystemManager implements FileSystemManager { public write(options : WriteOptions) { console.log(JSON.stringify(options)) if (options.encoding.toLowerCase() != 'base64' && options.encoding.toLowerCase() != 'utf-8' && options.encoding.toLowerCase() != 'ascii') { - let err = new FileSystemManagerFailImpl(1200002); + let err = new UniError(UniErrorSubject, 1200002, UniErrors.get(1200002)!); options.fail?.(err) options.complete?.(err) return @@ -2093,7 +2042,7 @@ class AndroidFileSystemManager implements FileSystemManager { let fd = ParcelFileDescriptor.fromFd(options.fd.toInt()) if (fd == null) { - let err = new FileSystemManagerFailImpl(1300009); + let err = new UniError(UniErrorSubject, 1300009, UniErrors.get(1300009)!); options.fail?.(err) options.complete?.(err) return @@ -2140,11 +2089,11 @@ class AndroidFileSystemManager implements FileSystemManager { public writeSync(options : WriteSyncOptions) : WriteResult { let msgPrefix = "writeSync:fail " if (options.encoding.toLowerCase() != 'base64' && options.encoding.toLowerCase() != 'utf-8' && options.encoding.toLowerCase() != 'ascii') { - throw new UniError(FileSystemManagerUniErrorSubject, 1200002, msgPrefix + FileSystemManagerUniErrors.get(1200002)!) + throw new UniError(UniErrorSubject, 1200002, msgPrefix + UniErrors.get(1200002)!) } let fd = ParcelFileDescriptor.fromFd(options.fd.toInt()) if (fd == null) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300009, msgPrefix + FileSystemManagerUniErrors.get(1300009)!) + throw new UniError(UniErrorSubject, 1300009, msgPrefix + UniErrors.get(1300009)!) } try { let outStream = new FileOutputStream(fd.getFileDescriptor()) @@ -2176,7 +2125,7 @@ class AndroidFileSystemManager implements FileSystemManager { fileChannel.write(buffer, 0) } } catch (e) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300201, msgPrefix + FileSystemManagerUniErrors.get(1300201)!) + throw new UniError(UniErrorSubject, 1300201, msgPrefix + UniErrors.get(1300201)!) } let ret : WriteResult = { bytesWritten: options.data.length @@ -2198,7 +2147,7 @@ class AndroidFileSystemManager implements FileSystemManager { options.success?.(success) options.complete?.(success) } catch (e) { - let err = new FileSystemManagerFailImpl(1300009); + let err = new UniError(UniErrorSubject, 1300009, UniErrors.get(1300009)!); options.fail?.(err) options.complete?.(err) } @@ -2213,7 +2162,7 @@ class AndroidFileSystemManager implements FileSystemManager { this.fileDesUtil.openMap.delete(options.fd) } } catch (e) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300009, msgPrefix + FileSystemManagerUniErrors.get(1300009)!) + throw new UniError(UniErrorSubject, 1300009, msgPrefix + UniErrors.get(1300009)!) } } public fstat(options : FStatOptions) { @@ -2222,7 +2171,7 @@ class AndroidFileSystemManager implements FileSystemManager { currentDispatcher.async(function (_) { if (!this.fileDesUtil.openMap.has(options.fd)) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300009); + let err = new UniError(UniErrorSubject, 1300009, UniErrors.get(1300009)! + ":" + options.fd); options.fail?.(err) options.complete?.(err) }, null) @@ -2239,7 +2188,7 @@ class AndroidFileSystemManager implements FileSystemManager { public fstatSync(options : FStatSyncOptions) : Stats { let msgPrefix = "ftruncateSync:fail " if (!this.fileDesUtil.openMap.has(options.fd)) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300009, msgPrefix + FileSystemManagerUniErrors.get(1300009)!) + throw new UniError(UniErrorSubject, 1300009, msgPrefix + UniErrors.get(1300009)!) } return wrapStats(this.fileDesUtil.openMap.get(options.fd)!) } @@ -2248,7 +2197,7 @@ class AndroidFileSystemManager implements FileSystemManager { UTSAndroid.getDispatcher('io').async(function (_) { if (!this.fileDesUtil.openMap.has(options.fd)) { currentDispatcher.async(function (_) { - let err = new FileSystemManagerFailImpl(1300009); + let err = new UniError(UniErrorSubject, 1300009, UniErrors.get(1300009)! + ":" + options.fd); options.fail?.(err) options.complete?.(err) }, null) @@ -2273,7 +2222,7 @@ class AndroidFileSystemManager implements FileSystemManager { public ftruncateSync(options : FTruncateFileSyncOptions) { let msgPrefix = "ftruncateSync:fail " if (!this.fileDesUtil.openMap.has(options.fd)) { - throw new UniError(FileSystemManagerUniErrorSubject, 1300009, msgPrefix + FileSystemManagerUniErrors.get(1300009)!) + throw new UniError(UniErrorSubject, 1300009, msgPrefix + UniErrors.get(1300009)!) } let targetFile = this.fileDesUtil.openMap.get(options.fd) let content = targetFile!.readText() @@ -2286,14 +2235,14 @@ class AndroidFileSystemManager implements FileSystemManager { public readZipEntry(options : ReadZipEntryOptions) { let targetPath = uni.env.CACHE_PATH + "/" + Base64.encodeToString(options.filePath.toByteArray(), Base64.NO_WRAP) targetPath = UTSAndroid.convert2AbsFullPath(targetPath) + console.log("readZipEntry", targetPath) let file : File = new File(targetPath) if (!file.exists()) { file.mkdirs() } - let target = this - let zipOptions : uts.sdk.modules.uniFileSystemManager.UnzipFileOptions = {//todo 需要去掉 + let zipOptions : UnzipFileOptions = { zipFilePath: options.filePath, targetPath: targetPath, success: (_) => { @@ -2305,6 +2254,7 @@ class AndroidFileSystemManager implements FileSystemManager { filterEntries?.forEach((item) => { let fileItem = new File(targetPath + "/" + item.path) + console.log("readZipEntry", file.getPath()) if (!fileItem.exists() || fileItem.isDirectory()) { let zipFileItem : ZipFileItem = { errMsg: 'no such file' @@ -2363,8 +2313,8 @@ class AndroidFileSystemManager implements FileSystemManager { targetFile.delete() }) }, - fail: (res) => { - let err = new FileSystemManagerFailImpl(res.errCode); + fail: (res : UniError) => { + let err = new UniError(UniErrorSubject, res.errCode, res.errMsg); options.fail?.(err) options.complete?.(err) } diff --git a/uni_modules/uni-fileSystemManager/utssdk/app-js/index.uts b/uni_modules/uni-fileSystemManager/utssdk/app-js/index.uts index ce098f5895a2e2f32a3ec9d0487a9c9b28e8a544..4afebccd908db6eb7bd34f79bf44d2b4b913a9c1 100644 --- a/uni_modules/uni-fileSystemManager/utssdk/app-js/index.uts +++ b/uni_modules/uni-fileSystemManager/utssdk/app-js/index.uts @@ -1,7 +1,8 @@ import { WriteFileOptions, ReadFileOptions, MkDirOptions, RmDirOptions, UnLinkOptions, ReadDirOptions, AccessOptions, RenameOptions, GetFileInfoOptions, CopyFileOptions, StatOptions } from "../interface.uts" import { ReadFileSuccessResult, FileManagerSuccessResult, ReadDirSuccessResult, GetFileInfoSuccessResult, StatSuccessResult, FileStats, Stats } from "../interface.uts" import { GetFileSystemManager, FileSystemManager } from "../interface.uts" -import { FileSystemManagerFailImpl, FileSystemManagerUniErrorSubject, FileSystemManagerUniErrors } from "../unierror.uts" +import { UniErrorSubject, UniErrors } from "../unierror.uts" +export { Stats,FileStats } from '../interface.uts' class InnerStats implements Stats { /** @@ -92,7 +93,7 @@ class JsFileSystemManager implements FileSystemManager { options.complete?.(ret) }, function (code) { - let err = new FileSystemManagerFailImpl(code) + let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.path); options.fail?.(err) options.complete?.(err) }) @@ -102,7 +103,7 @@ class JsFileSystemManager implements FileSystemManager { if(options.digestAlgorithm == null || options.digestAlgorithm == undefined){ options.digestAlgorithm = "md5" } else if (options.digestAlgorithm!.toLowerCase() != 'md5' && options.digestAlgorithm!.toLowerCase() != 'sha1') { - let err = new FileSystemManagerFailImpl(1300022); + let err = new UniError(UniErrorSubject, 1300022, UniErrors.get(1300022)! + ":invalid digestAlgorithm " + options.digestAlgorithm); options.fail?.(err) options.complete?.(err) return @@ -116,7 +117,7 @@ class JsFileSystemManager implements FileSystemManager { options.complete?.(ret) }, function (code) { - let err = new FileSystemManagerFailImpl(code); + let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) }) @@ -135,7 +136,7 @@ class JsFileSystemManager implements FileSystemManager { options.complete?.(ret) }, function (code) { - let err = new FileSystemManagerFailImpl(code); + let err = new UniError(UniErrorSubject, code, UniErrors.get(code)!); options.fail?.(err) options.complete?.(err) }) @@ -154,7 +155,7 @@ class JsFileSystemManager implements FileSystemManager { options.complete?.(ret) }, function (code) { - let err = new FileSystemManagerFailImpl(code); + let err = new UniError(UniErrorSubject, code, UniErrors.get(code)!); options.fail?.(err) options.complete?.(err) }) @@ -172,7 +173,7 @@ class JsFileSystemManager implements FileSystemManager { options.complete?.(ret) }, function (code) { - let err = new FileSystemManagerFailImpl(code); + let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.path); options.fail?.(err) options.complete?.(err) }) @@ -190,7 +191,7 @@ class JsFileSystemManager implements FileSystemManager { options.complete?.(ret) }, function (code) { - let err = new FileSystemManagerFailImpl(code); + let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.dirPath); options.fail?.(err) options.complete?.(err) }) @@ -213,7 +214,7 @@ class JsFileSystemManager implements FileSystemManager { options.complete?.(ret) }, function (code) { - let err = new FileSystemManagerFailImpl(code); + let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.dirPath); options.fail?.(err) options.complete?.(err) }) @@ -228,7 +229,7 @@ class JsFileSystemManager implements FileSystemManager { options.complete?.(ret) }, function (code) { - let err = new FileSystemManagerFailImpl(code); + let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.dirPath); options.fail?.(err) options.complete?.(err) }) @@ -247,7 +248,7 @@ class JsFileSystemManager implements FileSystemManager { options.complete?.(ret) }, function (code) { - let err = new FileSystemManagerFailImpl(code); + let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) }) @@ -265,7 +266,7 @@ class JsFileSystemManager implements FileSystemManager { options.complete?.(ret) }, function (code) { - let err = new FileSystemManagerFailImpl(code); + let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) }) @@ -285,7 +286,7 @@ class JsFileSystemManager implements FileSystemManager { options.complete?.(ret) }, function (code) { - let err = new FileSystemManagerFailImpl(code); + let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.filePath); options.fail?.(err) options.complete?.(err) }) diff --git a/uni_modules/uni-fileSystemManager/utssdk/interface.uts b/uni_modules/uni-fileSystemManager/utssdk/interface.uts index e55544ef920b88943194bbe84ca32d0470581166..99da5c0effb36687fc3e1744ff9a2c311fed93bb 100644 --- a/uni_modules/uni-fileSystemManager/utssdk/interface.uts +++ b/uni_modules/uni-fileSystemManager/utssdk/interface.uts @@ -21,7 +21,7 @@ export type FileManagerSuccessCallback = (res : FileManagerSuccessResult) => voi /** * 通用的错误返回结果回调 */ -export type FileManagerFailCallback = (res : FileSystemManagerFail) => void +export type FileManagerFailCallback = (res : UniError) => void /** * 通用的结束返回结果回调 */ @@ -39,7 +39,7 @@ export type ReadFileOptions = { */ encoding : "base64" | "utf-8", /** - * 文件路径,支持相对地址和绝对地址,app-android平台支持代码包文件目录 + * 文件路径,支持相对地址和绝对地址 */ filePath : string.URIString, /** @@ -553,7 +553,7 @@ export type ReadCompressedFileResult = { export type ReadCompressedFileCallback = (res : ReadCompressedFileResult) => void export type ReadCompressedFileOptions = { /** - * 要读取的文件的路径 (本地用户文件或代码包文件),app-android平台支持代码包文件目录 + * 要读取的文件的路径 (本地用户文件或代码包文件) */ filePath : string.URIString, /** @@ -779,7 +779,7 @@ export type ZipFileItem = { export type ReadZipEntryCallback = (res : EntriesResult) => void export type ReadZipEntryOptions = { /** - * 要读取的压缩包的路径 (本地路径),app-android平台支持代码包文件目录 + * 要读取的压缩包的路径 (本地路径) */ filePath : string.URIString, /** @@ -829,8 +829,6 @@ export interface FileSystemManager { readFile(options : ReadFileOptions) : void; /** * FileSystemManager.readFile 的同步版本参数 - * @param 文件路径,支持相对地址和绝对地址,app-android平台支持代码包文件目录 - * @param base64 / utf-8 * @uniPlatform { * "app": { * "android": { @@ -875,9 +873,6 @@ export interface FileSystemManager { writeFile(options : WriteFileOptions) : void; /** * FileSystemManager.writeFile 的同步版本 - * @param 文件路径,只支持绝对地址 - * @param 写入的文本内容 - * @param 指定写入文件的字符编码,支持:ascii base64 utf-8 * @uniPlatform { * "app": { * "android": { @@ -922,7 +917,6 @@ export interface FileSystemManager { unlink(options : UnLinkOptions) : void; /** * FileSystemManager.unlink 的同步版本 - * @param 文件路径,只支持绝对地址 * @uniPlatform { * "app": { * "android": { @@ -967,8 +961,6 @@ export interface FileSystemManager { mkdir(options : MkDirOptions) : void; /** * FileSystemManager.mkdir 的同步版本 - * @param 创建的目录路径 (本地路径) - * @param 是否在递归创建该目录的上级目录后再创建该目录。如果对应的上级目录已经存在,则不创建该上级目录。如 dirPath 为 a/b/c/d 且 recursive 为 true,将创建 a 目录,再在 a 目录下创建 b 目录,以此类推直至创建 a/b/c 目录下的 d 目录。 * @uniPlatform { * "app": { * "android": { @@ -1013,8 +1005,6 @@ export interface FileSystemManager { rmdir(options : RmDirOptions) : void; /** * FileSystemManager.rmdir 的同步版本 - * @param 要删除的目录路径 (本地路径) - * @param 是否递归删除目录。如果为 true,则删除该目录和该目录下的所有子目录以及文件。 * @uniPlatform { * "app": { * "android": { @@ -1059,7 +1049,6 @@ export interface FileSystemManager { readdir(options : ReadDirOptions) : void; /** * FileSystemManager.readdir 的同步版本 - * @param 要读取的目录路径 (本地路径) * @uniPlatform { * "app": { * "android": { @@ -1104,7 +1093,6 @@ export interface FileSystemManager { access(options : AccessOptions) : void; /** * FileSystemManager.access 的同步版本 - * @param 要删除的目录路径 (本地路径) * @uniPlatform { * "app": { * "android": { @@ -1149,8 +1137,6 @@ export interface FileSystemManager { rename(options : RenameOptions) : void; /** * FileSystemManager.rename 的同步版本 - * @param 源文件路径,支持本地路径 - * @param 新文件路径,支持本地路径 * @uniPlatform { * "app": { * "android": { @@ -1195,8 +1181,6 @@ export interface FileSystemManager { copyFile(options : CopyFileOptions) : void; /** * FileSystemManager.copyFile 的同步版本 - * @param 源文件路径,支持本地路径 - * @param 新文件路径,支持本地路径 * @uniPlatform { * "app": { * "android": { @@ -1263,8 +1247,6 @@ export interface FileSystemManager { stat(options : StatOptions) : void; /** * FileSystemManager.stat 的同步版本 - * @param 文件/目录路径 (本地路径) - * @param 是否递归获取目录下的每个文件的 Stats 信息 * @uniPlatform { * "app": { * "android": { @@ -1309,9 +1291,6 @@ export interface FileSystemManager { appendFile(options : AppendFileOptions) : void; /** * FileSystemManager.appendFile 的同步版本 - * @param 要追加内容的文件路径 (本地路径) - * @param 要追加的文本 - * @param 指定写入文件的字符编码支持:ascii base64 utf-8 * @uniPlatform { * "app": { * "android": { @@ -1802,26 +1781,4 @@ export interface Uni { * @uniVueVersion 2,3 //支持的vue版本 */ getFileSystemManager() : FileSystemManager -} - -/** - * 错误码 - * - 1200002 类型错误。仅支持 base64 / utf-8 - * - 1300002 未找到文件 - * - 1300013 无权限 - * - 1300021 是目录 - * - 1300022 参数无效 - * - 1300066 目录非空 - * - 1301003 对目录的非法操作 - * - 1301005 文件已存在 - * - 1300201 系统错误 - * - 1300202 超出文件存储限制的最大尺寸 - * - 1301111 brotli解压失败 - * - 1302003 标志无效 - * - 1300009 文件描述符错误 - */ -export type FileSystemManagerErrorCode = 1200002 | 1300002 | 1300013 | 1300021 | 1300022 | 1300066 | 1301003 | 1301005 | 1300201 | 1300202 | 1301111 | 1302003 | 1300009; -export type FileSystemManagerFail = IFileSystemManagerFail; -export interface IFileSystemManagerFail extends IUniError { - errCode : FileSystemManagerErrorCode -}; +} \ No newline at end of file diff --git a/uni_modules/uni-fileSystemManager/utssdk/unierror.uts b/uni_modules/uni-fileSystemManager/utssdk/unierror.uts index bcca4b630b33fa4c030038c1842c3b431dbfa328..625585070237f1df3be368c5189d89b41de26ae8 100644 --- a/uni_modules/uni-fileSystemManager/utssdk/unierror.uts +++ b/uni_modules/uni-fileSystemManager/utssdk/unierror.uts @@ -1,15 +1,13 @@ -import { FileSystemManagerErrorCode,IFileSystemManagerFail } from "./interface.uts" - /** * 错误主题 */ -export const FileSystemManagerUniErrorSubject = 'uni-fileSystemManager'; +export const UniErrorSubject = 'uni-fileSystemManager'; /** * 错误码 * @UniError */ -export const FileSystemManagerUniErrors : Map = new Map([ +export const UniErrors : Map = new Map([ [1200002, 'type error. only support base64 / utf-8'], [1300002, 'no such file or directory'], @@ -24,12 +22,4 @@ export const FileSystemManagerUniErrors : Map App模块配置` 中配置 `Geolocation(定位)` 模块 * @type 'authorized' | 'denied' | 'not determined' | 'config error' - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "4.4", - * "uniVer": "√", - * "unixVer": "3.9" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ locationAuthorized: 'authorized' | 'denied' | 'not determined' | 'config error', /** @@ -137,21 +107,6 @@ export type GetAppAuthorizeSettingResult = { * - full: 精准定位 * - unsupported: 不支持(包括用户拒绝定位权限和没有在 `manifest.json -> App模块配置` 中配置 `Geolocation(定位)` 模块) * @type 'reduced' | 'full' | 'unsupported' - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "4.4", - * "uniVer": "√", - * "unixVer": "3.9" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ locationAccuracy?: 'reduced' | 'full' | 'unsupported' | null, /** @@ -181,21 +136,6 @@ export type GetAppAuthorizeSettingResult = { * - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关) * - config error: Android平台:表示没有配置 `android.permission.RECORD_AUDIO` 权限,[权限配置详情](https://uniapp.dcloud.net.cn/tutorial/app-nativeresource-android.html#permissions);iOS平台没有该值 * @type 'authorized' | 'denied' | 'not determined' | 'config error' - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "4.4", - * "uniVer": "√", - * "unixVer": "3.9" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ microphoneAuthorized: 'authorized' | 'denied' | 'not determined' | 'config error', /** @@ -205,21 +145,6 @@ export type GetAppAuthorizeSettingResult = { * - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关) * - config error: Android平台没有该值;iOS平台:表示没有在 `manifest.json -> App模块配置` 中配置 `Push(推送)` 模块 * @type 'authorized' | 'denied' | 'not determined' | 'config error' - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "4.4", - * "uniVer": "√", - * "unixVer": "3.9" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ notificationAuthorized: 'authorized' | 'denied' | 'not determined' | 'config error', /** diff --git a/uni_modules/uni-getAppBaseInfo/utssdk/interface.uts b/uni_modules/uni-getAppBaseInfo/utssdk/interface.uts index 926361eea4a347334bc3a9ef5bafe94079782f75..2d027a69173e39ea206f1163107eb04a82576fa4 100644 --- a/uni_modules/uni-getAppBaseInfo/utssdk/interface.uts +++ b/uni_modules/uni-getAppBaseInfo/utssdk/interface.uts @@ -8,143 +8,31 @@ export type GetAppBaseInfoOptions = { export type GetAppBaseInfoResult = { /** * manifest.json 中应用appid,即DCloud appid。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ appId?: string, /** * `manifest.json` 中应用名称。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ appName?: string, /** * `manifest.json` 中应用版本名称。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ appVersion?: string, /** * `manifest.json` 中应用版本名号。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ appVersionCode?: string, /** * 应用设置的语言en、zh-Hans、zh-Hant、fr、es - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ appLanguage?: string, /** * 应用设置的语言 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ language?: string, /** * 引擎版本号。已废弃,仅为了向下兼容保留 * @deprecated 已废弃,仅为了向下兼容保留 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ version?: string, /** @@ -317,48 +205,12 @@ export type GetAppBaseInfoResult = { hostTheme?: string, /** * 是否uni-app x - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } */ isUniAppX ?: boolean, /** * uni 编译器版本 * @deprecated 已废弃,仅为了向下兼容保留 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ uniCompileVersion ?: string, /** @@ -379,79 +231,23 @@ export type GetAppBaseInfoResult = { * } * }, * "web": { - * "uniVer": "x", - * "unixVer": "x" + * "uniVer": "√", + * "unixVer": "4.0" * } * } */ uniCompilerVersion ?: string, /** * uni-app 运行平台。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ uniPlatform ?: 'app' | 'web' | 'mp-weixin' | 'mp-alipay' | 'mp-baidu' | 'mp-toutiao' | 'mp-lark' | 'mp-qq' | 'mp-kuaishou' | 'mp-jd' | 'mp-360' | 'quickapp-webview' | 'quickapp-webview-union' | 'quickapp-webview-huawei', /** * uni 运行时版本 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } */ uniRuntimeVersion ?: string, /** * uni 编译器版本号 * @deprecated 已废弃,仅为了向下兼容保留 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } */ uniCompileVersionCode?: number, /** @@ -472,34 +268,14 @@ export type GetAppBaseInfoResult = { * } * }, * "web": { - * "uniVer": "x", - * "unixVer": "x" + * "uniVer": "√", + * "unixVer": "4.0" * } * } */ uniCompilerVersionCode?: number, /** * uni 运行时版本号 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } */ uniRuntimeVersionCode?: number, /** diff --git a/uni_modules/uni-getDeviceInfo/utssdk/interface.uts b/uni_modules/uni-getDeviceInfo/utssdk/interface.uts index 85d4e4668b0d11b794262487146ebccc2736f40f..0e669e5cfe81cbe42e0097dd5b20583149ff12aa 100644 --- a/uni_modules/uni-getDeviceInfo/utssdk/interface.uts +++ b/uni_modules/uni-getDeviceInfo/utssdk/interface.uts @@ -1,367 +1,121 @@ -export type GetDeviceInfoOptions = { - /** - * @description 过滤字段的字符串数组,假如要获取指定字段,传入此数组。 - */ - filter: Array -} - -export type GetDeviceInfoResult = { - /** - * 设备品牌 - * @deprecated 已废弃,仅为了向下兼容保留 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } - */ - brand?: string - /** - * 设备品牌 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } - */ - deviceBrand?: string, - /** - * 设备 id 。由 uni-app 框架生成并存储,清空 Storage 会导致改变 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - deviceId?: string, - /** - * 设备型号 - * @deprecated 已废弃,仅为了向下兼容保留 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - model?: string, - /** - * 设备型号 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - deviceModel?: string, - /** - * 设备类型phone、pad、pc - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - deviceType?: string, - /** - * 设备方向 竖屏 portrait、横屏 landscape - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - deviceOrientation?: string, - /** - * 设备像素比 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - devicePixelRatio?: string, - /** - * 操作系统及版本 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - system?: string, - /** - * 客户端平台 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - platform?: string, - /** - * 是否root - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "x", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "x", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } - */ - isRoot?: boolean, - /** - * 是否是模拟器 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "x", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "x", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } - */ - isSimulator?: boolean, - /** - * adb是否开启 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "x", - * "unixVer": "√" - * }, - * "ios": { - * "osVer": "x", - * "uniVer": "x", - * "unixVer": "x" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } - */ - isUSBDebugging?: boolean, -} - - -/** - * @param [options=包含所有字段的过滤对象] 过滤的字段对象, 不传参数默认为获取全部字段。 - */ -export type GetDeviceInfo = (options?: GetDeviceInfoOptions | null) => GetDeviceInfoResult; - - -export interface Uni { - /** - * GetDeviceInfo(Object object) - * @description - * 获取设备信息 - * @param {GetDeviceInfoOptions} options [options=包含所有字段的过滤对象] 过滤的字段对象, 不传参数默认为获取全部字段。 - * @return {object} - * @tutorial https://uniapp.dcloud.net.cn/api/system/getDeviceInfo.html - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - * @example - ```typescript - uni.getDeviceInfo({ - filter:[] - }) - ``` - */ - getDeviceInfo(options?: GetDeviceInfoOptions | null): GetDeviceInfoResult; -} +export type GetDeviceInfoOptions = { + /** + * @description 过滤字段的字符串数组,假如要获取指定字段,传入此数组。 + */ + filter: Array +} + +export type GetDeviceInfoResult = { + /** + * 设备品牌 + */ + brand?: string + /** + * 设备品牌 + */ + deviceBrand?: string, + /** + * 设备 id 。由 uni-app 框架生成并存储,清空 Storage 会导致改变 + */ + deviceId?: string, + /** + * 设备型号 + */ + model?: string, + /** + * 设备型号 + */ + deviceModel?: string, + /** + * 设备类型phone、pad、pc + */ + deviceType?: string, + /** + * 设备方向 竖屏 portrait、横屏 landscape + */ + deviceOrientation?: string, + /** + * 设备像素比 + */ + devicePixelRatio?: string, + /** + * 操作系统及版本 + */ + system?: string, + /** + * 客户端平台 + */ + platform?: string, + /** + * 是否root + */ + isRoot?: boolean, + /** + * 是否是模拟器 + */ + isSimulator?: boolean, + /** + * adb是否开启 + * + * @uniPlatform + * { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "x", + * "unixVer": "√" + * }, + * "ios": { + * "osVer": "x", + * "uniVer": "x", + * "unixVer": "x" + * } + * } + * } + */ + isUSBDebugging?: boolean, +} + + +/** + * @param [options=包含所有字段的过滤对象] 过滤的字段对象, 不传参数默认为获取全部字段。 + */ +export type GetDeviceInfo = (options?: GetDeviceInfoOptions | null) => GetDeviceInfoResult; + + +export interface Uni { + /** + * GetDeviceInfo(Object object) + * @description + * 获取设备信息 + * @param {GetDeviceInfoOptions} options [options=包含所有字段的过滤对象] 过滤的字段对象, 不传参数默认为获取全部字段。 + * @return {object} + * @tutorial https://uniapp.dcloud.net.cn/api/system/getDeviceInfo.html + * @uniPlatform + * { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "3.9+" + * }, + * "ios": { + * "osVer": "12.0", + * "uniVer": "√", + * "unixVer": "4.11" + * } + * }, + * "web": { + * "uniVer": "√", + * "unixVer": "4.0" + * } + * } + * @example + ```typescript + uni.getDeviceInfo({ + filter:[] + }) + ``` + */ + getDeviceInfo(options?: GetDeviceInfoOptions | null): GetDeviceInfoResult; +} diff --git a/uni_modules/uni-getLocation-system/utssdk/interface.uts b/uni_modules/uni-getLocation-system/utssdk/interface.uts index 9e5f4b1c107d6a6aaded10394bc93bbc00b4360d..c3b7659baa70b4986df0e112a4876264c82451f1 100644 --- a/uni_modules/uni-getLocation-system/utssdk/interface.uts +++ b/uni_modules/uni-getLocation-system/utssdk/interface.uts @@ -22,16 +22,16 @@ export interface Uni { * "unixVer": "3.9.0" * }, * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" + * "osVer": "x", + * "uniVer": "x", + * "unixVer": "x" * } * }, * "web": { * "uniVer": "√", * "unixVer": "4.0" * } - * } + * }9999 * */ getLocation(options: GetLocationOptions):void; diff --git a/uni_modules/uni-getNetworkType/utssdk/interface.uts b/uni_modules/uni-getNetworkType/utssdk/interface.uts index f14e452e210b7d0f60f52cf04459d16bd1db42ad..d96b8169d3cb5ccb5ef43a0917ad7b5a84490546 100644 --- a/uni_modules/uni-getNetworkType/utssdk/interface.uts +++ b/uni_modules/uni-getNetworkType/utssdk/interface.uts @@ -15,9 +15,9 @@ export interface Uni { * "unixVer": "3.9+" * }, * "ios": { - * "osVer": "12.0", + * "osVer": "9.0", * "uniVer": "√", - * "unixVer": "4.11" + * "unixVer": "4.06" * } * }, * "web": { diff --git a/uni_modules/uni-getSystemInfo/utssdk/interface.uts b/uni_modules/uni-getSystemInfo/utssdk/interface.uts index 19dd650e1cf1913574ef6a4deae945e731f4f7ef..706c4ebc6d2d56b2dbd31955f1aee1f6f527eefa 100644 --- a/uni_modules/uni-getSystemInfo/utssdk/interface.uts +++ b/uni_modules/uni-getSystemInfo/utssdk/interface.uts @@ -1,1752 +1,462 @@ -export interface Uni { - /** - * getSystemInfo() - * @description - * 异步获取系统信息 - * @param {GetSystemInfoOptions} options - * @return {void} - * @tutorial http://uniapp.dcloud.io/api/system/info?id=getsysteminfo - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - * @example - ```typescript - uni.getSystemInfo({ - success(e) { - console.log("success :",e); - }, - complete(e) { - console.log("complete :",e); - } - }) - ``` - */ - getSystemInfo(options: GetSystemInfoOptions): void; - - /** - * getSystemInfoSync() - * @description - * 同步获取系统信息 - * @param {void} - * @return {GetSystemInfoResult} - * @tutorial http://uniapp.dcloud.io/api/system/info?id=getsysteminfosync - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - * @example - ```typescript - uni.getSystemInfoSync() - ``` - */ - getSystemInfoSync(): GetSystemInfoResult; - - /** - * getWindowInfo() - * @description - * 同步获取窗口信息 - * @param {void} - * @return {GetWindowInfoResult} result - * @tutorial http://uniapp.dcloud.io/api/system/getWindowInfo.html - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - * @example - ```typescript - uni.getWindowInfo() - ``` - */ - getWindowInfo(): GetWindowInfoResult; -} - -export type GetSystemInfo = (options: GetSystemInfoOptions) => void; -export type GetSystemInfoSync = () => GetSystemInfoResult; -export type GetWindowInfo = () => GetWindowInfoResult; -export type SafeArea = { - /** - * 安全区域左上角横坐标,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - left: number, - /** - * 安全区域右下角横坐标,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - right: number, - /** - * 安全区域左上角纵坐标,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - top: number, - /** - * 安全区域右下角纵坐标,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - bottom: number, - /** - * 安全区域的宽度,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - width: number, - /** - * 安全区域的高度,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - height: number -}; -export type SafeAreaInsets = { - /** - * 安全区域左侧插入位置,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - left: number, - /** - * 安全区域右侧插入位置,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - right: number, - /** - * 安全区顶部插入位置,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - top: number, - /** - * 安全区域底部插入位置,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - bottom: number -}; -export type GetSystemInfoResult = { - /** - * 客户端基础库版本 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } - */ - SDKVersion: string, - /** - * `manifest.json` 中应用appid。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - appId: string, - /** - * 应用设置的语言。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - appLanguage: string, - /** - * `manifest.json` 中应用名称。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - appName: string, - /** - * `manifest.json` 中应用版本名称。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - appVersion: string, - /** - * `manifest.json` 中应用版本名号。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - appVersionCode: string, - /** - * 应用资源(wgt)的版本名称。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "x" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "x" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } - */ - appWgtVersion?: string | null, - /** - * 手机品牌。 - * @deprecated 已废弃,仅为了向下兼容保留 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } - */ - brand: string, - /** - * 浏览器名称。`App` 端是系统 webview 的名字,比如 wkwebview、chrome。小程序端为空 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - browserName: string, - /** - * 浏览器版本、webview 版本。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } - */ - browserVersion: string, - /** - * 设备 ID - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - deviceId: string, - /** - * 设备品牌。如:`apple`、`huawei`。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - deviceBrand: string, - /** - * 设备型号 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - deviceModel: string, - /** - * 设备类型。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - deviceType: 'phone' | 'pad' | 'tv' | 'watch' | 'pc' | 'undefined' | 'car' | 'vr' | 'appliance', - /** - * 设备像素比 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - devicePixelRatio: number, - /** - * 设备方向。 - * @type 'portrait' | 'landscape' - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - deviceOrientation: 'portrait' | 'landscape', - /** - * 程序设置的语言 - * @deprecated 已废弃,仅为了向下兼容保留 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - language: string, - /** - * 手机型号 - * @deprecated 已废弃,仅为了向下兼容保留 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - model: string, - /** - * 系统名称 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - osName: 'ios' | 'android' | 'mac' | 'windows' | 'linux', - /** - * 操作系统版本。如 ios 版本,andriod 版本 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - osVersion: string, - /** - * 操作系统语言 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - osLanguage: string, - /** - * 操作系统主题 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "√" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } - */ - osTheme?: 'light' | 'dark' | null, - /** - * 设备像素比 - * @deprecated 已废弃,仅为了向下兼容保留 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - pixelRatio: number, - /** - * 客户端平台 - * @deprecated 已废弃,仅为了向下兼容保留 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - platform: 'ios' | 'android' | 'mac' | 'windows' | 'linux', - /** - * 屏幕宽度,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - screenWidth: number, - /** - * 屏幕高度,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - screenHeight: number, - /** - * 状态栏的高度,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - statusBarHeight: number, - /** - * 操作系统版本 - * @deprecated 已废弃,仅为了向下兼容保留 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - system: string, - /** - * 在竖屏正方向下的安全区域 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - safeArea: SafeArea, - /** - * 在竖屏正方向下的安全区域插入位置 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - safeAreaInsets: SafeAreaInsets, - /** - * 用户标识。小程序端为空 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - ua: string, - /** - * uni 编译器版本。 - * @deprecated 已废弃,仅为了向下兼容保留 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - uniCompileVersion: string, - /** - * uni 编译器版本。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "x", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "x", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } - */ - uniCompilerVersion: string, - /** - * uni-app 运行平台,与条件编译平台相同。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - uniPlatform: 'app' | 'web' | 'mp-weixin' | 'mp-alipay' | 'mp-baidu' | 'mp-toutiao' | 'mp-lark' | 'mp-qq' | 'mp-kuaishou' | 'mp-jd' | 'mp-360' | 'quickapp-webview' | 'quickapp-webview-union' | 'quickapp-webview-huawei', - /** - * uni 运行时版本。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - uniRuntimeVersion: string, - /** - * uni 编译器版本号。 - * @deprecated 已废弃,仅为了向下兼容保留 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "x", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "x", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - uniCompileVersionCode: number, - /** - * uni 编译器版本号。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "x", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "x", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } - */ - uniCompilerVersionCode: number, - /** - * uni 运行时版本号。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "x", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "x", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - uniRuntimeVersionCode: number, - /** - * 引擎版本号。 - * @deprecated 已废弃,仅为了向下兼容保留 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - version: string, - /** - * rom 名称。Android 部分机型获取不到值。iOS 恒为 `ios` - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "x", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } - */ - romName: string, - /** - * rom 版本号。Android 部分机型获取不到值。iOS 为操作系统版本号(同 `osVersion`)。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "x", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } - */ - romVersion: string, - /** - * 可使用窗口宽度,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - windowWidth: number, - /** - * 可使用窗口高度,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - windowHeight: number, - /** - * 内容区域距离顶部的距离(同CSS变量 `--window-top`),单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - windowTop: number, - /** - * 内容区域距离底部的距离(同CSS变量 `--window-bottom`),单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - windowBottom: number, - /** - * Android 系统API库的版本。 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "√" - * }, - * "ios": { - * "osVer": "x", - * "uniVer": "x", - * "unixVer": "x" - * } - * }, - * "web": { - * "uniVer": "x", - * "unixVer": "x" - * } - * } - */ - osAndroidAPILevel?: number | null -}; -export type GetSystemInfoSuccessCallback = (result: GetSystemInfoResult) => void; -type GetSystemInfoFail = UniError; -type GetSystemInfoFailCallback = (result: GetSystemInfoFail) => void; -export type GetSystemInfoComplete = any; -export type GetSystemInfoCompleteCallback = (result: GetSystemInfoComplete) => void; -export type GetSystemInfoOptions = { - /** - * 接口调用成功的回调函数 - * @defaultValue null - */ - success?: GetSystemInfoSuccessCallback | null, - /** - * 接口调用失败的回调函数 - * @defaultValue null - */ - fail?: GetSystemInfoFailCallback | null, - /** - * 接口调用结束的回调函数(调用成功、失败都会执行) - * @defaultValue null - */ - complete?: GetSystemInfoCompleteCallback | null -}; - -export type GetWindowInfoResult = { - /** - * 设备像素比 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - pixelRatio: number, - /** - * 屏幕宽度,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - screenWidth: number, - /** - * 屏幕高度,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - screenHeight: number, - /** - * 可使用窗口宽度,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - windowWidth: number, - /** - * 可使用窗口高度,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } - */ - windowHeight: number, - /** - * 状态栏的高度,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - statusBarHeight: number, - /** - * 内容区域距离顶部的距离(同CSS变量 `--window-top`),单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - windowTop: number, - /** - * 内容区域距离底部的距离(同CSS变量 `--window-bottom`),单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - windowBottom: number, - /** - * 在竖屏正方向下的安全区域 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - safeArea: SafeArea, - /** - * 在竖屏正方向下的安全区域插入位置 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - safeAreaInsets: SafeAreaInsets, - /** - * 窗口上边缘的 y 值,单位为px - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * }, - * "web": { - * "uniVer": "√", - * "unixVer": "4.0" - * } - * } - */ - screenTop: number -}; +export interface Uni { + /** + * getSystemInfo() + * @description + * 异步获取系统信息 + * @param {GetSystemInfoOptions} options + * @return {void} + * @tutorial http://uniapp.dcloud.io/api/system/info?id=getsysteminfo + * @uniPlatform + * { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "3.9+" + * }, + * "ios": { + * "osVer": "12.0", + * "uniVer": "√", + * "unixVer": "4.11" + * } + * }, + * "web": { + * "uniVer": "√", + * "unixVer": "4.0" + * } + * } + * @example + ```typescript + uni.getSystemInfo({ + success(e) { + console.log("success :",e); + }, + complete(e) { + console.log("complete :",e); + } + }) + ``` + */ + getSystemInfo(options: GetSystemInfoOptions): void; + + /** + * getSystemInfoSync() + * @description + * 同步获取系统信息 + * @param {void} + * @return {GetSystemInfoResult} + * @tutorial http://uniapp.dcloud.io/api/system/info?id=getsysteminfosync + * @uniPlatform + * { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "3.9+" + * }, + * "ios": { + * "osVer": "12.0", + * "uniVer": "√", + * "unixVer": "4.11" + * } + * }, + * "web": { + * "uniVer": "√", + * "unixVer": "4.0" + * } + * } + * @example + ```typescript + uni.getSystemInfoSync() + ``` + */ + getSystemInfoSync(): GetSystemInfoResult; + + /** + * getWindowInfo() + * @description + * 同步获取窗口信息 + * @param {void} + * @return {GetWindowInfoResult} result + * @tutorial http://uniapp.dcloud.io/api/system/getWindowInfo.html + * @uniPlatform + * { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "3.9+" + * }, + * "ios": { + * "osVer": "12.0", + * "uniVer": "√", + * "unixVer": "4.11" + * } + * }, + * "web": { + * "uniVer": "√", + * "unixVer": "4.0" + * } + * } + * @example + ```typescript + uni.getWindowInfo() + ``` + */ + getWindowInfo(): GetWindowInfoResult; +} + +export type GetSystemInfo = (options: GetSystemInfoOptions) => void; +export type GetSystemInfoSync = () => GetSystemInfoResult; +export type GetWindowInfo = () => GetWindowInfoResult; +export type SafeArea = { + /** + * 安全区域左上角横坐标,单位为px + */ + left: number, + /** + * 安全区域右下角横坐标,单位为px + */ + right: number, + /** + * 安全区域左上角纵坐标,单位为px + */ + top: number, + /** + * 安全区域右下角纵坐标,单位为px + */ + bottom: number, + /** + * 安全区域的宽度,单位为px + */ + width: number, + /** + * 安全区域的高度,单位为px + */ + height: number +}; +export type SafeAreaInsets = { + /** + * 安全区域左侧插入位置,单位为px + */ + left: number, + /** + * 安全区域右侧插入位置,单位为px + */ + right: number, + /** + * 安全区顶部插入位置,单位为px + */ + top: number, + /** + * 安全区域底部插入位置,单位为px + */ + bottom: number +}; +export type GetSystemInfoResult = { + /** + * 客户端基础库版本 + */ + SDKVersion: string, + /** + * `manifest.json` 中应用appid。 + */ + appId: string, + /** + * 应用设置的语言。 + */ + appLanguage: string, + /** + * `manifest.json` 中应用名称。 + */ + appName: string, + /** + * `manifest.json` 中应用版本名称。 + */ + appVersion: string, + /** + * `manifest.json` 中应用版本名号。 + */ + appVersionCode: string, + /** + * 应用资源(wgt)的版本名称。 + * + * @uniPlatform + * { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "ios": { + * "osVer": "12.0", + * "uniVer": "√", + * "unixVer": "x" + * } + * } + * } + */ + appWgtVersion?: string | null, + /** + * 手机品牌。 + */ + brand: string, + /** + * 浏览器名称。`App` 端是系统 webview 的名字,比如 wkwebview、chrome。小程序端为空 + */ + browserName: string, + /** + * 浏览器版本、webview 版本。 + */ + browserVersion: string, + /** + * 设备 ID + */ + deviceId: string, + /** + * 设备品牌。如:`apple`、`huawei`。 + */ + deviceBrand: string, + /** + * 设备型号 + */ + deviceModel: string, + /** + * 设备类型。 + */ + deviceType: 'phone' | 'pad' | 'tv' | 'watch' | 'pc' | 'undefined' | 'car' | 'vr' | 'appliance', + /** + * 设备像素比 + */ + devicePixelRatio: number, + /** + * 设备方向。 + * @type 'portrait' | 'landscape' + */ + deviceOrientation: 'portrait' | 'landscape', + /** + * 程序设置的语言 + */ + language: string, + /** + * 手机型号 + */ + model: string, + /** + * 系统名称 + */ + osName: 'ios' | 'android' | 'mac' | 'windows' | 'linux', + /** + * 操作系统版本。如 ios 版本,andriod 版本 + */ + osVersion: string, + /** + * 操作系统语言 + */ + osLanguage: string, + /** + * 操作系统主题 + * + * @uniPlatform + * { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "√" + * }, + * "ios": { + * "osVer": "12.0", + * "uniVer": "√", + * "unixVer": "4.11" + * } + * } + * } + */ + osTheme?: 'light' | 'dark' | null, + /** + * 设备像素比 + */ + pixelRatio: number, + /** + * 客户端平台 + */ + platform: 'ios' | 'android' | 'mac' | 'windows' | 'linux', + /** + * 屏幕宽度,单位为px + */ + screenWidth: number, + /** + * 屏幕高度,单位为px + */ + screenHeight: number, + /** + * 状态栏的高度,单位为px + */ + statusBarHeight: number, + /** + * 操作系统版本 + */ + system: string, + /** + * 在竖屏正方向下的安全区域 + */ + safeArea: SafeArea, + /** + * 在竖屏正方向下的安全区域插入位置 + */ + safeAreaInsets: SafeAreaInsets, + /** + * 用户标识。小程序端为空 + */ + ua: string, + /** + * uni 编译器版本。 + * @deprecated 已废弃,仅为了向下兼容保留 + */ + uniCompileVersion: string, + /** + * uni 编译器版本。 + */ + uniCompilerVersion: string, + /** + * uni-app 运行平台,与条件编译平台相同。 + */ + uniPlatform: 'app' | 'web' | 'mp-weixin' | 'mp-alipay' | 'mp-baidu' | 'mp-toutiao' | 'mp-lark' | 'mp-qq' | 'mp-kuaishou' | 'mp-jd' | 'mp-360' | 'quickapp-webview' | 'quickapp-webview-union' | 'quickapp-webview-huawei', + /** + * uni 运行时版本。 + */ + uniRuntimeVersion: string, + /** + * uni 编译器版本号。 + * @deprecated 已废弃,仅为了向下兼容保留 + */ + uniCompileVersionCode: number, + /** + * uni 编译器版本号。 + */ + uniCompilerVersionCode: number, + /** + * uni 运行时版本号。 + */ + uniRuntimeVersionCode: number, + /** + * 引擎版本号。 + * @deprecated 已废弃,仅为了向下兼容保留 + */ + version: string, + /** + * rom 名称。Android 部分机型获取不到值。iOS 恒为 `ios` + */ + romName: string, + /** + * rom 版本号。Android 部分机型获取不到值。iOS 为操作系统版本号(同 `osVersion`)。 + */ + romVersion: string, + /** + * 可使用窗口宽度,单位为px + */ + windowWidth: number, + /** + * 可使用窗口高度,单位为px + */ + windowHeight: number, + /** + * 内容区域距离顶部的距离(同CSS变量 `--window-top`),单位为px + */ + windowTop: number, + /** + * 内容区域距离底部的距离(同CSS变量 `--window-bottom`),单位为px + */ + windowBottom: number, + /** + * Android 系统API库的版本。 + * + * @uniPlatform + * { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "√" + * }, + * "ios": { + * "osVer": "x", + * "uniVer": "x", + * "unixVer": "x" + * } + * } + * } + */ + osAndroidAPILevel?: number | null +}; +export type GetSystemInfoSuccessCallback = (result: GetSystemInfoResult) => void; +type GetSystemInfoFail = UniError; +type GetSystemInfoFailCallback = (result: GetSystemInfoFail) => void; +export type GetSystemInfoComplete = any; +export type GetSystemInfoCompleteCallback = (result: GetSystemInfoComplete) => void; +export type GetSystemInfoOptions = { + /** + * 接口调用成功的回调函数 + * @defaultValue null + */ + success?: GetSystemInfoSuccessCallback | null, + /** + * 接口调用失败的回调函数 + * @defaultValue null + */ + fail?: GetSystemInfoFailCallback | null, + /** + * 接口调用结束的回调函数(调用成功、失败都会执行) + * @defaultValue null + */ + complete?: GetSystemInfoCompleteCallback | null +}; + +export type GetWindowInfoResult = { + /** + * 设备像素比 + */ + pixelRatio: number, + /** + * 屏幕宽度,单位为px + */ + screenWidth: number, + /** + * 屏幕高度,单位为px + */ + screenHeight: number, + /** + * 可使用窗口宽度,单位为px + */ + windowWidth: number, + /** + * 可使用窗口高度,单位为px + */ + windowHeight: number, + /** + * 状态栏的高度,单位为px + */ + statusBarHeight: number, + /** + * 内容区域距离顶部的距离(同CSS变量 `--window-top`),单位为px + */ + windowTop: number, + /** + * 内容区域距离底部的距离(同CSS变量 `--window-bottom`),单位为px + */ + windowBottom: number, + /** + * 在竖屏正方向下的安全区域 + */ + safeArea: SafeArea, + /** + * 在竖屏正方向下的安全区域插入位置 + */ + safeAreaInsets: SafeAreaInsets, + /** + * 窗口上边缘的 y 值,单位为px + */ + screenTop: number +}; diff --git a/uni_modules/uni-getSystemSetting/utssdk/interface.uts b/uni_modules/uni-getSystemSetting/utssdk/interface.uts index b6b1acd05382062667131dd7c5a8f03a37bedc6b..718da8754c0bd50573b121dd8ab4e4fb898a605a 100644 --- a/uni_modules/uni-getSystemSetting/utssdk/interface.uts +++ b/uni_modules/uni-getSystemSetting/utssdk/interface.uts @@ -2,123 +2,27 @@ export type GetSystemSettingResult = { /** - * 蓝牙是否开启 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } + * 蓝牙是否开启 */ bluetoothEnabled?: boolean, /** - * 蓝牙的报错信息 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } + * 蓝牙的报错信息 */ bluetoothError?: string, /** - * 位置是否开启 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } + * 位置是否开启 */ locationEnabled : boolean, /** - * wifi是否开启 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } + * wifi是否开启 */ wifiEnabled?: boolean, /** - * wifi的报错信息 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "x", - * "uniVer": "x", - * "unixVer": "x" - * } - * } - * } + * wifi的报错信息 */ wifiError?: string, /** - * 设备方向 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } + * 设备方向 */ deviceOrientation : 'portrait' | 'landscape', } diff --git a/uni_modules/uni-media/package.json b/uni_modules/uni-media/package.json index 734a2134e05937a2125101aae0c733a6c65b5777..7544e1837c4470807be7283d046e1a9bc0860473 100644 --- a/uni_modules/uni-media/package.json +++ b/uni_modules/uni-media/package.json @@ -86,7 +86,7 @@ "app": { "js": false, "kotlin": true, - "swift": true + "swift": false } }, "saveVideoToPhotosAlbum": { @@ -94,7 +94,7 @@ "app": { "js": false, "kotlin": true, - "swift": true + "swift": false } }, "getVideoInfo": { diff --git a/uni_modules/uni-media/utssdk/ChooseImageUtils.uts b/uni_modules/uni-media/utssdk/ChooseImageUtils.uts new file mode 100644 index 0000000000000000000000000000000000000000..89c248bf3d04b1ab156d7f013ed92dd25df8c836 --- /dev/null +++ b/uni_modules/uni-media/utssdk/ChooseImageUtils.uts @@ -0,0 +1,72 @@ +import { ChooseImageOptions, ChooseVideoOptions } from "./interface.uts" +import { + UniError_ChooseImage, UniError_ChooseVideo, MediaErrorImpl +} from "./unierror.uts" +export const CODE_CAMERA_ERROR = 11; +export const CODE_GALLERY_ERROR = 12; +export const CODE_GET_IMAGE_INFO_CODE = 13 + +export function uniChooseImage(options : ChooseImageOptions, onSourceTypeSelect : (count : number, compressed : boolean, index : number) => void) { + let count = options.count != null ? (options.count! <= 0 ? 9 : options.count) : 9 + // 默认为 false + let compressed = false; + if ((options.sizeType) != null) { + compressed = options.sizeType!.indexOf("original") < 0 + } + /* source type 乱传如何处理 */ + let sourceType : Array = (options.sourceType != null && options.sourceType!.length > 0) ? options.sourceType! : ["album", "camera"]; + let itemList = ["拍摄", "从相册选择"] + if (sourceType.length == 1) { + if (sourceType.indexOf("album") >= 0) { + onSourceTypeSelect(count!, compressed, 1) + } else if (sourceType.indexOf("camera") >= 0) { + onSourceTypeSelect(count!, compressed, 0) + } + return + } + if (sourceType.length == 2) { + uni.showActionSheet({ + itemList: itemList, + success: (e) => { + onSourceTypeSelect(count!, compressed, e.tapIndex!) + }, + fail: (e) => { + let error = new MediaErrorImpl(1101001, UniError_ChooseImage); + options.fail?.(error) + options.complete?.(error) + } + }) + } +} + +export function uniChooseVideo(options : ChooseVideoOptions, onSourceTypeSelect : (count : number, compressed : boolean, index : number) => void) { + let count = 1 + // 默认为 false + let compressed = options.compressed != null ? options.compressed! : true; + + /* source type 乱传如何处理 */ + let sourceType : Array = (options.sourceType != null && options.sourceType!.length > 0) ? options.sourceType! : ["album", "camera"]; + let itemList = ["拍摄", "从相册选择"] + if (sourceType.length == 1) { + if (sourceType.indexOf("album") >= 0) { + onSourceTypeSelect(count!, compressed, 1) + } else if (sourceType.indexOf("camera") >= 0) { + onSourceTypeSelect(count!, compressed, 0) + } + return + } + + if (sourceType.length == 2) { + uni.showActionSheet({ + itemList: itemList, + success: (e) => { + onSourceTypeSelect(count!, compressed, e.tapIndex!) + }, + fail: (e) => { + let error = new MediaErrorImpl(1101001, UniError_ChooseVideo); + options.fail?.(error) + options.complete?.(error) + } + }) + } +} \ No newline at end of file diff --git a/uni_modules/uni-media/utssdk/app-android/index.uts b/uni_modules/uni-media/utssdk/app-android/index.uts index 44a84121a0cb88d261e974bc84d493ad0eb192b3..9b945e37dd1bf579312568fac8d0069723ac9618 100644 --- a/uni_modules/uni-media/utssdk/app-android/index.uts +++ b/uni_modules/uni-media/utssdk/app-android/index.uts @@ -343,7 +343,6 @@ function copyFile(fromFilePath : string, toFilePath : string) : boolean { if (!fromFile.canRead()) { return false; } - fis = new FileInputStream(fromFile); } if (fis == null) { return false @@ -359,6 +358,7 @@ function copyFile(fromFilePath : string, toFilePath : string) : boolean { toFile.createNewFile() } try { + // let fis = new FileInputStream(fromFile) let fos = new FileOutputStream(toFile) let byteArrays = ByteArray(1024) var c = fis!!.read(byteArrays) @@ -592,21 +592,6 @@ export const getVideoInfo : GetVideoInfo = function (options : GetVideoInfoOptio export const saveVideoToPhotosAlbum : SaveVideoToPhotosAlbum = function (options : SaveVideoToPhotosAlbumOptions) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - let requestPermissionList : Array = [Manifest.permission.WRITE_EXTERNAL_STORAGE]; - UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, requestPermissionList, (a : boolean, b : string[]) => { - loadFile(options); - }, (a : boolean, b : string[]) => { - let error = new MediaErrorImpl(1101005, UniError_SaveVideoToPhotosAlbum); - options.fail?.(error); - options.complete?.(error); - }) - } else { - loadFile(options); - } -} - -function loadFile(options : SaveVideoToPhotosAlbumOptions) { if (TextUtils.isEmpty(options.filePath)) { let error = new MediaErrorImpl(1101003, UniError_SaveVideoToPhotosAlbum); options.fail?.(error) diff --git a/uni_modules/uni-media/utssdk/app-android/utils/ChooseMediaUtils.uts b/uni_modules/uni-media/utssdk/app-android/utils/ChooseMediaUtils.uts index e354bf605bad1662126904a7011147734bf472af..c2ea2c1b2ba031b6d65e8632abb453a972f36d1b 100644 --- a/uni_modules/uni-media/utssdk/app-android/utils/ChooseMediaUtils.uts +++ b/uni_modules/uni-media/utssdk/app-android/utils/ChooseMediaUtils.uts @@ -8,7 +8,7 @@ import { MediaErrorImpl } from "../../unierror.uts" import { getVideoMetadata } from "./MediaUtils.uts" -import { uniChooseImage, uniChooseVideo } from "./ChooseImageUtils.uts" +import { uniChooseImage, uniChooseVideo } from "../../ChooseImageUtils.uts" import { getUniActivity } from "io.dcloud.uts.android"; import Intent from 'android.content.Intent'; import File from 'java.io.File'; diff --git a/uni_modules/uni-media/utssdk/app-android/utils/CompressUtils.uts b/uni_modules/uni-media/utssdk/app-android/utils/CompressUtils.uts index 05f8e8af271634d524b86662b56dd9b214c4931c..41157c6cbc7d69b63a737b300815201027d3d462 100644 --- a/uni_modules/uni-media/utssdk/app-android/utils/CompressUtils.uts +++ b/uni_modules/uni-media/utssdk/app-android/utils/CompressUtils.uts @@ -46,16 +46,18 @@ export function transcodeImage(options : CompressImageOptions) { var widthStr = "" var heightStr = "" if (options.compressedWidth != null) { - widthStr = options.compressedWidth.toString(); + compressOption.width = options.compressedWidth! } else { widthStr = TextUtils.isEmpty(options.width) ? "auto" : options.width! } if (options.compressedHeight != null) { - heightStr = options.compressedHeight.toString(); + compressOption.height = options.compressedHeight! } else { heightStr = TextUtils.isEmpty(options.height) ? "auto" : options.height! } - getHeightAndWidth(compressOption, widthStr, heightStr); + if (compressOption.width <= 0 || compressOption.height <= 0) { + getHeightAndWidth(compressOption, widthStr, heightStr) + } let bitmapOptions = new BitmapFactory.Options() bitmapOptions.inJustDecodeBounds = false; if (srcFile.length() > 1500000) { @@ -173,7 +175,7 @@ function str2Float(valuestr : string, realValue : number, defValue : number) : n } valuestr = valuestr.toLowerCase() if (valuestr.endsWith("px")) { - valuestr = valuestr.substring(0, valuestr.length - 2); + valuestr == valuestr.substring(0, valuestr.length - 2); } try { return Integer.parseInt(valuestr) @@ -229,7 +231,8 @@ export function transcodeVideo(options : CompressVideoOptions) { } else if (resolution! > 1 || resolution! <= 0) { resolution = 1.0 } - let outPath = mediaCachePath + "compress_video_" + System.currentTimeMillis() + ".mp4"; + let fileName = getFileName(inPath); + let outPath = mediaCachePath + (fileName == "" ? (System.currentTimeMillis() + ".mp4") : fileName) let outFile = new File(outPath) if (!outFile.getParentFile().exists()) { outFile.getParentFile().mkdirs() @@ -238,6 +241,14 @@ export function transcodeVideo(options : CompressVideoOptions) { MediaTranscoder.getInstance().transcodeVideo(inPath, outPath, MediaFormatStrategyPresets.createAndroid720pStrategy(compressLevel, resolution!), new MediaTranscoderListener(inPath, outPath, options)) } +function getFileName(path : string) : string { + const array = path.split("/") + if (array.length > 0) { + return array[array.length - 1] + } + return "" +} + class MediaTranscoderListener implements Listener { inPath : string outPath : string diff --git a/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64/DCloudMediaPicker.framework/DCloudMediaPicker b/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64/DCloudMediaPicker.framework/DCloudMediaPicker index 758b28773aec2fca287a18b7a192391f23c5224b..53df847de192f7b2f8e7e0eb9ba84fda3f1c9794 100644 Binary files a/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64/DCloudMediaPicker.framework/DCloudMediaPicker and b/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64/DCloudMediaPicker.framework/DCloudMediaPicker differ diff --git a/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/DCloudMediaPicker b/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/DCloudMediaPicker index 97251a69a05acd3a40cfe62a779923cc9a057024..82231a550c92f7c99a41788cea406b720cd1716f 100644 Binary files a/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/DCloudMediaPicker and b/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/DCloudMediaPicker differ diff --git a/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/_CodeSignature/CodeDirectory b/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/_CodeSignature/CodeDirectory index 216369327bb64fa7db0ee4765b17f83d8e50ea53..b43c40fc441f50c1bf104422b4fdcce263bb8af3 100644 Binary files a/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/_CodeSignature/CodeDirectory and b/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/_CodeSignature/CodeDirectory differ diff --git a/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/_CodeSignature/CodeRequirements-1 b/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/_CodeSignature/CodeRequirements-1 index a674e878bee9fafd699d6fdf521a238a5897888e..62fa0caf89c1740d145ee9e93b46e79ae28add30 100644 Binary files a/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/_CodeSignature/CodeRequirements-1 and b/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/_CodeSignature/CodeRequirements-1 differ diff --git a/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/_CodeSignature/CodeResources b/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/_CodeSignature/CodeResources index e4a35afd077442fe1f9816b01c0e31d7c80c623b..04b7ae1ba3fad6d0e11ece1816319c5eaeb650a5 100644 --- a/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/_CodeSignature/CodeResources +++ b/uni_modules/uni-media/utssdk/app-ios/Frameworks/DCloudMediaPicker.xcframework/ios-arm64_x86_64-simulator/DCloudMediaPicker.framework/_CodeSignature/CodeResources @@ -28,10 +28,6 @@ nghJYGVbKFhvAi/+2XYvdy408is= - PrivacyInfo.xcprivacy - - L50owgIQfV6zTzg7T11NlSDYSZU= - files2 @@ -90,17 +86,6 @@ M9nMA2y1DqhJFLOymGCa66mNVw5qDN8J1QzcxQD3H/w= - PrivacyInfo.xcprivacy - - hash - - L50owgIQfV6zTzg7T11NlSDYSZU= - - hash2 - - NOpzMYrYXZEAI4Xdo9XJX+tflymAvdW2UHdZwen1+iU= - - rules diff --git a/uni_modules/uni-media/utssdk/app-ios/index.uts b/uni_modules/uni-media/utssdk/app-ios/index.uts index 344fa0839155feae7241e4fab8b7917ec0364a6c..1eca53f5718696edaa68f6cb7b8e6bd3f599dc20 100644 --- a/uni_modules/uni-media/utssdk/app-ios/index.uts +++ b/uni_modules/uni-media/utssdk/app-ios/index.uts @@ -2,15 +2,13 @@ import { ChooseImageOptions, ChooseImage, ChooseImageSuccess, PreviewImageOptions, PreviewImage, PreviewImageSuccess, ClosePreviewImage, ClosePreviewImageSuccess, ClosePreviewImageOptions, - SaveImageToPhotosAlbum, SaveImageToPhotosAlbumOptions, SaveImageToPhotosAlbumSuccess, - ChooseVideo, ChooseVideoOptions, - SaveVideoToPhotosAlbum, SaveVideoToPhotosAlbumOptions, SaveVideoToPhotosAlbumSuccess, ChooseVideoSuccess, + SaveImageToPhotosAlbum, SaveImageToPhotosAlbumOptions, SaveImageToPhotosAlbumSuccess, } from "../interface.uts"; import { UniError_ChooseImage, UniError_SaveImageToPhotosAlbum, - MediaErrorImpl,UniError_PreviewImage, UniError_ChooseVideo, UniError_SaveVideoToPhotosAlbum + MediaErrorImpl,UniError_PreviewImage } from "../unierror.uts" -import { uniChooseImage, uniChooseVideo } from "./ChooseImageUtils.uts"; +import { uniChooseImage, uniChooseVideo } from "../ChooseImageUtils.uts"; import { UTSiOS } from "DCloudUTSFoundation"; import { NSFileManager } from "Foundation"; @@ -25,7 +23,7 @@ export const chooseImage : ChooseImage = function (option : ChooseImageOptions) if (index == 0) { requestCameraPermission(function (status : number) { if (status == 1) { - mediaPicker.openCameraForImage(option) + mediaPicker.openCameraForImage(option, compressed) } else { let error = new MediaErrorImpl(1101005, UniError_ChooseImage); option.fail?.(error) @@ -36,7 +34,7 @@ export const chooseImage : ChooseImage = function (option : ChooseImageOptions) } else if (index == 1) { requestAlbumPermission("readWrite", function (status : number) { if (status == 1) { - mediaPicker.openAlbumForImage(option, count) + mediaPicker.openAlbumForImage(option, count, 101) } else { let error = new MediaErrorImpl(1101005, UniError_ChooseImage); option.fail?.(error) @@ -47,56 +45,14 @@ export const chooseImage : ChooseImage = function (option : ChooseImageOptions) }); } -export const chooseVideo : ChooseVideo = function (option : ChooseVideoOptions) { - uniChooseVideo(option, (count : number, compressed : boolean, index : number) => { - if (index == 0) { - requestCameraPermission(function (status : number) { - if (status == 1) { - requestMicrophonePermission(function (status : number){ - if (status == 1) { - mediaPicker.openCameraForVideo(option) - }else{ - let error = new MediaErrorImpl(1101005, UniError_ChooseVideo); - option.fail?.(error) - option.complete?.(error) - } - }) - - } else { - let error = new MediaErrorImpl(1101005, UniError_ChooseVideo); - option.fail?.(error) - option.complete?.(error) - } - }) - - } else if (index == 1) { - requestAlbumPermission("readWrite", function (status : number) { - if (status == 1) { - mediaPicker.openAlbumForVideo(option) - } else { - let error = new MediaErrorImpl(1101005, UniError_ChooseVideo); - option.fail?.(error) - option.complete?.(error) - } - }) - } - }) -} - class DCUniMediaPicker { private mediaAlbum : DCloudMediaAlbum = new DCloudMediaAlbum(); private mediaCamera : DCloudMediaCamera = new DCloudMediaCamera(); - openAlbumForImage(option : ChooseImageOptions, count : number){ - this.chooseImageWithAlbum(option,count); - } - openAlbumForVideo(option : ChooseVideoOptions){ - this.chooseVideoWithAlbum(option); + openAlbumForImage(option : ChooseImageOptions, count : number, type : number){ + this.chooseImageWithAlbum(option,count,type); } - openCameraForVideo(option : ChooseVideoOptions){ - this.chooseVideoWithCamera(option); - } - openCameraForImage(option : ChooseImageOptions){ - this.chooseImageWithCamera(option); + openCameraForImage(option : ChooseImageOptions, compressed : boolean){ + this.chooseImageWithCamera(option,compressed); } preview(options : PreviewImageOptions){ this.previewImageWithOptions(options); @@ -104,44 +60,7 @@ class DCUniMediaPicker { close(){ this.closePreview(); } - - private chooseVideoWithAlbum(option : ChooseVideoOptions){ - const mediaCachePath = UTSiOS.getMediaCacheDir() + "/" - let fileManager = FileManager.default - if (fileManager.fileExists(atPath = mediaCachePath) == false) { - try { - UTSiOS.try(fileManager.createDirectory(atPath = mediaCachePath, withIntermediateDirectories = true, attributes = null)) - } catch (e) { - console.log(e) - } - } - let options : Map = new Map(); - options.set('resolution', "high"); - options.set('videoCompress', option.compressed); - options.set('filePath', mediaCachePath); - options.set('maximum', 1); - options.set('filter', "video"); - DispatchQueue.main.async(execute = () : void => { - this.mediaAlbum.start(options, success = (response : Map) : void => { - const filePath : string = response.get('tempFilePath') as string - let success : ChooseVideoSuccess = { - tempFilePath: "file://" + filePath, - width: response.get('width'), - height: response.get('height'), - size: response.get('size'), - duration: response.get('duration'), - } - option.success?.(success) - option.complete?.(success) - }, fail = (code : number) : void => { - let mediaError = new MediaErrorImpl(code, UniError_ChooseVideo); - option.fail?.(mediaError) - option.complete?.(mediaError) - }) - }) - } - - private chooseImageWithAlbum(option : ChooseImageOptions, count : number){ + private chooseImageWithAlbum(option : ChooseImageOptions, count : number, type : number){ const mediaCachePath = UTSiOS.getMediaCacheDir() + "/" let fileManager = FileManager.default if (fileManager.fileExists(atPath = mediaCachePath) == false) { @@ -192,47 +111,7 @@ class DCUniMediaPicker { }) } - private chooseVideoWithCamera(option : ChooseVideoOptions){ - const mediaCachePath = UTSiOS.getMediaCacheDir() + "/" - const fileManager = FileManager.default - if (fileManager.fileExists(atPath = mediaCachePath) == false) { - try { - UTSiOS.try(fileManager.createDirectory(atPath = mediaCachePath, withIntermediateDirectories = true, attributes = null)) - } catch (e) { - console.log(e) - } - } - - const currentTime = Int(Date().timeIntervalSince1970) - const cameraPath = (mediaCachePath + currentTime.toString() + ".mp4") - - let options : Map = new Map(); - options.set('resolution', "high"); - options.set('videoCompress', option.compressed); - options.set('filePath', cameraPath); - options.set('type', "video"); - options.set('videoMaximumDuration', 60); - - DispatchQueue.main.async(execute = () : void => { - this.mediaCamera.start(options, success = (response : Map) : void => { - let success : ChooseVideoSuccess = { - tempFilePath: "file://" + cameraPath, - width: response.get('width'), - height: response.get('height'), - size: response.get('size'), - duration: response.get('duration'), - } - option.success?.(success) - option.complete?.(success) - }, fail = (code : number) : void => { - let mediaError = new MediaErrorImpl(code, UniError_ChooseVideo); - option.fail?.(mediaError) - option.complete?.(mediaError) - }) - }) - } - - private chooseImageWithCamera(option : ChooseImageOptions){ + private chooseImageWithCamera(option : ChooseImageOptions, compressed : boolean){ const mediaCachePath = UTSiOS.getMediaCacheDir() + "/" const fileManager = FileManager.default if (fileManager.fileExists(atPath = mediaCachePath) == false) { @@ -250,7 +129,6 @@ class DCUniMediaPicker { options.set('resolution', "high"); options.set('sizeType', option.sizeType); options.set('filePath', cameraPath); - options.set('type', "image"); if (option.crop != null) { let crop : Map = new Map(); if (option.crop!.width != nil) { @@ -316,23 +194,6 @@ class DCUniMediaPicker { options.success?.(success) options.complete?.(success) } -} - -function requestMicrophonePermission(completion : (status : number) => void) { - let authorized = AVCaptureDevice.authorizationStatus(for= AVMediaType.audio) - if (authorized == AVAuthorizationStatus.authorized) { - completion(1) - } else if (authorized == AVAuthorizationStatus.notDetermined) { - AVCaptureDevice.requestAccess(for=AVMediaType.audio, completionHandler = (result : Bool) : void => { - if (result) { - completion(1) - } else { - completion(0) - } - }) - } else { - completion(0) - } } function requestCameraPermission(completion : (status : number) => void) { @@ -473,35 +334,4 @@ export const saveImageToPhotosAlbum : SaveImageToPhotosAlbum = function (options options.complete?.(error) } }) -} - -export const saveVideoToPhotosAlbum : SaveVideoToPhotosAlbum = function (options : SaveVideoToPhotosAlbumOptions) { - const path = UTSiOS.getResourceAbsolutePath(options.filePath,null) - let url = new URL(string = path) - if (url == null) { - let error = new MediaErrorImpl(1101003, UniError_SaveVideoToPhotosAlbum); - options.fail?.(error) - options.complete?.(error) - return - } - requestAlbumPermission("addOnly", function (status : number) { - if (status == 1) { - try { - UTSiOS.try(PHPhotoLibrary.shared().performChangesAndWait(() : void => { - PHAssetCreationRequest.creationRequestForAssetFromVideo(atFileURL = url!) - })) - let success : SaveVideoToPhotosAlbumSuccess = {} - options.success?.(success) - options.complete?.(success) - } catch (e) { - let error = new MediaErrorImpl(1101006, UniError_SaveVideoToPhotosAlbum); - options.fail?.(error) - options.complete?.(error) - } - } else { - let error = new MediaErrorImpl(1101005, UniError_SaveVideoToPhotosAlbum); - options.fail?.(error) - options.complete?.(error) - } - }) } \ No newline at end of file diff --git a/uni_modules/uni-media/utssdk/app-ios/info.plist b/uni_modules/uni-media/utssdk/app-ios/info.plist index 8e69cb22415bdb2f47ac91abf679781eb4cd0212..ee3a2507358f1c198bc34e7c3c5bd0e8aa432c4d 100644 --- a/uni_modules/uni-media/utssdk/app-ios/info.plist +++ b/uni_modules/uni-media/utssdk/app-ios/info.plist @@ -5,10 +5,8 @@ NSCameraUsageDescription APP需要您的同意,才能使用摄像头,以便于相机拍摄 NSPhotoLibraryAddUsageDescription - APP需要您的同意,才能访问相册,以便于保存图像 + APP需要您的同意,才能访问相册,以便于保存图片 NSPhotoLibraryUsageDescription - APP需要您的同意,才能访问相册,以便于图像选取 - NSMicrophoneUsageDescription - APP需要您的同意,才能使用麦克风,以便于录制音频 + APP需要您的同意,才能访问相册,以便于图片选取 \ No newline at end of file diff --git a/uni_modules/uni-media/utssdk/interface.uts b/uni_modules/uni-media/utssdk/interface.uts index 11a71727535f6d2f8bf98f1275a231fcce3956ea..f7979fff575ea74fa08bc7f99980fe8037538efd 100644 --- a/uni_modules/uni-media/utssdk/interface.uts +++ b/uni_modules/uni-media/utssdk/interface.uts @@ -429,7 +429,6 @@ export type ChooseVideoOptions = { /** * 是否压缩所选的视频源文件,默认值为true,需要压缩 * @type boolean - * @default true */ compressed ?: boolean | null, /** diff --git a/uni_modules/uni-network/utssdk/app-ios/index.uts b/uni_modules/uni-network/utssdk/app-ios/index.uts index cc7a69b47137cc8ffa593b63bb6578ba8535328c..bc6c3c7dcfd4960c0e369204845f82a2bef9b1ec 100644 --- a/uni_modules/uni-network/utssdk/app-ios/index.uts +++ b/uni_modules/uni-network/utssdk/app-ios/index.uts @@ -1,15 +1,15 @@ -import { Request, RequestOptions, RequestSuccess, RequestFail, RequestTask, UploadFileOptions, UploadFile, UploadTask, OnProgressUpdateResult, UploadFileSuccess, UploadFileProgressUpdateCallback, DownloadFileProgressUpdateCallback, DownloadFileOptions, OnProgressDownloadResult, DownloadFile, DownloadFileSuccess } from './interface'; +import { Request, RequestOptions, RequestSuccess, RequestFail, RequestTask, UploadFileOptions, UploadFile, UploadTask, OnProgressUpdateResult, UploadFileSuccess, UploadFileProgressUpdateCallback, DownloadFileProgressUpdateCallback, DownloadFileOptions, OnProgressDownloadResult, DownloadFile ,DownloadFileSuccess} from './interface'; import { NetworkManager, NetworkRequestListener, NetworkUploadFileListener, NetworkDownloadFileListener } from './network/NetworkManager.uts' import { Data, HTTPURLResponse, NSError, NSNumber, ComparisonResult, RunLoop, Thread } from 'Foundation'; import { StatusCode } from './network/StatusCode.uts'; import { RequestFailImpl, UploadFileFailImpl, DownloadFileFailImpl, getErrcode } from '../unierror'; -class SimpleNetworkListener extends NetworkRequestListener { - private param : RequestOptions | null = null; +class SimpleNetworkListener extends NetworkRequestListener { + private param : RequestOptions | null = null; private headers : Map | null = null; private received : number = 0; private data : Data = new Data(); - constructor(param : RequestOptions) { + constructor(param : RequestOptions) { this.param = param; super(); } @@ -53,21 +53,12 @@ class SimpleNetworkListener extends NetworkRequestListener { result['data'] = this.parseData(this.data, strData, type); - if (result['data'] == null) { - let failResult = new RequestFailImpl(getErrcode(100001)); - let fail = kParam?.fail; - let complete = kParam?.complete; - fail?.(failResult); - complete?.(failResult); - return - } - - let tmp = new RequestSuccess({ - data: result['data']! as T, + let tmp : RequestSuccess = { + data: result['data']!, statusCode: (new NSNumber(value = response.statusCode)), header: result['header'] ?? "", cookies: this.parseCookie(this.headers) - }) + }; let success = kParam?.success; let complete = kParam?.complete; success?.(tmp); @@ -78,21 +69,21 @@ class SimpleNetworkListener extends NetworkRequestListener { public override onFail(error : NSError) : void { let kParam = this.param; - let code = (error as NSError).code; + let code = (error as NSError).code; let errCode = code; let cause = error.localizedDescription; - if (code == -1001) { - errCode = 5; - } else if (code == -1004) { - errCode = 1000; - } else if (code == -1009) { - errCode = 600003; - } else { - errCode = 602001; - } - - let failResult = new RequestFailImpl(getErrcode(Number.from(errCode))); - failResult.cause = new SourceError(cause); + if (code == -1001) { + errCode = 5; + } else if (code == -1004) { + errCode = 1000; + } else if (code == -1009) { + errCode = 600003; + } else { + errCode = 602001; + } + + let failResult = new RequestFailImpl(getErrcode(Number.from(errCode))); + failResult.cause = new SourceError(cause); let fail = kParam?.fail; let complete = kParam?.complete; @@ -117,59 +108,52 @@ class SimpleNetworkListener extends NetworkRequestListener { return result; } - private parseData(data : Data | null, dataStr : string | null, parseType : string | null) : any | null { - if (`${type(of = T.self)}` == "Any.Protocol" || `${type(of = T.self)}` == "Optional.Type") { - if (parseType != null && parseType!.contains("json")) { - if (dataStr == null || dataStr!.length == 0) { - return {}; - } - - return JSON.parse(dataStr!); - } else if (parseType == 'jsonp') { - if (dataStr == null || dataStr!.length == 0) { - return {}; - } - let start = dataStr!.indexOf('('); - let end = dataStr!.indexOf(')'); - if (start == 0 || start >= end) { - return {}; - } - start += 1; - let tmp = dataStr!.slice(start, end); - return JSON.parse(tmp); - } else { - //dataStr如果解码失败是空的时候,还需要继续尝试解码。极端情况,服务器不是utf8的,所以字符解码会出现乱码,所以特殊处理一下非utf8的字符。 - if (data == null) { - return data; - } - - let currentStr : string | null = dataStr; - //todo 等uts支持swift文件混编的时候,再进行处理。 - // if (currentStr == null) { - // let data = cleanUTF8(data); - // if (data != null) { - // currentStr = new String(data = data, encoding = String.Encoding.utf8); - // } - // } - - if (currentStr == null) { - currentStr = new String(data = data!, encoding = String.Encoding.utf8); - } - // utf8 如果失败了,就用ascii,虽然几率很小。 - if (currentStr == null) { - currentStr = new String(data = data!, encoding = String.Encoding.ascii); - } - - return currentStr; + private parseData(data : Data | null, dataStr : string | null, type : string | null) : any | null { + if (type != null && type!.contains("json")) { + if (dataStr == null || dataStr!.length == 0) { + return {}; } - } else { + return this.parseJson(dataStr!); + } else if (type == 'jsonp') { if (dataStr == null || dataStr!.length == 0) { - return null; + return {}; + } + let start = dataStr!.indexOf('('); + let end = dataStr!.indexOf(')'); + if (start == 0 || start >= end) { + return {}; + } + start += 1; + let tmp = dataStr!.slice(start, end); + return this.parseJson(tmp); + } else { + //dataStr如果解码失败是空的时候,还需要继续尝试解码。极端情况,服务器不是utf8的,所以字符解码会出现乱码,所以特殊处理一下非utf8的字符。 + if (data == null) { + return data; } - return JSON.parse(dataStr!) + + let currentStr : string | null = dataStr; + //todo 等uts支持swift文件混编的时候,再进行处理。 + // if (currentStr == null) { + // let data = cleanUTF8(data); + // if (data != null) { + // currentStr = new String(data = data, encoding = String.Encoding.utf8); + // } + // } + + if (currentStr == null) { + currentStr = new String(data = data!, encoding = String.Encoding.ascii); + } + + return currentStr; } } + + private parseJson(str : string) : any | null { + return JSON.parse(str); + } + private parseCookie(header : Map | null) : string[] { if (header == null) { return [] @@ -291,7 +275,7 @@ class UploadNetworkListener implements NetworkUploadFileListener { } class DownloadNetworkListener implements NetworkDownloadFileListener { - public options : DownloadFileOptions | null = null; + public options : DownloadFileOptions | null = null; public progressListeners : Array = []; private data : Data = new Data(); @@ -309,19 +293,19 @@ class DownloadNetworkListener implements NetworkDownloadFileListener { } } - onFinished(response : HTTPURLResponse, filePath : string) : void { - try { - let kParam = this.options; - let tmp : DownloadFileSuccess = { - tempFilePath: filePath, - statusCode: response.statusCode - }; - let success = kParam?.success; - let complete = kParam?.complete; - success?.(tmp); - complete?.(tmp); - } catch (e) { - } + onFinished(response : HTTPURLResponse, filePath: string) : void { + try { + let kParam = this.options; + let tmp : DownloadFileSuccess = { + tempFilePath:filePath, + statusCode: response.statusCode + }; + let success = kParam?.success; + let complete = kParam?.complete; + success?.(tmp); + complete?.(tmp); + } catch (e) { + } this.progressListeners.splice(0, this.progressListeners.length) } @@ -329,7 +313,7 @@ class DownloadNetworkListener implements NetworkDownloadFileListener { let kParam = this.options; let code = (error as NSError).code; let errCode = code; - let cause = error.localizedDescription; + let cause = error.localizedDescription; if (code == -1001) { errCode = 5; } else if (code == -1004) { @@ -351,15 +335,10 @@ class DownloadNetworkListener implements NetworkDownloadFileListener { } -// export const request : Request = (options : RequestOptions) : RequestTask => { -// return NetworkManager.getInstance().request(options, new SimpleNetworkListener(options)); -// } - -export function request(options : RequestOptions, _t : T.Type) : RequestTask { - return NetworkManager.getInstance().request(options, new SimpleNetworkListener(options)); +export const request : Request = (options : RequestOptions) : RequestTask => { + return NetworkManager.getInstance().request(options, new SimpleNetworkListener(options)); } - export const uploadFile : UploadFile = (options : UploadFileOptions) : UploadTask => { return NetworkManager.getInstance().uploadFile(options, new UploadNetworkListener(options)); } diff --git a/uni_modules/uni-network/utssdk/app-ios/interface.uts b/uni_modules/uni-network/utssdk/app-ios/interface.uts index 107b8e9d1aab553b7cf81a1904d04a902dfb1479..37309cf04844162d9e7412e83165168e204c7a0c 100644 --- a/uni_modules/uni-network/utssdk/app-ios/interface.uts +++ b/uni_modules/uni-network/utssdk/app-ios/interface.uts @@ -1,10 +1,10 @@ -export type Request = (param: RequestOptions) => RequestTask; +export type Request = (param: RequestOptions) => RequestTask; /** * 网络请求参数 */ -export type RequestOptions = { +export type RequestOptions = { /** * 开发者服务器接口地址 */ @@ -80,7 +80,7 @@ export type RequestOptions = { * 网络请求成功回调。 * @defaultValue null */ - success?: RequestSuccessCallback | null, + success?: RequestSuccessCallback | null, /** * 网络请求失败回调。 * @defaultValue null @@ -93,12 +93,12 @@ export type RequestOptions = { complete?: RequestCompleteCallback | null } -export type RequestSuccess = { +export type RequestSuccess = { /** * 开发者服务器返回的数据 * @type {RequestDataOptions} */ - data: T | null, + data: any | null, /** * 开发者服务器返回的 HTTP 状态码 */ @@ -138,7 +138,7 @@ export type RequestMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" export type RequestErrorCode = 5 | 1000 | 100001 | 100002 | 600003 | 600009 | 602001; -// export type RequestFail = UniError; +export type RequestFail = UniError; // /** // * 网络请求失败的错误回调参数 // */ @@ -146,7 +146,8 @@ export type RequestErrorCode = 5 | 1000 | 100001 | 100002 | 600003 | 600009 | 60 // errCode: RequestErrorCode // }; -export type RequestSuccessCallback = (option: RequestSuccess) => void; + +export type RequestSuccessCallback = (option: RequestSuccess) => void; export type RequestFailCallback = (option: RequestFail) => void; export type RequestCompleteCallback = (option: any) => void; @@ -230,7 +231,7 @@ export type UploadFileSuccess = { statusCode: number }; export type UploadFileSuccessCallback = (result: UploadFileSuccess) => void; -// export type UploadFileFail = UniError; +export type UploadFileFail = UniError; // /** // * 上传文件失败的错误回调参数 // */ @@ -386,7 +387,7 @@ export type DownloadFileSuccess = { statusCode: number }; export type DownloadFileSuccessCallback = (result: DownloadFileSuccess) => void; -// export type DownloadFileFail = UniError; +export type DownloadFileFail = UniError; // /** // * 下载文件失败的错误回调参数 // */ @@ -569,7 +570,7 @@ export interface Uni { }); ``` */ - request(param: RequestOptions): RequestTask; + request: Request, /** * UploadFile() * @description @@ -606,7 +607,7 @@ export interface Uni { }); ``` */ - uploadFile: UploadFile; + uploadFile: UploadFile, /** * DownloadFile() * @description @@ -638,5 +639,5 @@ export interface Uni { }); ``` */ - downloadFile: DownloadFile; + downloadFile: DownloadFile } diff --git a/uni_modules/uni-network/utssdk/app-ios/network/NetworkManager.uts b/uni_modules/uni-network/utssdk/app-ios/network/NetworkManager.uts index 089a2ee48a8107e36a10757e0b5767c3f6ca5cb2..fbe465d257751717cf63f74a01d870d5c4d1784b 100644 --- a/uni_modules/uni-network/utssdk/app-ios/network/NetworkManager.uts +++ b/uni_modules/uni-network/utssdk/app-ios/network/NetworkManager.uts @@ -60,7 +60,7 @@ class NetworkManager implements URLSessionDataDelegate { } - public request(param : RequestOptions, listener : NetworkRequestListener) : RequestTask { + public request(param : RequestOptions, listener : NetworkRequestListener) : RequestTask { let request = this.createRequest(param); if (request == null) { let error = new NSError(domain = "invalid URL", code = 600009); @@ -91,7 +91,7 @@ class NetworkManager implements URLSessionDataDelegate { } - public createRequest(param : RequestOptions) : URLRequest | null { + public createRequest(param : RequestOptions) : URLRequest | null { let url = new URL(string = param.url); if (url == null) { return null diff --git a/uni_modules/uni-network/utssdk/interface.uts b/uni_modules/uni-network/utssdk/interface.uts index 36bba999a63c1b5f7c5ea76a92d09a083f0dd16c..f54d17f6f73a853a23c81af7e917e97b63838469 100644 --- a/uni_modules/uni-network/utssdk/interface.uts +++ b/uni_modules/uni-network/utssdk/interface.uts @@ -6,63 +6,17 @@ export type Request = (param: RequestOptions) => RequestTask; export type RequestOptions = { /** * 开发者服务器接口地址 - * - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ url: string, /** * 请求的参数 UTSJSONObject|string类型 * @type {RequestDataOptions} * @defaultValue null - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ data?: any | null, /** * 设置请求的 header,header 中不能设置 Referer * @defaultValue null - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ header?: UTSJSONObject | null, /** @@ -70,41 +24,11 @@ export type RequestOptions = { * 如果设置的值不在取值范围内,会以GET方法进行请求。 * @type {RequestMethod} * @defaultValue "GET" - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ method?: RequestMethod | null, /** * 超时时间,单位 ms * @defaultValue 60000 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ timeout?: number | null, /** @@ -155,21 +79,6 @@ export type RequestOptions = { /** * DNS解析时优先使用ipv4 * @defaultValue false - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "x" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "x" - * } - * } - * } */ firstIpv4?: boolean | null, /** @@ -193,78 +102,18 @@ export type RequestSuccess = { /** * 开发者服务器返回的数据 * @type {RequestDataOptions} - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ data: T | null, /** * 开发者服务器返回的 HTTP 状态码 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ statusCode: number, /** * 开发者服务器返回的 HTTP Response Header - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ header: any, /** * 开发者服务器返回的 cookies,格式为字符串数组 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ cookies: Array } @@ -350,40 +199,10 @@ export type UploadFileOptionFiles = { /** * multipart 提交时,表单的项目名,默认为 file,如果 name 不填或填的值相同,可能导致服务端读取文件时只能读取到一个文件。 * @defaultValue "file" - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ name?: string | null, /** * 要上传文件资源的路径 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ uri: string, /** @@ -413,40 +232,10 @@ export type UploadFileOptionFiles = { export type UploadFileSuccess = { /** * 开发者服务器返回的数据 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ data: string, /** * 开发者服务器返回的 HTTP 状态码 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ statusCode: number }; @@ -463,141 +252,36 @@ export type UploadFileCompleteCallback = (result: any) => void; export type UploadFileOptions = { /** * 开发者服务器 url - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ url: string, /** * 要上传文件资源的路径, 支持uni.env * @defaultValue null - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ filePath?: string | null, /** * 文件对应的 key , 开发者在服务器端通过这个 key 可以获取到文件二进制内容 * @defaultValue null - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ name?: string | null, /** * 需要上传的文件列表。 * @defaultValue null - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ files?: (UploadFileOptionFiles[]) | null, /** * HTTP 请求 Header, header 中不能设置 Referer * @defaultValue null - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ header?: UTSJSONObject | null, /** * HTTP 请求中其他额外的 form data * @defaultValue null - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ formData?: UTSJSONObject | null, /** * 超时时间,单位 ms * @defaultValue 120000 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ timeout?: number | null, /** @@ -619,59 +303,14 @@ export type UploadFileOptions = { export type OnProgressUpdateResult = { /** * 上传进度百分比 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ progress: number, /** * 已经上传的数据长度,单位 Bytes - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ totalBytesSent: number, /** * 预期需要上传的数据总长度,单位 Bytes - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ totalBytesExpectedToSend: number }; @@ -758,40 +397,10 @@ export type DownloadFile = (options: DownloadFileOptions) => DownloadTask; export type DownloadFileSuccess = { /** * 临时文件路径,下载后的文件会存储到一个临时文件 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ tempFilePath: string, /** * 开发者服务器返回的 HTTP 状态码 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ statusCode: number }; @@ -808,41 +417,11 @@ export type DownloadFileCompleteCallback = (result: DownloadFileComplete) => voi export type DownloadFileOptions = { /** * 下载资源的 url - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ url: string, /** * HTTP 请求 Header,header 中不能设置 Referer * @defaultValue null - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ header?: UTSJSONObject | null, /** @@ -853,41 +432,11 @@ export type DownloadFileOptions = { * `/imgs/` * 支持uni.env的平台兼容性:Android自3.9开始支持uni.env,iOS自4.13开始支持uni.env * @defaultValue null - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ filePath?: string | null, /** * 超时时间,单位 ms * @defaultValue 120000 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ timeout?: number | null, /** @@ -909,59 +458,14 @@ export type DownloadFileOptions = { export type OnProgressDownloadResult = { /** * 下载进度百分比 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ progress: number, /** * 已经下载的数据长度,单位 Bytes - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ totalBytesWritten: number, /** * 预期需要下载的数据总长度,单位 Bytes - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ totalBytesExpectedToWrite: number }; diff --git a/uni_modules/uni-payment-alipay/utssdk/app-android/Alipay.uts b/uni_modules/uni-payment-alipay/utssdk/app-android/Alipay.uts index 353650359ffa3313eeacc70a82f3ef53050fb45c..650dc10baece1de55207b4d10f4f1b1ca70ca2a8 100644 --- a/uni_modules/uni-payment-alipay/utssdk/app-android/Alipay.uts +++ b/uni_modules/uni-payment-alipay/utssdk/app-android/Alipay.uts @@ -1,13 +1,13 @@ import PayTask from 'com.alipay.sdk.app.PayTask'; import string from 'android.R.string'; -const defaultErrorCode : number = 700000 +const defaultErrorCode : number = 700716 const errorCodeMap : Map = new Map([ - [8000, 700600], - [4000, 701100], - [5000, 701110], - [6001, 700601], - [6002, 700602], - [6004, 700603] + [8000, 700710], + [4000, 700711], + [5000, 700712], + [6001, 700713], + [6002, 700714], + [6004, 700715] ]) export class Alipay { public requestPayment(options : RequestPaymentOptions) { diff --git a/uni_modules/uni-payment-alipay/utssdk/app-ios/Alipay.uts b/uni_modules/uni-payment-alipay/utssdk/app-ios/Alipay.uts new file mode 100644 index 0000000000000000000000000000000000000000..efdbb886b1d70976adac826c8806566af5f9db54 --- /dev/null +++ b/uni_modules/uni-payment-alipay/utssdk/app-ios/Alipay.uts @@ -0,0 +1,77 @@ +import { UTSiOSHookProxy } from "DCloudUniappRuntime"; +import { UIApplication } from "UIKit" +import { AlipaySDK } from "AlipaySDK" +import { URL, NSUserActivity, NSUserActivityTypeBrowsingWeb } from "Foundation" + + +const defaultErrorCode : number = 700716; + +const errorCodeMap : Map = new Map([ + ['8000', 700710], + ['4000', 700711], + ['5000', 700712], + ['6001', 700713], + ['6002', 700714], + ['6004', 700715] +]); + +export class Alipay implements UTSiOSHookProxy { + + options ?: RequestPaymentOptions + + // 通过 url scheme 方式唤起 app 时的回调函数。 + applicationOpenURLOptions(app : UIApplication | null, url : URL, options : Map | null = null) : boolean { + if (url.host == 'safepay') { + AlipaySDK.defaultService().processOrder(withPaymentResult = url, standbyCallback = (resultDic ?: Map) : void => { + this.handlePaymentResult(resultDic) + }) + } + return true + } + + // 当应用程序接收到与用户活动相关的数据时调用此方法,例如,当用户使用 Universal Link 唤起应用时。 + applicationContinueUserActivityRestorationHandler(application : UIApplication | null, userActivity : NSUserActivity | null, restorationHandler : ((res : [any] | null) => void) | null = null) : boolean { + if (userActivity?.activityType == NSUserActivityTypeBrowsingWeb) { + AlipaySDK.defaultService().handleOpenUniversalLink(userActivity, standbyCallback = (resultDic ?: Map) : void => { + this.handlePaymentResult(resultDic) + }) + } + return true + } + + requestPayment(options : RequestPaymentOptions) { + this.options = options + AlipaySDK.defaultService().payOrder(options.orderInfo, fromScheme = "uniAlipay", fromUniversalLink = "", callback = (resultDic ?: Map) : void => { + this.handlePaymentResult(resultDic) + }) + } + + handlePaymentResult(resultDic ?: Map) { + let resultStatus : string = '' + if (resultDic == null) { + resultStatus = defaultErrorCode.toString() + } else { + resultStatus = resultDic!.get("resultStatus") as string + if (resultStatus == null) { + resultStatus = defaultErrorCode.toString() + } + } + + if (resultStatus == "9000") { + let res : RequestPaymentSuccess = { + data: resultDic + } + this.options?.success?.(res) + this.options?.complete?.(res) + } else { + let code = errorCodeMap[resultStatus]; + if (code == null) { + code = defaultErrorCode + } + let err = new RequestPaymentFailImpl(code!); + this.options?.fail?.(err) + this.options?.complete?.(err) + } + + } +} \ No newline at end of file diff --git a/uni_modules/uni-payment-alipay/utssdk/app-ios/config.json b/uni_modules/uni-payment-alipay/utssdk/app-ios/config.json index 7148fc57181e9520eaa4559cde3e07581f32aafc..25eb4ef311a538f0457ada60afcbb082ea48ed75 100644 --- a/uni_modules/uni-payment-alipay/utssdk/app-ios/config.json +++ b/uni_modules/uni-payment-alipay/utssdk/app-ios/config.json @@ -1,37 +1,17 @@ -{ - "frameworks": [ - "libc++.tbd", - "libz.tbd", - "SystemConfiguration.framework", - "CoreTelephony.framework", - "QuartzCore.framework", - "CoreText.framework", - "CoreGraphics.framework", - "UIKit.framework", - "Foundation.framework", - "CFNetwork.framework", - "CoreMotion.framework" - ], - "deploymentTarget": "12.0", - "parameters": { - "universalLink": { - "des": "请填写能唤起当前应用的Universal Links路径(https开头,以“/”结尾,建议带path,比如“https://your_domain/app/”),在实际调用SDK时,会校验Universal Links是否匹配" - } - }, - "plists": { - "CFBundleURLTypes": [{ - "CFBundleTypeRole": "Editor", - "CFBundleURLName": "Alipay", - "CFBundleURLSchemes": [ - "alipay{$_dcloud_appid_md5}" - ] - }], - "LSApplicationQueriesSchemes": [ - "alipay", - "safepay" - ], - "Alipay": { - "universalLink": "{$universalLink}" - } - } -} \ No newline at end of file +{ + "frameworks": [ + "libc++.tbd", + "libz.tbd", + "SystemConfiguration.framework", + "CoreTelephony.framework", + "QuartzCore.framework", + "CoreText.framework", + "CoreGraphics.framework", + "UIKit.framework", + "Foundation.framework", + "CFNetwork.framework", + "CoreMotion.framework" + ], + "deploymentTarget": "12.0" +} + diff --git a/uni_modules/uni-payment-alipay/utssdk/app-ios/index.uts b/uni_modules/uni-payment-alipay/utssdk/app-ios/index.uts index bd1499c3305092c672050a587a63668fd23d955c..4015a64e0e30f780b78e2eee90bbe01d87d8b7b1 100644 --- a/uni_modules/uni-payment-alipay/utssdk/app-ios/index.uts +++ b/uni_modules/uni-payment-alipay/utssdk/app-ios/index.uts @@ -1,135 +1,5 @@ -import { UTSiOSHookProxy } from "DCloudUniappRuntime"; -import { UIApplication } from "UIKit" -import { AlipaySDK } from "AlipaySDK" assert { type: "implementationOnly" }; -import { URL, NSUserActivity, NSUserActivityTypeBrowsingWeb, Bundle } from "Foundation" +import { Alipay } from './Alipay.uts' export const requestPayment : RequestPayment = function (options : RequestPaymentOptions) { - Alipay.requestPayment(options) -}; - - -const defaultErrorCode : number = 700000; - -const errorCodeMap : Map = new Map([ - ['8000', 700600], - ['4000', 701100], - ['5000', 701110], - ['6001', 700601], - ['6002', 700602], - ['6004', 700603] -]); - -export class AlipayHookProxy implements UTSiOSHookProxy { - - // 通过 url scheme 方式唤起 app 时的回调函数。 - applicationOpenURLOptions(app : UIApplication | null, url : URL, options : Map | null = null) : boolean { - // this.processOrder(url) - Alipay.share.processOrder(url) - return true - } - - // 当应用程序接收到与用户活动相关的数据时调用此方法,例如,当用户使用 Universal Link 唤起应用时。 - applicationContinueUserActivityRestorationHandler(application : UIApplication | null, userActivity : NSUserActivity | null, restorationHandler : ((res : [any] | null) => void) | null = null) : boolean { - Alipay.share.handleOpenUniversalLink(userActivity) - return true - } -} - -export class Alipay { - static share = new Alipay() - - private options ?: RequestPaymentOptions - - static requestPayment(options : RequestPaymentOptions) { - Alipay.share.options = options - if (Alipay.share.getApplicationScheme() == null) { - let err = new RequestPaymentFailImpl(700800); - Alipay.share.options?.fail?.(err) - Alipay.share.options?.complete?.(err) - return - } - Alipay.share.payOrder() - } - - @UTSiOS.keyword("fileprivate") - processOrder(url : URL) { - if (url.host == 'safepay') { - AlipaySDK.defaultService().processOrder(withPaymentResult = url, standbyCallback = (resultDic ?: Map) : void => { - this.handlePaymentResult(resultDic) - }) - } - } - - @UTSiOS.keyword("fileprivate") - handleOpenUniversalLink(userActivity : NSUserActivity | null) { - if (userActivity?.activityType == NSUserActivityTypeBrowsingWeb) { - AlipaySDK.defaultService().handleOpenUniversalLink(userActivity, standbyCallback = (resultDic ?: Map) : void => { - this.handlePaymentResult(resultDic) - }) - } - } - - private payOrder() { - AlipaySDK.defaultService().payOrder(this.options?.orderInfo, fromScheme = this.getApplicationScheme(), fromUniversalLink = this.getApplicationUniversalLink(), callback = (resultDic ?: Map) : void => { - this.handlePaymentResult(resultDic) - }) - } - - private getApplicationScheme() : string | null { - let scheme : string | null = null - const infoDictionary = Bundle.main.infoDictionary - if (infoDictionary != null) { - const bundleURLTypes = infoDictionary!['CFBundleURLTypes'] as Map[] | null - if (bundleURLTypes != null) { - bundleURLTypes!.forEach((value, key) => { - const urlIdentifier = value['CFBundleURLName'] as string | null - if (urlIdentifier != null && urlIdentifier!.toLowerCase() == "alipay") { - const urlSchemes = value['CFBundleURLSchemes'] as string[] - scheme = urlSchemes[0] - } - }) - } - } - return scheme - } - - private getApplicationUniversalLink() : string | null { - let universalLink : string | null = null - const infoDictionary = Bundle.main.infoDictionary - if (infoDictionary != null) { - const alipay = infoDictionary!['Alipay'] as Map | null - if (alipay != null) { - universalLink = alipay!['universalLink'] as string | null - } - } - return universalLink - } - - private handlePaymentResult(resultDic ?: Map) { - let resultStatus : string = '' - if (resultDic == null) { - resultStatus = defaultErrorCode.toString() - } else { - resultStatus = resultDic!.get("resultStatus") as string - if (resultStatus == null) { - resultStatus = defaultErrorCode.toString() - } - } - - if (resultStatus == "9000") { - let res : RequestPaymentSuccess = { - data: resultDic - } - Alipay.share.options?.success?.(res) - Alipay.share.options?.complete?.(res) - } else { - let code = errorCodeMap[resultStatus]; - if (code == null) { - code = defaultErrorCode - } - let err = new RequestPaymentFailImpl(code!); - Alipay.share.options?.fail?.(err) - Alipay.share.options?.complete?.(err) - } - } -} \ No newline at end of file + new Alipay().requestPayment(options) +}; \ No newline at end of file diff --git a/uni_modules/uni-payment-alipay/utssdk/app-ios/info.plist b/uni_modules/uni-payment-alipay/utssdk/app-ios/info.plist new file mode 100644 index 0000000000000000000000000000000000000000..2ee241cee6d6cf8e70c2b8570e76a2ee456bc651 --- /dev/null +++ b/uni_modules/uni-payment-alipay/utssdk/app-ios/info.plist @@ -0,0 +1,19 @@ + + + + + CFBundleURLTypes + + + CFBundleURLSchemes + + uniAlipay + + + + LSApplicationQueriesSchemes + + alipays + + + \ No newline at end of file diff --git a/uni_modules/uni-payment-wxpay/utssdk/app-android/src/WXPayEntryActivity.uts b/uni_modules/uni-payment-wxpay/utssdk/app-android/src/WXPayEntryActivity.uts index 149c7d570183331e2b86e2b55b9a1c122dd79b80..59838e098773d6fe76a6a36280509f30ba8a5f6b 100644 --- a/uni_modules/uni-payment-wxpay/utssdk/app-android/src/WXPayEntryActivity.uts +++ b/uni_modules/uni-payment-wxpay/utssdk/app-android/src/WXPayEntryActivity.uts @@ -7,10 +7,10 @@ import Bundle from 'android.os.Bundle' import WXAPIFactory from 'com.tencent.mm.opensdk.openapi.WXAPIFactory'; import {Wxpay} from './Wxpay'; import R from 'uts.sdk.modules.uniPaymentWxpay.R'; -const defaultErrorCode : number = 700000 +const defaultErrorCode : number = 700716 const errorCodeMap : Map = new Map([ - [-1, 701100], - [-2, 700601] + [-1, 700711], + [-2, 700713] ]) export class WXPayEntryActivity extends Activity implements IWXAPIEventHandler { constructor() { diff --git a/uni_modules/uni-payment-wxpay/utssdk/app-android/src/Wxpay.uts b/uni_modules/uni-payment-wxpay/utssdk/app-android/src/Wxpay.uts index 2303ac2c7ed234aa34467766dc30740692b650e6..2eff27a35d315e4b6d7dde9a679c2410a7311d14 100644 --- a/uni_modules/uni-payment-wxpay/utssdk/app-android/src/Wxpay.uts +++ b/uni_modules/uni-payment-wxpay/utssdk/app-android/src/Wxpay.uts @@ -2,7 +2,7 @@ import IWXAPI from 'com.tencent.mm.opensdk.openapi.IWXAPI'; import WXAPIFactory from 'com.tencent.mm.opensdk.openapi.WXAPIFactory'; import PayReq from 'com.tencent.mm.opensdk.modelpay.PayReq'; import BaseReq from 'com.tencent.mm.opensdk.modelbase.BaseReq'; -const defaultErrorCode : number = 700000 +const defaultErrorCode : number = 700716 export class Wxpay { public static mOptions : RequestPaymentOptions = { orderInfo: "", @@ -10,7 +10,7 @@ export class Wxpay { } as RequestPaymentOptions public requestPayment(options : RequestPaymentOptions) { if (!Wxpay.isInstalled()) { - let err = new RequestPaymentFailImpl(700604); + let err = new RequestPaymentFailImpl(700717); options.fail?.(err) options.complete?.(err) return diff --git a/uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WeChatSDK/README.txt b/uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/README.txt similarity index 100% rename from uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WeChatSDK/README.txt rename to uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/README.txt diff --git a/uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WeChatSDK/WXApi.h b/uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WXApi.h similarity index 100% rename from uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WeChatSDK/WXApi.h rename to uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WXApi.h diff --git a/uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WeChatSDK/WXApiObject.h b/uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WXApiObject.h similarity index 100% rename from uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WeChatSDK/WXApiObject.h rename to uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WXApiObject.h diff --git a/uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WeChatSDK/WechatAuthSDK.h b/uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WechatAuthSDK.h similarity index 100% rename from uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WeChatSDK/WechatAuthSDK.h rename to uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WechatAuthSDK.h diff --git a/uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WeChatSDK/libWeChatSDK.a b/uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/libWeChatSDK.a similarity index 100% rename from uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/WeChatSDK/libWeChatSDK.a rename to uni_modules/uni-payment-wxpay/utssdk/app-ios/Libs/libWeChatSDK.a diff --git a/uni_modules/uni-payment-wxpay/utssdk/app-ios/UTS.entitlements b/uni_modules/uni-payment-wxpay/utssdk/app-ios/UTS.entitlements deleted file mode 100644 index 8edb490a56cb2386335c474ef4df92504df8bdb8..0000000000000000000000000000000000000000 --- a/uni_modules/uni-payment-wxpay/utssdk/app-ios/UTS.entitlements +++ /dev/null @@ -1,11 +0,0 @@ - - - - - com.apple.developer.associated-domains - - applinks: uniappx.dcloud.net.cn - applinks: hellouniappx.dcloud.net.cn - - - diff --git a/uni_modules/uni-payment-wxpay/utssdk/app-ios/Wxpay.uts b/uni_modules/uni-payment-wxpay/utssdk/app-ios/Wxpay.uts new file mode 100644 index 0000000000000000000000000000000000000000..dd8b54844b402a33a6dbc9a2b1ee648507d0e5af --- /dev/null +++ b/uni_modules/uni-payment-wxpay/utssdk/app-ios/Wxpay.uts @@ -0,0 +1,113 @@ +import { WXApi, WXApiDelegate, BaseReq, PayReq, PayResp } from "WechatOpenSDK"; +import { UTSiOSHookProxy } from "DCloudUniappRuntime"; +import { UIApplication } from "UIKit"; +import { URL, NSUserActivity } from "Foundation"; + +const defaultErrorCode : number = 700716 + +const errorCodeMap : Map = new Map([ + [-1, 700711], + [-2, 700713] +]) + +export class Wxpay implements UTSiOSHookProxy, WXApiDelegate { + + options ?: RequestPaymentOptions + + // 应用正常启动时 (不包括已在后台转到前台的情况)的回调函数。 + applicationDidFinishLaunchingWithOptions(application : UIApplication | null, launchOptions : Map | null = null) : boolean { + WXApi.registerApp('wxd930ea5d5a258f4f', universalLink = 'YourUniversionLink') + return false + } + + // 通过 url scheme 方式唤起 app 时的回调函数。 + applicationOpenURLOptions(app : UIApplication | null, url : URL, options : Map | null = null) : boolean { + + WXApi.handleOpen(url, delegate = this) + return true + } + + // 当应用程序接收到与用户活动相关的数据时调用此方法,例如,当用户使用 Universal Link 唤起应用时。 + applicationContinueUserActivityRestorationHandler(application : UIApplication | null, userActivity : NSUserActivity | null, restorationHandler : ((res : [any] | null) => void) | null = null) : boolean { + if (userActivity != null) { + WXApi.handleOpenUniversalLink(userActivity!, delegate = this) + } + + return true + } + + //@brief 收到一个来自微信的请求,第三方应用程序处理完后调用sendResp向微信发送结果 + onReq(req : BaseReq) { + //TODO + } + + //@brief 发送一个sendReq后,收到微信的回应 + onResp(resp : BaseReq) { + const payResp :PayResp | null = resp as PayResp + if (payResp != null) { + if (payResp!.errCode == 0) { + let res : RequestPaymentSuccess = { + data: payResp! + } + this.options?.success?.(res) + this.options?.complete?.(res) + } else { + const errCode = payResp!.errCode as number + let code = errorCodeMap[errCode]; + if (code == null) { + code = defaultErrorCode + } + let err = new RequestPaymentFailImpl(code!); + this.options?.fail?.(err) + this.options?.complete?.(err) + } + } + } + + requestPayment(options : RequestPaymentOptions) { + this.options = options + + if (this.isWXAppInstalled() == true) { + let err = new RequestPaymentFailImpl(defaultErrorCode); + options.fail?.(err) + options.complete?.(err) + return + } + + const params = JSON.parse(options.orderInfo) as UTSJSONObject + const partnerId = params.getString("partnerid") + const prepayId = params.getString("prepayid") + const packageV = params.getString("package") + const nonceStr = params.getString("noncestr") + const timeStamp = params.getNumber("timestamp") + const sign = params.getString("sign") + + let request = new PayReq(); + if (partnerId != null) { + request.partnerId = partnerId! + } + if (prepayId != null) { + request.prepayId = prepayId! + } + if (packageV != null) { + request.package = packageV! + } + if (nonceStr != null) { + request.nonceStr = nonceStr! + } + if (timeStamp != null) { + request.timeStamp = timeStamp!.toUInt32() + } + if (sign != null) { + request.sign = sign! + } + + //函数调用后,会切换到微信的界面。第三方应用程序等待微信返回onResp。微信在异步处理完成后一定会调用onResp + WXApi.send(request); + } + + //@brief 检查微信是否已被用户安装 + isWXAppInstalled() : boolean { + return WXApi.isWXAppInstalled() + } +} \ No newline at end of file diff --git a/uni_modules/uni-payment-wxpay/utssdk/app-ios/config.json b/uni_modules/uni-payment-wxpay/utssdk/app-ios/config.json index 8456495b88aa865a7c6d61766c13895510331b46..59db4269c476123234dc2e4ff2c84fa48edc1d48 100644 --- a/uni_modules/uni-payment-wxpay/utssdk/app-ios/config.json +++ b/uni_modules/uni-payment-wxpay/utssdk/app-ios/config.json @@ -1,30 +1,9 @@ -{ - "frameworks": [ - "CoreGraphics.framework", - "WebKit.framework", - "Security.framework" - ], - "deploymentTarget": "12.0", - "parameters": { - "appid": { - "des": "请填写微信开发者平台对应app的APPID" - }, - "universalLink": { - "des": "请填写能唤起当前应用的Universal Links路径(https开头,以“/”结尾,建议带path,比如“https://your_domain/app/”),在实际调用SDK时,会校验Universal Links是否匹配" - } - }, - "plists": { - "CFBundleURLTypes": [{ - "CFBundleTypeRole": "Editor", - "CFBundleURLName": "WeChat", - "CFBundleURLSchemes": [ - "{$appid}" - ] - }], - "LSApplicationQueriesSchemes": ["weixin", "weixinULAPI", "weixinURLParamsAPI"], - "WeChat": { - "appid": "{$appid}", - "universalLink": "{$universalLink}" - } - } -} \ No newline at end of file +{ + "frameworks": [ + "CoreGraphics.framework", + "WebKit.framework", + "Security.framework" + ], + "deploymentTarget": "12.0" +} + diff --git a/uni_modules/uni-payment-wxpay/utssdk/app-ios/index.uts b/uni_modules/uni-payment-wxpay/utssdk/app-ios/index.uts index f0a8ab7e4d33e55d3097a84a00154878c7b0dd8f..05ab1bb0345edb446754d7a06a3ee13646d21518 100644 --- a/uni_modules/uni-payment-wxpay/utssdk/app-ios/index.uts +++ b/uni_modules/uni-payment-wxpay/utssdk/app-ios/index.uts @@ -1,174 +1,5 @@ -import { UTSiOSHookProxy } from "DCloudUniappRuntime"; -import { UIApplication } from "UIKit"; -import { URL, NSUserActivity } from "Foundation"; +import { Wxpay } from "./Wxpay"; export const requestPayment : RequestPayment = function (options : RequestPaymentOptions) { - Wxpay.requestPayment(options) -}; - -const wxDefaultErrorCode : number = 700000 - -const wxErrorCodeMap : Map = new Map([ - [-1, 701100], - [-2, 700601] -]) - -export class WxpayHookProxy implements UTSiOSHookProxy { - // 应用正常启动时 (不包括已在后台转到前台的情况)的回调函数。 - applicationDidFinishLaunchingWithOptions(application : UIApplication | null, launchOptions : Map | null = null) : boolean { - Wxpay.share.registerApp() - return false - } - - // 通过 url scheme 方式唤起 app 时的回调函数。 - applicationOpenURLOptions(app : UIApplication | null, url : URL, options : Map | null = null) : boolean { - Wxpay.share.handleOpen(url) - return true - } - - // 当应用程序接收到与用户活动相关的数据时调用此方法,例如,当用户使用 Universal Link 唤起应用时。 - applicationContinueUserActivityRestorationHandler(application : UIApplication | null, userActivity : NSUserActivity | null, restorationHandler : ((res : [any] | null) => void) | null = null) : boolean { - Wxpay.share.handleOpenUniversalLink(userActivity) - return true - } -} - -export class Wxpay implements WXApiDelegate { - static share = new Wxpay() - - private options ?: RequestPaymentOptions - - @UTSiOS.keyword("fileprivate") - registerApp() { - const scheme = Wxpay.share.getApplicationScheme() - const universalLink = Wxpay.share.getApplicationUniversalLink() - if (scheme != null && universalLink != null) { - WXApi.registerApp(scheme!, universalLink = universalLink!) - } - } - - @UTSiOS.keyword("fileprivate") - handleOpen(url : URL) { - WXApi.handleOpen(url, delegate = this) - } - - @UTSiOS.keyword("fileprivate") - handleOpenUniversalLink(userActivity : NSUserActivity | null) { - if (userActivity != null) { - WXApi.handleOpenUniversalLink(userActivity!, delegate = this) - } - } - - private getApplicationScheme() : string | null { - let scheme : string | null = null - const infoDictionary = Bundle.main.infoDictionary - if (infoDictionary != null) { - const bundleURLTypes = infoDictionary!['CFBundleURLTypes'] as Map[] | null - if (bundleURLTypes != null) { - bundleURLTypes!.forEach((value, key) => { - const urlIdentifier = value['CFBundleURLName'] as string | null - if (urlIdentifier != null && urlIdentifier == "wechat") { - const urlSchemes = value['CFBundleURLSchemes'] as string[] - scheme = urlSchemes[0] - } - }) - } - } - return scheme - } - - private getApplicationUniversalLink() : string | null { - let universalLink : string | null = null - const infoDictionary = Bundle.main.infoDictionary - if (infoDictionary != null) { - const wechat = infoDictionary!['WeChat'] as Map | null - if (wechat != null) { - universalLink = wechat!['universalLink'] as string | null - } - } - return universalLink - } - - //@brief 检查微信是否已被用户安装 - private isWXAppInstalled() : boolean { - return WXApi.isWXAppInstalled() - } - - //@brief 发送一个sendReq后,收到微信的回应 - onResp(resp : BaseResp) { - if (resp.errCode == 0) { - let res : RequestPaymentSuccess = { - data: resp - } - this.options?.success?.(res) - this.options?.complete?.(res) - } else { - const errCode = resp.errCode as number - let code = wxErrorCodeMap[errCode]; - if (code == null) { - code = wxDefaultErrorCode - } - let err = new RequestPaymentFailImpl(code!); - this.options?.fail?.(err) - this.options?.complete?.(err) - } - } - - static requestPayment(options : RequestPaymentOptions) { - Wxpay.share.options = options - - if (Wxpay.share.isWXAppInstalled() == false) { - let err = new RequestPaymentFailImpl(wxDefaultErrorCode); - Wxpay.share.options?.fail?.(err) - Wxpay.share.options?.complete?.(err) - return - } - - if (Wxpay.share.getApplicationScheme() == null) { - let err = new RequestPaymentFailImpl(700800); - Wxpay.share.options?.fail?.(err) - Wxpay.share.options?.complete?.(err) - return - } - - if (Wxpay.share.getApplicationUniversalLink() == null) { - let err = new RequestPaymentFailImpl(700801); - Wxpay.share.options?.fail?.(err) - Wxpay.share.options?.complete?.(err) - return - } - - if (Wxpay.share.options != null) { - const params = JSON.parse(Wxpay.share.options!.orderInfo) as UTSJSONObject - const partnerId = params.getString("partnerid") - const prepayId = params.getString("prepayid") - const packageV = params.getString("package") - const nonceStr = params.getString("noncestr") - const timeStamp = params.getNumber("timestamp") - const sign = params.getString("sign") - - let request = new PayReq(); - if (partnerId != null) { - request.partnerId = partnerId! - } - if (prepayId != null) { - request.prepayId = prepayId! - } - if (packageV != null) { - request.package = packageV! - } - if (nonceStr != null) { - request.nonceStr = nonceStr! - } - if (timeStamp != null) { - request.timeStamp = timeStamp!.toUInt32() - } - if (sign != null) { - request.sign = sign! - } - - //函数调用后,会切换到微信的界面。第三方应用程序等待微信返回onResp。微信在异步处理完成后一定会调用onResp - WXApi.send(request); - } - } -} \ No newline at end of file + new Wxpay().requestPayment(options) +}; \ No newline at end of file diff --git a/uni_modules/uni-payment-wxpay/utssdk/app-ios/info.plist b/uni_modules/uni-payment-wxpay/utssdk/app-ios/info.plist new file mode 100644 index 0000000000000000000000000000000000000000..e62bd39f5d27468fec48daa59a18a3010fe3c51d --- /dev/null +++ b/uni_modules/uni-payment-wxpay/utssdk/app-ios/info.plist @@ -0,0 +1,21 @@ + + + + + CFBundleURLTypes + + + CFBundleURLSchemes + + wxd930ea5d5a258f4f + + + + LSApplicationQueriesSchemes + + weixin + weixinULAPI + weixinURLParamsAPI + + + \ No newline at end of file diff --git a/uni_modules/uni-payment/utssdk/app-android/index.uts b/uni_modules/uni-payment/utssdk/app-android/index.uts index 6d9252abb6f9457a7a8e7ccfa37dd1735ceda4c9..bf64aeec30e2131076ddfc52f08dd073eab76663 100644 --- a/uni_modules/uni-payment/utssdk/app-android/index.uts +++ b/uni_modules/uni-payment/utssdk/app-android/index.uts @@ -7,7 +7,7 @@ export const requestPayment : RequestPayment = function (options : RequestPaymen if (provider != null) { provider.requestPayment(options) } else { - let err = new RequestPaymentFailImpl(700000); + let err = new RequestPaymentFailImpl(700716); options.fail?.(err) options.complete?.(err) } diff --git a/uni_modules/uni-payment/utssdk/app-ios/index.uts b/uni_modules/uni-payment/utssdk/app-ios/index.uts index 75fdd5c2ca98edb21be40cde4fc9a98a45540c69..ffaefa5d7ff4840db0b982f75766f88c0c48d1e0 100644 --- a/uni_modules/uni-payment/utssdk/app-ios/index.uts +++ b/uni_modules/uni-payment/utssdk/app-ios/index.uts @@ -7,7 +7,7 @@ export const requestPayment : RequestPayment = function (options : RequestPaymen if(provider != null){ provider!.requestPayment(options) } else { - const err = new RequestPaymentFailImpl(700000); + const err = new RequestPaymentFailImpl(700716); options.fail?.(err) options.complete?.(err) } diff --git a/uni_modules/uni-payment/utssdk/interface.uts b/uni_modules/uni-payment/utssdk/interface.uts index b9ac8073d75423e801b5b31e432fc9bd85880ffe..151a34e1558cb95839f4ce40dc478d9caa0b60e5 100644 --- a/uni_modules/uni-payment/utssdk/interface.uts +++ b/uni_modules/uni-payment/utssdk/interface.uts @@ -40,18 +40,15 @@ export interface Uni { } /** * 错误码 - * - 700600 正在处理中,支付结果未知(有可能已经支付成功),请查询商家订单列表中订单的支付状态 - * - 701100 订单支付失败。 - * - 701110 重复请求。 - * - 700601 用户中途取消。 - * - 700602 网络连接出错。 - * - 700603 支付结果未知(有可能已经支付成功),请查询商家订单列表中订单的支付状态。 - * - 700000 其它支付错误。 - * - 700604 微信没有安装。 - * - 700800 没有配置对应的URL Scheme。 - * - 700801 没有配置对应的universal Link。 + * - 700710 正在处理中,支付结果未知(有可能已经支付成功),请查询商家订单列表中订单的支付状态 + * - 700711 订单支付失败。 + * - 700712 重复请求。 + * - 700713 用户中途取消。 + * - 700714 网络连接出错。 + * - 700715 支付结果未知(有可能已经支付成功),请查询商家订单列表中订单的支付状态。 + * - 700716 其它支付错误。 */ -export type RequestPaymentErrorCode = 700600 | 701100 | 701110 | 700601 | 700602 | 700603 | 700000 | 700604 | 700800 | 700801; +export type RequestPaymentErrorCode = 700710 | 700711 | 700712 | 700713 | 700714 | 700715 | 700716; export type RequestPayment = (options : RequestPaymentOptions) => void; export type RequestPaymentSuccess = { diff --git a/uni_modules/uni-payment/utssdk/unierror.uts b/uni_modules/uni-payment/utssdk/unierror.uts index 703e79a7371d6e35b2348548253ef25be3972f48..4c2a035bdf0ca16f3b32c9370c26215c47d173d7 100644 --- a/uni_modules/uni-payment/utssdk/unierror.uts +++ b/uni_modules/uni-payment/utssdk/unierror.uts @@ -12,40 +12,36 @@ const RequestPaymentUniErrors : Map = new Map([ /** * 正在处理中,支付结果未知(有可能已经支付成功),请查询商家订单列表中订单的支付状态。 */ - [700600, 'The payment result is unknown (it may have been successfully paid). Please check the payment status of the order in the merchant order list.'], + [700710, 'The payment result is unknown (it may have been successfully paid). Please check the payment status of the order in the merchant order list.'], /** * 订单支付失败。 */ - [701100, 'Order payment failure.'], + [700711, 'Order payment failure.'], /** * 重复请求。 */ - [701110, 'Repeat the request.'], + [700712, 'Repeat the request.'], /** * 用户中途取消。 */ - [700601, 'The user canceled midway.'], + [700713, 'The user canceled midway.'], /** * 网络连接出错。 */ - [700602, 'Network connection error.'], + [700714, 'Network connection error.'], /** * 支付结果未知(有可能已经支付成功),请查询商家订单列表中订单的支付状态。 */ - [700603, 'Payment result unknown (may have been successfully paid), please check the payment status of the order in the merchant order list.'], + [700715, 'Payment result unknown (may have been successfully paid), please check the payment status of the order in the merchant order list.'], /** * 其它支付错误。 */ - [700000, 'Other payment errors.'], + [700716, 'Other payment errors.'], /** * 微信没有安装 */ - [700604, 'Wechat is not installed.'], - /** - * iOS 没有配置对应的URL Scheme - */ - [700718, 'URL Scheme is not configured.'] + [700717, 'Wechat is not installed.'] ]); diff --git a/uni_modules/uni-prompt/utssdk/app-android/showToast.uts b/uni_modules/uni-prompt/utssdk/app-android/showToast.uts index 76c12323d7e4d1b1778deef94310cf0236e1c0fe..ebd9c1278fff29b8db2590e055d84762a39d2b4b 100644 --- a/uni_modules/uni-prompt/utssdk/app-android/showToast.uts +++ b/uni_modules/uni-prompt/utssdk/app-android/showToast.uts @@ -46,19 +46,10 @@ export function hideLoadingImpl() { closeToast("loading") } -// 全局存储 -const onReadyToast = new Map() - function closeToast(type : string | null) { if (type != null && type !== toastType) { return } - let pages = getCurrentPages(); - if (pages.length > 0) { - let page = pages[pages.length - 1]; - onReadyToast.remove(page) - } - if (timeout != null && (timeout as number) > 0) { clearTimeout(timeout as number) timeout = null @@ -134,17 +125,10 @@ function makeLoading(style : ShowLoadingOptions, type : string, errMsg : string) toast = alert alert?.showWaiting(); } else { - onReadyToast.set(page,options) onReady(() => { - if(onReadyToast.containsKey(page)){ - options = onReadyToast.get(page) as UTSJSONObject; - - const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options) - toast = alert - alert?.showWaiting(); - - onReadyToast.remove(page) - } + const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options) + toast = alert + alert?.showWaiting(); }, instance) } @@ -266,17 +250,10 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) { toast = alert alert?.showWaiting(); } else { - onReadyToast.set(page,options) onReady(() => { - if(onReadyToast.containsKey(page)){ - options = onReadyToast.get(page) as UTSJSONObject; - - const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options) - toast = alert - alert?.showWaiting(); - - onReadyToast.remove(page) - } + const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options) + toast = alert + alert?.showWaiting(); }, instance) } diff --git a/uni_modules/uni-route/utssdk/interface.uts b/uni_modules/uni-route/utssdk/interface.uts index dbbc821dcb3883481fa0ca7fe2d295032ce6e6af..4cf893e5ce95347a1c03061b5c5faac6e925a28a 100644 --- a/uni_modules/uni-route/utssdk/interface.uts +++ b/uni_modules/uni-route/utssdk/interface.uts @@ -151,8 +151,8 @@ export type NavigateToOptions = { * } * }, * "web": { - * "uniVer": "x", - * "unixVer": "x" + * "uniVer": "√", + * "unixVer": "4.0" * } * } */ @@ -215,8 +215,8 @@ export type NavigateToOptions = { * } * }, * "web": { - * "uniVer": "x", - * "unixVer": "x" + * "uniVer": "√", + * "unixVer": "4.0" * } * } */ @@ -1420,8 +1420,8 @@ export type NavigateBackOptions = { * } * }, * "web": { - * "uniVer": "x", - * "unixVer": "x" + * "uniVer": "√", + * "unixVer": "4.0" * } * } */ @@ -1484,8 +1484,8 @@ export type NavigateBackOptions = { * } * }, * "web": { - * "uniVer": "x", - * "unixVer": "x" + * "uniVer": "√", + * "unixVer": "4.0" * } * } */ diff --git a/uni_modules/uni-storage/utssdk/interface.uts b/uni_modules/uni-storage/utssdk/interface.uts index 34fc0989b1cb471957a4666a57cd00c9da9068a7..8706a39fdcca508c43cb0c9ed222069218a3c1e4 100644 --- a/uni_modules/uni-storage/utssdk/interface.uts +++ b/uni_modules/uni-storage/utssdk/interface.uts @@ -26,7 +26,7 @@ export type SetStorageOptions = { */ key: string, /** - * 需要存储的内容,只支持能通过 JSON.stringify 序列化的对象 + * 需要存储的内容,只支持原生类型、及能够通过 JSON.stringify 序列化的对象 */ data: any, /** @@ -275,7 +275,7 @@ export interface Uni { * 将 data 存储在本地storage存储中指定的 key 中,会覆盖掉原来该 key 对应的内容,这是一个同步接口。 * * @param {string} key 本地storage存储中的指定的 key - * @param {any} data 需要存储的内容,只支持能通过 JSON.stringify 序列化的对象 + * @param {any} data 需要存储的内容,只支持原生类型、及能够通过 JSON.stringify 序列化的对象 * @tutorial https://uniapp.dcloud.net.cn/api/storage/storage.html#setstoragesync * @uniPlatform { * "app": { diff --git a/uni_modules/uni-websocket/utssdk/app-ios/websocket/WebsockerClient.uts b/uni_modules/uni-websocket/utssdk/app-ios/websocket/WebsockerClient.uts index 0a12561928deaf5b5e03012edf3ce43081f1803c..e0db98b90fd2a3a73d6acbb254c5c16b7fdc1238 100644 --- a/uni_modules/uni-websocket/utssdk/app-ios/websocket/WebsockerClient.uts +++ b/uni_modules/uni-websocket/utssdk/app-ios/websocket/WebsockerClient.uts @@ -138,8 +138,8 @@ class RunnableTask { public execute() { if (this.looper == null || this.looper!.currentMode == null) { this.callback?.(); - } else { - this.looper?.perform(inModes = [RunLoop.Mode.common], block = () => { + } else { + this.looper?.perform(() => { this.callback?.(); }) } diff --git a/uni_modules/uni-websocket/utssdk/interface.uts b/uni_modules/uni-websocket/utssdk/interface.uts index dc22e70da955a0e45670c01a0dbda1b7396d722e..fd19440cde02b8fbf2c350e72d1f7d4d00e06dfd 100644 --- a/uni_modules/uni-websocket/utssdk/interface.uts +++ b/uni_modules/uni-websocket/utssdk/interface.uts @@ -266,61 +266,16 @@ type ConnectSocketCompleteCallback = (result: ConnectSocketComplete) => void; export type ConnectSocketOptions = { /** * 开发者服务器接口地址 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ url: string, /** * HTTP 请求 Header,header 中不能设置 Referer * @defaultValue null - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ header?: UTSJSONObject | null, /** * 子协议数组 * @defaultValue null - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ protocols?: (string[]) | null, /** @@ -363,21 +318,6 @@ export type SendSocketMessageOptions = { * 需要发送的内容 * @type string | ArrayBuffer * @type {SocketDataOptions} - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ data: any, /** @@ -400,41 +340,11 @@ export type CloseSocketOptions = { /** * 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。如果这个参数没有被指定,默认的取值是1000 (表示正常连接关闭) * @defaultValue 1000 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ code?: number | null, /** * 一个可读的字符串,表示连接被关闭的原因。这个字符串必须是不长于123字节的UTF-8 文本(不是字符) * @defaultValue "" - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ reason?: string | null, /** @@ -456,21 +366,6 @@ export type CloseSocketOptions = { export type OnSocketOpenCallbackResult = { /** * 连接成功的 HTTP 响应 Header - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ header: any }; @@ -478,21 +373,6 @@ export type OnSocketMessageCallbackResult = { /** * 服务器返回的消息 * @type {SocketDataOptions} - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ data: any }; @@ -714,41 +594,11 @@ export type OnSocketMessage = (callback: OnSocketMessageCallback) => void; export type CloseSocket = (options: CloseSocketOptions) => void; export type OnSocketCloseCallbackResult = { /** - * 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } + * 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。 */ code: number, /** * 一个可读的字符串,表示连接被关闭的原因。 - * @uniPlatform - * { - * "app": { - * "android": { - * "osVer": "5.0", - * "uniVer": "√", - * "unixVer": "3.9+" - * }, - * "ios": { - * "osVer": "12.0", - * "uniVer": "√", - * "unixVer": "4.11" - * } - * } - * } */ reason: string };