提交 24f0ec42 编写于 作者: DCloud-yyl's avatar DCloud-yyl

同步代码@HBuilderX4.21

上级 d38d3d80
...@@ -61,14 +61,16 @@ export interface Uni { ...@@ -61,14 +61,16 @@ export interface Uni {
* "android": { * "android": {
* "osVer": "5.0", * "osVer": "5.0",
* "uniVer": "3.8.15", * "uniVer": "3.8.15",
* "uniUtsPlugin": "3.9.0",
* "unixVer": "3.9.0", * "unixVer": "3.9.0",
* "utsPlugin": "3.9.0" * "unixUtsPlugin": "3.9.0"
* }, * },
* "ios": { * "ios": {
* "osVer": "x", * "osVer": "x",
* "uniVer": "x", * "uniVer": "x",
* "uniUtsPlugin": "x",
* "unixVer": "x", * "unixVer": "x",
* "utsPlugin": "x" * "unixUtsPlugin": "x"
* } * }
* }, * },
* "web": { * "web": {
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
"getFileSystemManager": { "getFileSystemManager": {
"name": "getFileSystemManager", "name": "getFileSystemManager",
"app": { "app": {
"js": false, "js": true,
"kotlin": true, "kotlin": true,
"swift": false "swift": false
} }
......
import File from 'java.io.File' import File from 'java.io.File'
import ParcelFileDescriptor from 'android.os.ParcelFileDescriptor' import ParcelFileDescriptor from 'android.os.ParcelFileDescriptor'
import { OpenFileOptions, OpenFileSuccessResult, OpenFileSyncOptions } from '../interface'; import { OpenFileOptions, OpenFileSuccessResult, OpenFileSyncOptions } from '../interface';
import { UniErrorSubject, UniErrors } from '../unierror'; import { UniErrorSubject,FileSystemManagerFailImpl,FileSystemManagerUniErrors } from '../unierror';
export class FileDescriptorUtil { export class FileDescriptorUtil {
public openMap : Map<string, File> = new Map() public openMap : Map<string, File> = new Map()
...@@ -28,12 +28,12 @@ export class FileDescriptorUtil { ...@@ -28,12 +28,12 @@ export class FileDescriptorUtil {
case 'ax': //类似于 'a',但如果路径存在,则失败 case 'ax': //类似于 'a',但如果路径存在,则失败
{ {
if (file.exists()) { if (file.exists()) {
let err = new UniError(UniErrorSubject, 1301005, UniErrors.get(1301005)!); let err = new FileSystemManagerFailImpl(1301005);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
} else { } else {
if (file.parentFile?.exists() == false) { if (file.parentFile?.exists() == false) {
let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)!); let err = new FileSystemManagerFailImpl(1300002);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
return return
...@@ -66,7 +66,7 @@ export class FileDescriptorUtil { ...@@ -66,7 +66,7 @@ export class FileDescriptorUtil {
case 'ax+': //类似于 'a+',但如果路径存在,则失败 case 'ax+': //类似于 'a+',但如果路径存在,则失败
{ {
if (file.exists()) { if (file.exists()) {
let err = new UniError(UniErrorSubject, 1301005, UniErrors.get(1301005)!); let err = new FileSystemManagerFailImpl(1301005);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
} else { } else {
...@@ -84,7 +84,7 @@ export class FileDescriptorUtil { ...@@ -84,7 +84,7 @@ export class FileDescriptorUtil {
case 'r': //打开文件用于读取。 如果文件不存在,则会发生异常 case 'r': //打开文件用于读取。 如果文件不存在,则会发生异常
{ {
if (!file.exists()) { if (!file.exists()) {
let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)!); let err = new FileSystemManagerFailImpl(1300002);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
} else { } else {
...@@ -104,7 +104,7 @@ export class FileDescriptorUtil { ...@@ -104,7 +104,7 @@ export class FileDescriptorUtil {
case 'r+': //打开文件用于读取和写入。 如果文件不存在,则会发生异常 case 'r+': //打开文件用于读取和写入。 如果文件不存在,则会发生异常
{ {
if (!file.exists()) { if (!file.exists()) {
let err = new UniError(UniErrorSubject, 1300002, UniErrors.get(1300002)!); let err = new FileSystemManagerFailImpl(1300002);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
} else { } else {
...@@ -136,7 +136,7 @@ export class FileDescriptorUtil { ...@@ -136,7 +136,7 @@ export class FileDescriptorUtil {
case 'wx'://类似于 'w',但如果路径存在,则失败 case 'wx'://类似于 'w',但如果路径存在,则失败
{ {
if (file.exists()) { if (file.exists()) {
let err = new UniError(UniErrorSubject, 1301005, UniErrors.get(1301005)!); let err = new FileSystemManagerFailImpl(1301005);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
} else { } else {
...@@ -168,7 +168,7 @@ export class FileDescriptorUtil { ...@@ -168,7 +168,7 @@ export class FileDescriptorUtil {
case 'wx+': // 类似于 'w+',但如果路径存在,则失败 case 'wx+': // 类似于 'w+',但如果路径存在,则失败
{ {
if (file.exists()) { if (file.exists()) {
let err = new UniError(UniErrorSubject, 1301005, UniErrors.get(1301005)!); let err = new FileSystemManagerFailImpl(1301005);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
} else { } else {
...@@ -187,7 +187,7 @@ export class FileDescriptorUtil { ...@@ -187,7 +187,7 @@ export class FileDescriptorUtil {
} }
} }
} catch (e) { } catch (e) {
let err = new UniError(UniErrorSubject, 1300201, UniErrors.get(1300201)! + ":" + e + " " + options.filePath); let err = new FileSystemManagerFailImpl(1300201);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
} }
...@@ -206,10 +206,10 @@ export class FileDescriptorUtil { ...@@ -206,10 +206,10 @@ export class FileDescriptorUtil {
case 'ax': //类似于 'a',但如果路径存在,则失败 case 'ax': //类似于 'a',但如果路径存在,则失败
{ {
if (file.exists()) { if (file.exists()) {
throw new Error(`${msgPrefix}${UniErrors[1301005]}`) throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1301005]}`)
} else { } else {
if (file.parentFile?.exists() == false) { if (file.parentFile?.exists() == false) {
throw new Error(`${msgPrefix}${UniErrors[1300002]}`) throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1300002]}`)
} else { } else {
file.createNewFile() file.createNewFile()
let fd = this.open_a(file) let fd = this.open_a(file)
...@@ -228,7 +228,7 @@ export class FileDescriptorUtil { ...@@ -228,7 +228,7 @@ export class FileDescriptorUtil {
case 'ax+': //类似于 'a+',但如果路径存在,则失败 case 'ax+': //类似于 'a+',但如果路径存在,则失败
{ {
if (file.exists()) { if (file.exists()) {
throw new Error(`${msgPrefix}${UniErrors[1301005]}`) throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1301005]}`)
} else { } else {
let fd = this.open_ax(file) let fd = this.open_ax(file)
this.openMap.set(fd, file) this.openMap.set(fd, file)
...@@ -238,7 +238,7 @@ export class FileDescriptorUtil { ...@@ -238,7 +238,7 @@ export class FileDescriptorUtil {
case 'r': //打开文件用于读取。 如果文件不存在,则会发生异常 case 'r': //打开文件用于读取。 如果文件不存在,则会发生异常
{ {
if (!file.exists()) { if (!file.exists()) {
throw new Error(`${msgPrefix}${UniErrors[1300002]}`) throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1300002]}`)
} else { } else {
let mode = ParcelFileDescriptor.MODE_READ_ONLY let mode = ParcelFileDescriptor.MODE_READ_ONLY
let pfd = ParcelFileDescriptor.open(file, mode); let pfd = ParcelFileDescriptor.open(file, mode);
...@@ -251,7 +251,7 @@ export class FileDescriptorUtil { ...@@ -251,7 +251,7 @@ export class FileDescriptorUtil {
case 'r+': //打开文件用于读取和写入。 如果文件不存在,则会发生异常 case 'r+': //打开文件用于读取和写入。 如果文件不存在,则会发生异常
{ {
if (!file.exists()) { if (!file.exists()) {
throw new Error(`${msgPrefix}${UniErrors[1300002]}`) throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1300002]}`)
} else { } else {
let mode = ParcelFileDescriptor.MODE_READ_WRITE let mode = ParcelFileDescriptor.MODE_READ_WRITE
let pfd = ParcelFileDescriptor.open(file, mode); let pfd = ParcelFileDescriptor.open(file, mode);
...@@ -270,7 +270,7 @@ export class FileDescriptorUtil { ...@@ -270,7 +270,7 @@ export class FileDescriptorUtil {
case 'wx'://类似于 'w',但如果路径存在,则失败 case 'wx'://类似于 'w',但如果路径存在,则失败
{ {
if (file.exists()) { if (file.exists()) {
throw new Error(`${msgPrefix}${UniErrors[1301005]}`) throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1301005]}`)
} else { } else {
let fd = this.open_w(file) let fd = this.open_w(file)
this.openMap.set(fd, file) this.openMap.set(fd, file)
...@@ -289,7 +289,7 @@ export class FileDescriptorUtil { ...@@ -289,7 +289,7 @@ export class FileDescriptorUtil {
case 'wx+': // 类似于 'w+',但如果路径存在,则失败 case 'wx+': // 类似于 'w+',但如果路径存在,则失败
{ {
if (file.exists()) { if (file.exists()) {
throw new Error(`${msgPrefix}${UniErrors[1301005]}`) throw new Error(`${msgPrefix}${FileSystemManagerUniErrors[1301005]}`)
} else { } else {
let mode = ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_READ_WRITE | ParcelFileDescriptor.MODE_TRUNCATE let mode = ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_READ_WRITE | ParcelFileDescriptor.MODE_TRUNCATE
let pfd = ParcelFileDescriptor.open(file, mode); let pfd = ParcelFileDescriptor.open(file, mode);
......
import { WriteFileOptions, ReadFileOptions, MkDirOptions, RmDirOptions, UnLinkOptions, ReadDirOptions, AccessOptions, RenameOptions, GetFileInfoOptions, CopyFileOptions, StatOptions } from "../interface.uts" 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 { ReadFileSuccessResult, FileManagerSuccessResult, ReadDirSuccessResult, GetFileInfoSuccessResult, StatSuccessResult, FileStats, Stats } from "../interface.uts"
import { GetFileSystemManager, FileSystemManager } from "../interface.uts" import { GetFileSystemManager, FileSystemManager } from "../interface.uts"
import { UniErrorSubject, UniErrors } from "../unierror.uts" import { FileSystemManagerFailImpl, FileSystemManagerUniErrorSubject, FileSystemManagerUniErrors } from "../unierror.uts"
export { Stats,FileStats } from '../interface.uts'
class InnerStats implements Stats { class InnerStats implements Stats {
/** /**
...@@ -93,7 +92,7 @@ class JsFileSystemManager implements FileSystemManager { ...@@ -93,7 +92,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret) options.complete?.(ret)
}, },
function (code) { function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.path); let err = new FileSystemManagerFailImpl(code)
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
}) })
...@@ -103,7 +102,7 @@ class JsFileSystemManager implements FileSystemManager { ...@@ -103,7 +102,7 @@ class JsFileSystemManager implements FileSystemManager {
if(options.digestAlgorithm == null || options.digestAlgorithm == undefined){ if(options.digestAlgorithm == null || options.digestAlgorithm == undefined){
options.digestAlgorithm = "md5" options.digestAlgorithm = "md5"
} else if (options.digestAlgorithm!.toLowerCase() != 'md5' && options.digestAlgorithm!.toLowerCase() != 'sha1') { } else if (options.digestAlgorithm!.toLowerCase() != 'md5' && options.digestAlgorithm!.toLowerCase() != 'sha1') {
let err = new UniError(UniErrorSubject, 1300022, UniErrors.get(1300022)! + ":invalid digestAlgorithm " + options.digestAlgorithm); let err = new FileSystemManagerFailImpl(1300022);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
return return
...@@ -117,7 +116,7 @@ class JsFileSystemManager implements FileSystemManager { ...@@ -117,7 +116,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret) options.complete?.(ret)
}, },
function (code) { function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.filePath); let err = new FileSystemManagerFailImpl(code);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
}) })
...@@ -136,7 +135,7 @@ class JsFileSystemManager implements FileSystemManager { ...@@ -136,7 +135,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret) options.complete?.(ret)
}, },
function (code) { function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)!); let err = new FileSystemManagerFailImpl(code);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
}) })
...@@ -155,7 +154,7 @@ class JsFileSystemManager implements FileSystemManager { ...@@ -155,7 +154,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret) options.complete?.(ret)
}, },
function (code) { function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)!); let err = new FileSystemManagerFailImpl(code);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
}) })
...@@ -173,7 +172,7 @@ class JsFileSystemManager implements FileSystemManager { ...@@ -173,7 +172,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret) options.complete?.(ret)
}, },
function (code) { function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.path); let err = new FileSystemManagerFailImpl(code);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
}) })
...@@ -191,7 +190,7 @@ class JsFileSystemManager implements FileSystemManager { ...@@ -191,7 +190,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret) options.complete?.(ret)
}, },
function (code) { function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.dirPath); let err = new FileSystemManagerFailImpl(code);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
}) })
...@@ -214,7 +213,7 @@ class JsFileSystemManager implements FileSystemManager { ...@@ -214,7 +213,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret) options.complete?.(ret)
}, },
function (code) { function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.dirPath); let err = new FileSystemManagerFailImpl(code);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
}) })
...@@ -229,7 +228,7 @@ class JsFileSystemManager implements FileSystemManager { ...@@ -229,7 +228,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret) options.complete?.(ret)
}, },
function (code) { function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.dirPath); let err = new FileSystemManagerFailImpl(code);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
}) })
...@@ -248,7 +247,7 @@ class JsFileSystemManager implements FileSystemManager { ...@@ -248,7 +247,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret) options.complete?.(ret)
}, },
function (code) { function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.filePath); let err = new FileSystemManagerFailImpl(code);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
}) })
...@@ -266,7 +265,7 @@ class JsFileSystemManager implements FileSystemManager { ...@@ -266,7 +265,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret) options.complete?.(ret)
}, },
function (code) { function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.filePath); let err = new FileSystemManagerFailImpl(code);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
}) })
...@@ -286,7 +285,7 @@ class JsFileSystemManager implements FileSystemManager { ...@@ -286,7 +285,7 @@ class JsFileSystemManager implements FileSystemManager {
options.complete?.(ret) options.complete?.(ret)
}, },
function (code) { function (code) {
let err = new UniError(UniErrorSubject, code, UniErrors.get(code)! + ":" + options.filePath); let err = new FileSystemManagerFailImpl(code);
options.fail?.(err) options.fail?.(err)
options.complete?.(err) options.complete?.(err)
}) })
......
...@@ -21,7 +21,7 @@ export type FileManagerSuccessCallback = (res : FileManagerSuccessResult) => voi ...@@ -21,7 +21,7 @@ export type FileManagerSuccessCallback = (res : FileManagerSuccessResult) => voi
/** /**
* 通用的错误返回结果回调 * 通用的错误返回结果回调
*/ */
export type FileManagerFailCallback = (res : UniError) => void export type FileManagerFailCallback = (res : FileSystemManagerFail) => void
/** /**
* 通用的结束返回结果回调 * 通用的结束返回结果回调
*/ */
...@@ -39,7 +39,7 @@ export type ReadFileOptions = { ...@@ -39,7 +39,7 @@ export type ReadFileOptions = {
*/ */
encoding : "base64" | "utf-8", encoding : "base64" | "utf-8",
/** /**
* 文件路径,支持相对地址和绝对地址 * 文件路径,支持相对地址和绝对地址,app-android平台支持代码包文件目录
*/ */
filePath : string.URIString, filePath : string.URIString,
/** /**
...@@ -553,7 +553,7 @@ export type ReadCompressedFileResult = { ...@@ -553,7 +553,7 @@ export type ReadCompressedFileResult = {
export type ReadCompressedFileCallback = (res : ReadCompressedFileResult) => void export type ReadCompressedFileCallback = (res : ReadCompressedFileResult) => void
export type ReadCompressedFileOptions = { export type ReadCompressedFileOptions = {
/** /**
* 要读取的文件的路径 (本地用户文件或代码包文件) * 要读取的文件的路径 (本地用户文件或代码包文件),app-android平台支持代码包文件目录
*/ */
filePath : string.URIString, filePath : string.URIString,
/** /**
...@@ -779,7 +779,7 @@ export type ZipFileItem = { ...@@ -779,7 +779,7 @@ export type ZipFileItem = {
export type ReadZipEntryCallback = (res : EntriesResult) => void export type ReadZipEntryCallback = (res : EntriesResult) => void
export type ReadZipEntryOptions = { export type ReadZipEntryOptions = {
/** /**
* 要读取的压缩包的路径 (本地路径) * 要读取的压缩包的路径 (本地路径),app-android平台支持代码包文件目录
*/ */
filePath : string.URIString, filePath : string.URIString,
/** /**
...@@ -829,6 +829,8 @@ export interface FileSystemManager { ...@@ -829,6 +829,8 @@ export interface FileSystemManager {
readFile(options : ReadFileOptions) : void; readFile(options : ReadFileOptions) : void;
/** /**
* FileSystemManager.readFile 的同步版本参数 * FileSystemManager.readFile 的同步版本参数
* @param filePath 文件路径,支持相对地址和绝对地址,app-android平台支持代码包文件目录
* @param encoding base64 / utf-8
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
...@@ -873,6 +875,9 @@ export interface FileSystemManager { ...@@ -873,6 +875,9 @@ export interface FileSystemManager {
writeFile(options : WriteFileOptions) : void; writeFile(options : WriteFileOptions) : void;
/** /**
* FileSystemManager.writeFile 的同步版本 * FileSystemManager.writeFile 的同步版本
* @param filePath 文件路径,只支持绝对地址
* @param data 写入的文本内容
* @param encoding 指定写入文件的字符编码,支持:ascii base64 utf-8
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
...@@ -917,6 +922,7 @@ export interface FileSystemManager { ...@@ -917,6 +922,7 @@ export interface FileSystemManager {
unlink(options : UnLinkOptions) : void; unlink(options : UnLinkOptions) : void;
/** /**
* FileSystemManager.unlink 的同步版本 * FileSystemManager.unlink 的同步版本
* @param filePath 文件路径,只支持绝对地址
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
...@@ -961,6 +967,8 @@ export interface FileSystemManager { ...@@ -961,6 +967,8 @@ export interface FileSystemManager {
mkdir(options : MkDirOptions) : void; mkdir(options : MkDirOptions) : void;
/** /**
* FileSystemManager.mkdir 的同步版本 * FileSystemManager.mkdir 的同步版本
* @param dirPath 创建的目录路径 (本地路径)
* @param recursive 是否在递归创建该目录的上级目录后再创建该目录。如果对应的上级目录已经存在,则不创建该上级目录。如 dirPath 为 a/b/c/d 且 recursive 为 true,将创建 a 目录,再在 a 目录下创建 b 目录,以此类推直至创建 a/b/c 目录下的 d 目录。
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
...@@ -1005,6 +1013,8 @@ export interface FileSystemManager { ...@@ -1005,6 +1013,8 @@ export interface FileSystemManager {
rmdir(options : RmDirOptions) : void; rmdir(options : RmDirOptions) : void;
/** /**
* FileSystemManager.rmdir 的同步版本 * FileSystemManager.rmdir 的同步版本
* @param dirPath 要删除的目录路径 (本地路径)
* @param recursive 是否递归删除目录。如果为 true,则删除该目录和该目录下的所有子目录以及文件。
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
...@@ -1049,6 +1059,7 @@ export interface FileSystemManager { ...@@ -1049,6 +1059,7 @@ export interface FileSystemManager {
readdir(options : ReadDirOptions) : void; readdir(options : ReadDirOptions) : void;
/** /**
* FileSystemManager.readdir 的同步版本 * FileSystemManager.readdir 的同步版本
* @param dirPath 要读取的目录路径 (本地路径)
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
...@@ -1093,6 +1104,7 @@ export interface FileSystemManager { ...@@ -1093,6 +1104,7 @@ export interface FileSystemManager {
access(options : AccessOptions) : void; access(options : AccessOptions) : void;
/** /**
* FileSystemManager.access 的同步版本 * FileSystemManager.access 的同步版本
* @param path 要删除的目录路径 (本地路径)
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
...@@ -1137,6 +1149,8 @@ export interface FileSystemManager { ...@@ -1137,6 +1149,8 @@ export interface FileSystemManager {
rename(options : RenameOptions) : void; rename(options : RenameOptions) : void;
/** /**
* FileSystemManager.rename 的同步版本 * FileSystemManager.rename 的同步版本
* @param oldPath 源文件路径,支持本地路径
* @param newPath 新文件路径,支持本地路径
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
...@@ -1181,6 +1195,8 @@ export interface FileSystemManager { ...@@ -1181,6 +1195,8 @@ export interface FileSystemManager {
copyFile(options : CopyFileOptions) : void; copyFile(options : CopyFileOptions) : void;
/** /**
* FileSystemManager.copyFile 的同步版本 * FileSystemManager.copyFile 的同步版本
* @param srcPath 源文件路径,支持本地路径
* @param destPath 新文件路径,支持本地路径
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
...@@ -1247,6 +1263,8 @@ export interface FileSystemManager { ...@@ -1247,6 +1263,8 @@ export interface FileSystemManager {
stat(options : StatOptions) : void; stat(options : StatOptions) : void;
/** /**
* FileSystemManager.stat 的同步版本 * FileSystemManager.stat 的同步版本
* @param path 文件/目录路径 (本地路径)
* @param recursive 是否递归获取目录下的每个文件的 Stats 信息
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
...@@ -1291,6 +1309,9 @@ export interface FileSystemManager { ...@@ -1291,6 +1309,9 @@ export interface FileSystemManager {
appendFile(options : AppendFileOptions) : void; appendFile(options : AppendFileOptions) : void;
/** /**
* FileSystemManager.appendFile 的同步版本 * FileSystemManager.appendFile 的同步版本
* @param filePath 要追加内容的文件路径 (本地路径)
* @param data 要追加的文本
* @param encoding 指定写入文件的字符编码支持:ascii base64 utf-8
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
...@@ -1335,6 +1356,8 @@ export interface FileSystemManager { ...@@ -1335,6 +1356,8 @@ export interface FileSystemManager {
saveFile(options : SaveFileOptions) : void; saveFile(options : SaveFileOptions) : void;
/** /**
* FileSystemManager.saveFile 的同步版本 * FileSystemManager.saveFile 的同步版本
* @param tempFilePath 临时存储文件路径 (本地路径)
* @param filePath 要存储的文件路径 (本地路径)
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
...@@ -1445,6 +1468,8 @@ export interface FileSystemManager { ...@@ -1445,6 +1468,8 @@ export interface FileSystemManager {
truncate(options : TruncateFileOptions) : void; truncate(options : TruncateFileOptions) : void;
/** /**
* 对文件内容进行截断操作 (truncate 的同步版本) * 对文件内容进行截断操作 (truncate 的同步版本)
* @param filePath 要截断的文件路径 (本地路径)
* @param length 截断位置,默认0。如果 length 小于文件长度(字节),则只有前面 length 个字节会保留在文件中,其余内容会被删除;如果 length 大于文件长度,不做处理
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
...@@ -1489,6 +1514,8 @@ export interface FileSystemManager { ...@@ -1489,6 +1514,8 @@ export interface FileSystemManager {
readCompressedFile(options : ReadCompressedFileOptions) : void; readCompressedFile(options : ReadCompressedFileOptions) : void;
/** /**
* 同步读取指定压缩类型的本地文件内容 * 同步读取指定压缩类型的本地文件内容
* @param filePath 要读取的文件的路径 (本地用户文件或代码包文件),app-android平台支持代码包文件目录
* @param compressionAlgorithm 文件压缩类型,目前仅支持 'br'。
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
...@@ -1618,7 +1645,7 @@ export interface FileSystemManager { ...@@ -1618,7 +1645,7 @@ export interface FileSystemManager {
* } * }
* } * }
*/ */
close(options : CloseOptions); close(options : CloseOptions) : void;
/** /**
* 同步关闭文件 * 同步关闭文件
* @uniPlatform { * @uniPlatform {
...@@ -1781,4 +1808,26 @@ export interface Uni { ...@@ -1781,4 +1808,26 @@ export interface Uni {
* @uniVueVersion 2,3 //支持的vue版本 * @uniVueVersion 2,3 //支持的vue版本
*/ */
getFileSystemManager() : FileSystemManager getFileSystemManager() : FileSystemManager
} }
\ No newline at end of file
/**
* 错误码
* - 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
};
import { FileSystemManagerErrorCode,IFileSystemManagerFail } from "./interface.uts"
/** /**
* 错误主题 * 错误主题
*/ */
export const UniErrorSubject = 'uni-fileSystemManager'; export const FileSystemManagerUniErrorSubject = 'uni-fileSystemManager';
/** /**
* 错误码 * 错误码
* @UniError * @UniError
*/ */
export const UniErrors : Map<number, string> = new Map([ export const FileSystemManagerUniErrors : Map<FileSystemManagerErrorCode, string> = new Map([
[1200002, 'type error. only support base64 / utf-8'], [1200002, 'type error. only support base64 / utf-8'],
[1300002, 'no such file or directory'], [1300002, 'no such file or directory'],
...@@ -22,4 +24,12 @@ export const UniErrors : Map<number, string> = new Map([ ...@@ -22,4 +24,12 @@ export const UniErrors : Map<number, string> = new Map([
[1301111, 'brotli decompress fail'], [1301111, 'brotli decompress fail'],
[1302003, 'invalid flag'], [1302003, 'invalid flag'],
[1300009, 'bad file descriptor'] [1300009, 'bad file descriptor']
]); ]);
\ No newline at end of file export class FileSystemManagerFailImpl extends UniError implements IFileSystemManagerFail {
constructor(errCode : FileSystemManagerErrorCode) {
super();
this.errSubject = FileSystemManagerUniErrorSubject;
this.errCode = errCode;
this.errMsg = FileSystemManagerUniErrors.get(errCode) ?? "";
}
}
\ No newline at end of file
...@@ -41,7 +41,8 @@ export type GetAppAuthorizeSettingResult = { ...@@ -41,7 +41,8 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权 * - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限) * - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关) * - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* @type 'authorized' | 'denied' | 'not determined' * - config error: 当前应用没有配置相册权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform * @uniPlatform
* { * {
* "app": { * "app": {
...@@ -58,13 +59,13 @@ export type GetAppAuthorizeSettingResult = { ...@@ -58,13 +59,13 @@ export type GetAppAuthorizeSettingResult = {
* } * }
* } * }
*/ */
albumAuthorized?: 'authorized' | 'denied' | 'not determined' | null, albumAuthorized?: 'authorized' | 'denied' | 'not determined' | 'config error' | null,
/** /**
* 允许 App 使用蓝牙的开关(仅 iOS 支持) * 允许 App 使用蓝牙的开关(仅 iOS 支持)
* - authorized: 已经获得授权,无需再次请求授权 * - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限) * - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关) * - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: Android平台没有该值;iOS平台:表示没有在 `manifest.json -> App模块配置` 中配置 `BlueTooth(低功耗蓝牙)` 模块 * - config error: Android平台没有该值;iOS平台:当前应用没有配置蓝牙权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error' * @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform * @uniPlatform
* { * {
...@@ -88,7 +89,7 @@ export type GetAppAuthorizeSettingResult = { ...@@ -88,7 +89,7 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权 * - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限) * - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关) * - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: Android平台:表示没有配置 `android.permission.CAMERA` 权限,[权限配置详情](https://uniapp.dcloud.net.cn/tutorial/app-nativeresource-android.html#permissions);iOS平台没有该值 * - config error: Android平台:表示没有配置 `android.permission.CAMERA` 权限,[权限配置详情](https://uniapp.dcloud.net.cn/tutorial/app-nativeresource-android.html#permissions);iOS平台:当前应用没有配置相机权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error' * @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform * @uniPlatform
* { * {
...@@ -112,7 +113,7 @@ export type GetAppAuthorizeSettingResult = { ...@@ -112,7 +113,7 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权 * - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限) * - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关) * - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: Android平台:表示没有配置 `android.permission.ACCESS_COARSE_LOCATION` 权限,[权限配置详情](https://uniapp.dcloud.net.cn/tutorial/app-nativeresource-android.html#permissions);iOS平台:表示没有在 `manifest.json -> App模块配置` 中配置 `Geolocation(定位)` 模块 * - config error: Android平台:表示没有配置 `android.permission.ACCESS_COARSE_LOCATION` 权限,[权限配置详情](https://uniapp.dcloud.net.cn/tutorial/app-nativeresource-android.html#permissions);iOS平台:当前应用没有配置定位权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error' * @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform * @uniPlatform
* { * {
...@@ -135,7 +136,7 @@ export type GetAppAuthorizeSettingResult = { ...@@ -135,7 +136,7 @@ export type GetAppAuthorizeSettingResult = {
* 定位准确度。 * 定位准确度。
* - reduced: 模糊定位 * - reduced: 模糊定位
* - full: 精准定位 * - full: 精准定位
* - unsupported: 不支持(包括用户拒绝定位权限和没有在 `manifest.json -> App模块配置` 中配置 `Geolocation(定位)` 模块 * - unsupported: 不支持(包括用户拒绝定位权限和没有包含定位权限描述
* @type 'reduced' | 'full' | 'unsupported' * @type 'reduced' | 'full' | 'unsupported'
* @uniPlatform * @uniPlatform
* { * {
...@@ -179,7 +180,7 @@ export type GetAppAuthorizeSettingResult = { ...@@ -179,7 +180,7 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权 * - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限) * - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关) * - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: Android平台:表示没有配置 `android.permission.RECORD_AUDIO` 权限,[权限配置详情](https://uniapp.dcloud.net.cn/tutorial/app-nativeresource-android.html#permissions);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' * @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform * @uniPlatform
* { * {
...@@ -203,7 +204,7 @@ export type GetAppAuthorizeSettingResult = { ...@@ -203,7 +204,7 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权 * - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限) * - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关) * - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: Android平台没有该值;iOS平台:表示没有在 `manifest.json -> App模块配置` 中配置 `Push(推送)` 模块 * - config error: Android平台没有该值;iOS平台:没有包含推送权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error' * @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform * @uniPlatform
* { * {
...@@ -227,7 +228,7 @@ export type GetAppAuthorizeSettingResult = { ...@@ -227,7 +228,7 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权 * - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限) * - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关) * - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: 没有在 `manifest.json -> App模块配置` 中配置 `Push(推送)` 模块 * - config error: 当前应用没有配置推送权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error' * @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform * @uniPlatform
* { * {
...@@ -251,7 +252,7 @@ export type GetAppAuthorizeSettingResult = { ...@@ -251,7 +252,7 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权 * - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限) * - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关) * - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: 没有在 `manifest.json -> App模块配置` 中配置 `Push(推送)` 模块 * - config error: 当前应用没有配置推送权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error' * @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform * @uniPlatform
* { * {
...@@ -275,7 +276,7 @@ export type GetAppAuthorizeSettingResult = { ...@@ -275,7 +276,7 @@ export type GetAppAuthorizeSettingResult = {
* - authorized: 已经获得授权,无需再次请求授权 * - authorized: 已经获得授权,无需再次请求授权
* - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限) * - denied: 请求授权被拒绝,无法再次请求授权;(此情况需要引导用户打开系统设置,在设置页中打开权限)
* - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关) * - not determined: 尚未请求授权,会在App下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关)
* - config error: 没有在 `manifest.json -> App模块配置` 中配置 `Push(推送)` 模块 * - config error: 当前应用没有配置推送权限描述
* @type 'authorized' | 'denied' | 'not determined' | 'config error' * @type 'authorized' | 'denied' | 'not determined' | 'config error'
* @uniPlatform * @uniPlatform
* { * {
......
...@@ -39,7 +39,8 @@ export const getAppBaseInfo : GetAppBaseInfo = (config : GetAppBaseInfoOptions | ...@@ -39,7 +39,8 @@ export const getAppBaseInfo : GetAppBaseInfo = (config : GetAppBaseInfoOptions |
"uniCompilerVersionCode", "uniCompilerVersionCode",
"uniRuntimeVersionCode", "uniRuntimeVersionCode",
"packageName", "packageName",
"signature" "signature",
"appTheme",
]; ];
filter = defaultFilter; filter = defaultFilter;
} }
...@@ -134,6 +135,10 @@ function getBaseInfo(filterArray : Array<string>) : GetAppBaseInfoResult { ...@@ -134,6 +135,10 @@ function getBaseInfo(filterArray : Array<string>) : GetAppBaseInfoResult {
if (filterArray.indexOf("signature") != -1) { if (filterArray.indexOf("signature") != -1) {
result.signature = AppBaseInfoDeviceUtil.getAppSignatureSHA1(activity); result.signature = AppBaseInfoDeviceUtil.getAppSignatureSHA1(activity);
}
if (filterArray.indexOf("appTheme") != -1) {
result.appTheme = UTSAndroid.getAppTheme();
} }
return result; return result;
......
...@@ -35,7 +35,8 @@ export const getAppBaseInfo : GetAppBaseInfo = (config : GetAppBaseInfoOptions | ...@@ -35,7 +35,8 @@ export const getAppBaseInfo : GetAppBaseInfo = (config : GetAppBaseInfoOptions |
"uniPlatform", "uniPlatform",
"uniRuntimeVersion", "uniRuntimeVersion",
"uniCompilerVersionCode", "uniCompilerVersionCode",
"uniRuntimeVersionCode" "uniRuntimeVersionCode",
"appTheme",
]; ];
filter = defaultFilter; filter = defaultFilter;
} }
...@@ -115,6 +116,10 @@ function getBaseInfo(filterArray : Array<string>) : GetAppBaseInfoResult { ...@@ -115,6 +116,10 @@ function getBaseInfo(filterArray : Array<string>) : GetAppBaseInfoResult {
if (filterArray.indexOf("uniRuntimeVersionCode") != -1) { if (filterArray.indexOf("uniRuntimeVersionCode") != -1) {
result.uniRuntimeVersionCode = AppBaseInfoConvertVersionCode(UTSiOS.getRuntimeVersion()); result.uniRuntimeVersionCode = AppBaseInfoConvertVersionCode(UTSiOS.getRuntimeVersion());
}
if (filterArray.indexOf("appTheme") != -1) {
result.appTheme = UTSiOS.getAppTheme();
} }
return result; return result;
......
...@@ -22,7 +22,11 @@ export type GetAppBaseInfoResult = { ...@@ -22,7 +22,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "unixVer": "4.11"
* } * }
* } * },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* } * }
*/ */
appId?: string, appId?: string,
...@@ -42,7 +46,11 @@ export type GetAppBaseInfoResult = { ...@@ -42,7 +46,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "unixVer": "4.11"
* } * }
* } * },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* } * }
*/ */
appName?: string, appName?: string,
...@@ -62,7 +70,11 @@ export type GetAppBaseInfoResult = { ...@@ -62,7 +70,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "unixVer": "4.11"
* } * }
* } * },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* } * }
*/ */
appVersion?: string, appVersion?: string,
...@@ -82,7 +94,11 @@ export type GetAppBaseInfoResult = { ...@@ -82,7 +94,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "unixVer": "4.11"
* } * }
* } * },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* } * }
*/ */
appVersionCode?: string, appVersionCode?: string,
...@@ -102,7 +118,11 @@ export type GetAppBaseInfoResult = { ...@@ -102,7 +118,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "unixVer": "4.11"
* } * }
* } * },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* } * }
*/ */
appLanguage?: string, appLanguage?: string,
...@@ -122,7 +142,11 @@ export type GetAppBaseInfoResult = { ...@@ -122,7 +142,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "unixVer": "4.11"
* } * }
* } * },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* } * }
*/ */
language?: string, language?: string,
...@@ -143,7 +167,11 @@ export type GetAppBaseInfoResult = { ...@@ -143,7 +167,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "unixVer": "4.11"
* } * }
* } * },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* } * }
*/ */
version?: string, version?: string,
...@@ -331,7 +359,11 @@ export type GetAppBaseInfoResult = { ...@@ -331,7 +359,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "unixVer": "4.11"
* } * }
* } * },
* "web": {
* "uniVer": "x",
* "unixVer": "4.18"
* }
* } * }
*/ */
isUniAppX ?: boolean, isUniAppX ?: boolean,
...@@ -353,7 +385,11 @@ export type GetAppBaseInfoResult = { ...@@ -353,7 +385,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "unixVer": "4.11"
* } * }
* } * },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* } * }
*/ */
uniCompileVersion ?: string, uniCompileVersion ?: string,
...@@ -375,8 +411,8 @@ export type GetAppBaseInfoResult = { ...@@ -375,8 +411,8 @@ export type GetAppBaseInfoResult = {
* } * }
* }, * },
* "web": { * "web": {
* "uniVer": "", * "uniVer": "x",
* "unixVer": "4.0" * "unixVer": "4.18"
* } * }
* } * }
*/ */
...@@ -397,7 +433,11 @@ export type GetAppBaseInfoResult = { ...@@ -397,7 +433,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "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', 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',
...@@ -417,7 +457,11 @@ export type GetAppBaseInfoResult = { ...@@ -417,7 +457,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "unixVer": "4.11"
* } * }
* } * },
* "web": {
* "uniVer": "x",
* "unixVer": "4.18"
* }
* } * }
*/ */
uniRuntimeVersion ?: string, uniRuntimeVersion ?: string,
...@@ -438,7 +482,11 @@ export type GetAppBaseInfoResult = { ...@@ -438,7 +482,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "unixVer": "4.11"
* } * }
* } * },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* } * }
*/ */
uniCompileVersionCode?: number, uniCompileVersionCode?: number,
...@@ -460,8 +508,8 @@ export type GetAppBaseInfoResult = { ...@@ -460,8 +508,8 @@ export type GetAppBaseInfoResult = {
* } * }
* }, * },
* "web": { * "web": {
* "uniVer": "", * "uniVer": "x",
* "unixVer": "4.0" * "unixVer": "4.18"
* } * }
* } * }
*/ */
...@@ -482,7 +530,11 @@ export type GetAppBaseInfoResult = { ...@@ -482,7 +530,11 @@ export type GetAppBaseInfoResult = {
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "unixVer": "4.11"
* } * }
* } * },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* } * }
*/ */
uniRuntimeVersionCode?: number, uniRuntimeVersionCode?: number,
...@@ -559,6 +611,30 @@ export type GetAppBaseInfoResult = { ...@@ -559,6 +611,30 @@ export type GetAppBaseInfoResult = {
* } * }
*/ */
signature?: string, signature?: string,
/**
* 当前App的主题
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
appTheme?: 'light' | 'dark' | 'auto' | null,
} }
/** /**
...@@ -589,10 +665,10 @@ export interface Uni { ...@@ -589,10 +665,10 @@ export interface Uni {
* "unixVer": "4.11" * "unixVer": "4.11"
* } * }
* }, * },
* "web": { * "web": {
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.0" * "unixVer": "4.0"
* } * }
* } * }
* @example * @example
```typescript ```typescript
......
...@@ -215,6 +215,15 @@ export class DeviceUtil { ...@@ -215,6 +215,15 @@ export class DeviceUtil {
public static getOaid(): string { public static getOaid(): string {
return UTSAndroid.getOAID(); return UTSAndroid.getOAID();
} }
public static getRomName():string{
DeviceUtil.setCustomInfo(Build.MANUFACTURER);
return DeviceUtil.customOS ?? "";
}
public static getRomVersion():string{
DeviceUtil.setCustomInfo(Build.MANUFACTURER);
return DeviceUtil.customOSVersion ?? "";
}
/** /**
......
...@@ -89,12 +89,7 @@ function getBaseInfo(filterArray : Array<string>) : GetDeviceInfoResult { ...@@ -89,12 +89,7 @@ function getBaseInfo(filterArray : Array<string>) : GetDeviceInfoResult {
result.osLanguage = UTSiOS.getOsLanguage(); result.osLanguage = UTSiOS.getOsLanguage();
} }
if (filterArray.indexOf("osTheme") != -1) { if (filterArray.indexOf("osTheme") != -1) {
let osTheme = 'light' result.osTheme = UTSiOS.getOsTheme();
if(UTSiOS.available("iOS 13, *")){
let currentTraitCollection = UIApplication.shared.keyWindow?.traitCollection
osTheme = currentTraitCollection?.userInterfaceStyle == UIUserInterfaceStyle.dark ? "dark" : "light"
}
result.osTheme = osTheme;
} }
if (filterArray.indexOf("romName") != -1) { if (filterArray.indexOf("romName") != -1) {
result.romName = "ios" result.romName = "ios"
......
export type GetDeviceInfoOptions = { export type GetDeviceInfoOptions = {
/** /**
* @description 过滤字段的字符串数组,假如要获取指定字段,传入此数组。 * @description 过滤字段的字符串数组,假如要获取指定字段,传入此数组。
*/ */
filter: Array<string> filter: Array<string>
} }
export type GetDeviceInfoResult = { export type GetDeviceInfoResult = {
/** /**
* 设备品牌 * 设备品牌
* @deprecated 已废弃,仅为了向下兼容保留 * @deprecated 已废弃,仅为了向下兼容保留
* *
* @uniPlatform * @uniPlatform
* { * {
* "app": { * "app": {
* "android": { * "android": {
* "osVer": "5.0", * "osVer": "5.0",
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "3.9+" * "unixVer": "3.9+"
* }, * },
* "ios": { * "ios": {
* "osVer": "12.0", * "osVer": "12.0",
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "unixVer": "4.11"
* } * }
* } * },
* } * "web": {
*/ * "uniVer": "x",
brand?: string * "unixVer": "x"
/** * }
* 设备品牌 * }
* */
* @uniPlatform brand?: string
* { /**
* "app": { * 设备品牌
* "android": { *
* "osVer": "5.0", * @uniPlatform
* "uniVer": "√", * {
* "unixVer": "3.9+" * "app": {
* }, * "android": {
* "ios": { * "osVer": "5.0",
* "osVer": "12.0", * "uniVer": "√",
* "uniVer": "√", * "unixVer": "3.9+"
* "unixVer": "4.11" * },
* } * "ios": {
* } * "osVer": "12.0",
* } * "uniVer": "√",
*/ * "unixVer": "4.11"
deviceBrand?: string, * }
/** * },
* 设备 id 。由 uni-app 框架生成并存储,清空 Storage 会导致改变 * "web": {
* * "uniVer": "x",
* @uniPlatform * "unixVer": "x"
* { * }
* "app": { * }
* "android": { */
* "osVer": "5.0", deviceBrand?: string,
* "uniVer": "√", /**
* "unixVer": "3.9+" * 设备 id 。由 uni-app 框架生成并存储,清空 Storage 会导致改变
* }, *
* "ios": { * @uniPlatform
* "osVer": "12.0", * {
* "uniVer": "√", * "app": {
* "unixVer": "4.11" * "android": {
* } * "osVer": "5.0",
* } * "uniVer": "√",
* } * "unixVer": "3.9+"
*/ * },
deviceId?: string, * "ios": {
/** * "osVer": "12.0",
* 设备型号 * "uniVer": "√",
* @deprecated 已废弃,仅为了向下兼容保留 * "unixVer": "4.11"
* * }
* @uniPlatform * },
* { * "web": {
* "app": { * "uniVer": "√",
* "android": { * "unixVer": "4.0"
* "osVer": "5.0", * }
* "uniVer": "√", * }
* "unixVer": "3.9+" */
* }, deviceId?: string,
* "ios": { /**
* "osVer": "12.0", * 设备型号
* "uniVer": "√", * @deprecated 已废弃,仅为了向下兼容保留
* "unixVer": "4.11" *
* } * @uniPlatform
* } * {
* } * "app": {
*/ * "android": {
model?: string, * "osVer": "5.0",
/** * "uniVer": "√",
* 设备型号 * "unixVer": "3.9+"
* * },
* @uniPlatform * "ios": {
* { * "osVer": "12.0",
* "app": { * "uniVer": "√",
* "android": { * "unixVer": "4.11"
* "osVer": "5.0", * }
* "uniVer": "√", * },
* "unixVer": "3.9+" * "web": {
* }, * "uniVer": "√",
* "ios": { * "unixVer": "4.0"
* "osVer": "12.0", * }
* "uniVer": "√", * }
* "unixVer": "4.11" */
* } model?: string,
* } /**
* } * 设备型号
*/ *
deviceModel?: string, * @uniPlatform
/** * {
* 设备类型phone、pad、pc * "app": {
* * "android": {
* @uniPlatform * "osVer": "5.0",
* { * "uniVer": "√",
* "app": { * "unixVer": "3.9+"
* "android": { * },
* "osVer": "5.0", * "ios": {
* "uniVer": "√", * "osVer": "12.0",
* "unixVer": "3.9+" * "uniVer": "√",
* }, * "unixVer": "4.11"
* "ios": { * }
* "osVer": "12.0", * },
* "uniVer": "√", * "web": {
* "unixVer": "4.11" * "uniVer": "√",
* } * "unixVer": "4.0"
* } * }
* } * }
*/ */
deviceType?: string, deviceModel?: string,
/** /**
* 设备方向 竖屏 portrait、横屏 landscape * 设备类型phone、pad、pc
* *
* @uniPlatform * @uniPlatform
* { * {
* "app": { * "app": {
* "android": { * "android": {
* "osVer": "5.0", * "osVer": "5.0",
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "3.9+" * "unixVer": "3.9+"
* }, * },
* "ios": { * "ios": {
* "osVer": "12.0", * "osVer": "12.0",
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "unixVer": "4.11"
* } * }
* } * },
* } * "web": {
*/ * "uniVer": "√",
deviceOrientation?: string, * "unixVer": "4.0"
/** * }
* 设备像素比 * }
* */
* @uniPlatform deviceType?: string,
* { /**
* "app": { * 设备方向 竖屏 portrait、横屏 landscape
* "android": { *
* "osVer": "5.0", * @uniPlatform
* "uniVer": "√", * {
* "unixVer": "3.9+" * "app": {
* }, * "android": {
* "ios": { * "osVer": "5.0",
* "osVer": "12.0", * "uniVer": "√",
* "uniVer": "√", * "unixVer": "3.9+"
* "unixVer": "4.11" * },
* } * "ios": {
* } * "osVer": "12.0",
* } * "uniVer": "√",
*/ * "unixVer": "4.11"
devicePixelRatio?: string, * }
/** * },
* 操作系统及版本 * "web": {
* * "uniVer": "√",
* @uniPlatform * "unixVer": "4.0"
* { * }
* "app": { * }
* "android": { */
* "osVer": "5.0", deviceOrientation?: string,
* "uniVer": "√", /**
* "unixVer": "3.9+" * 设备像素比
* }, *
* "ios": { * @uniPlatform
* "osVer": "12.0", * {
* "uniVer": "√", * "app": {
* "unixVer": "4.11" * "android": {
* } * "osVer": "5.0",
* } * "uniVer": "√",
* } * "unixVer": "3.9+"
*/ * },
system?: string, * "ios": {
/** * "osVer": "12.0",
* 客户端平台 * "uniVer": "√",
* * "unixVer": "4.11"
* @uniPlatform * }
* { * },
* "app": { * "web": {
* "android": { * "uniVer": "√",
* "osVer": "5.0", * "unixVer": "4.0"
* "uniVer": "√", * }
* "unixVer": "3.9+" * }
* }, */
* "ios": { devicePixelRatio?: string,
* "osVer": "12.0", /**
* "uniVer": "√", * 操作系统及版本
* "unixVer": "4.11" *
* } * @uniPlatform
* } * {
* } * "app": {
*/ * "android": {
platform?: string, * "osVer": "5.0",
/** * "uniVer": "√",
* 是否root * "unixVer": "3.9+"
* * },
* @uniPlatform * "ios": {
* { * "osVer": "12.0",
* "app": { * "uniVer": "√",
* "android": { * "unixVer": "4.11"
* "osVer": "5.0", * }
* "uniVer": "x", * },
* "unixVer": "3.9+" * "web": {
* }, * "uniVer": "√",
* "ios": { * "unixVer": "4.0"
* "osVer": "12.0", * }
* "uniVer": "x", * }
* "unixVer": "4.11" */
* } system?: string,
* } /**
* } * 客户端平台
*/ *
isRoot?: boolean, * @uniPlatform
/** * {
* 是否是模拟器 * "app": {
* * "android": {
* @uniPlatform * "osVer": "5.0",
* { * "uniVer": "√",
* "app": { * "unixVer": "3.9+"
* "android": { * },
* "osVer": "5.0", * "ios": {
* "uniVer": "x", * "osVer": "12.0",
* "unixVer": "3.9+" * "uniVer": "√",
* }, * "unixVer": "4.11"
* "ios": { * }
* "osVer": "12.0", * },
* "uniVer": "x", * "web": {
* "unixVer": "4.11" * "uniVer": "√",
* } * "unixVer": "4.0"
* } * }
* } * }
*/ */
isSimulator?: boolean, platform?: string,
/** /**
* adb是否开启 * 是否root。iOS 为是否越狱
* *
* @uniPlatform * @uniPlatform
* { * {
* "app": { * "app": {
* "android": { * "android": {
* "osVer": "5.0", * "osVer": "5.0",
* "uniVer": "x", * "uniVer": "x",
* "unixVer": "√" * "unixVer": "3.9+"
* }, * },
* "ios": { * "ios": {
* "osVer": "x", * "osVer": "12.0",
* "uniVer": "x", * "uniVer": "x",
* "unixVer": "x" * "unixVer": "4.11"
* } * }
* } * },
* } * "web": {
*/ * "uniVer": "x",
isUSBDebugging?: boolean, * "unixVer": "x"
} * }
* }
*/
/** isRoot?: boolean,
* @param [options=包含所有字段的过滤对象] 过滤的字段对象, 不传参数默认为获取全部字段。 /**
*/ * 是否是模拟器
export type GetDeviceInfo = (options?: GetDeviceInfoOptions | null) => GetDeviceInfoResult; *
* @uniPlatform
* {
export interface Uni { * "app": {
/** * "android": {
* GetDeviceInfo(Object object) * "osVer": "5.0",
* @description * "uniVer": "x",
* 获取设备信息 * "unixVer": "3.9+"
* @param {GetDeviceInfoOptions} options [options=包含所有字段的过滤对象] 过滤的字段对象, 不传参数默认为获取全部字段。 * },
* @return {object} * "ios": {
* @tutorial https://uniapp.dcloud.net.cn/api/system/getDeviceInfo.html * "osVer": "12.0",
* @uniPlatform * "uniVer": "x",
* { * "unixVer": "4.11"
* "app": { * }
* "android": { * },
* "osVer": "5.0", * "web": {
* "uniVer": "√", * "uniVer": "x",
* "unixVer": "3.9+" * "unixVer": "x"
* }, * }
* "ios": { * }
* "osVer": "12.0", */
* "uniVer": "√", isSimulator?: boolean,
* "unixVer": "4.11" /**
* } * adb是否开启
* }, *
* "web": { * @uniPlatform
* "uniVer": "√", * {
* "unixVer": "4.0" * "app": {
* } * "android": {
* } * "osVer": "5.0",
* @example * "uniVer": "x",
```typescript * "unixVer": "√"
uni.getDeviceInfo({ * },
filter:[] * "ios": {
}) * "osVer": "x",
``` * "uniVer": "x",
*/ * "unixVer": "x"
getDeviceInfo(options?: GetDeviceInfoOptions | null): GetDeviceInfoResult; * }
} * },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
isUSBDebugging?: boolean,
/**
* 系统名称
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "4.18"
* }
* }
*/
osName?: 'ios' | 'android' | 'macos' | 'windows' | 'linux' | null,
/**
* 操作系统版本。如 ios 版本,andriod 版本
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "4.18"
* }
* }
*/
osVersion?: string | null,
/**
* 操作系统语言
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
osLanguage?: string | null,
/**
* 操作系统主题
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
osTheme?: 'light' | 'dark' | null,
/**
* Android 系统API库的版本。
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
osAndroidAPILevel?: number | null,
/**
* rom 名称。Android 部分机型获取不到值。iOS 恒为 `ios`
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
romName?: string | null,
/**
* rom 版本号。Android 部分机型获取不到值。iOS 为操作系统版本号(同 `osVersion`)。
*
* @uniPlatform
* {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "4.18"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
romVersion?: string | null,
}
/**
* @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;
}
\ No newline at end of file
...@@ -112,7 +112,7 @@ export type GetLocationOptions = { ...@@ -112,7 +112,7 @@ export type GetLocationOptions = {
* 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于uni.openLocation的坐标,web端需配置定位 SDK 信息才可支持 gcj02 * 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于uni.openLocation的坐标,web端需配置定位 SDK 信息才可支持 gcj02
* @defaultValue wgs84 * @defaultValue wgs84
*/ */
type?: "wgs84" | "gcj02" | "gps" | null, type?: "wgs84" | "gcj02" | null,
/** /**
* 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度 * 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度
* @type boolean * @type boolean
......
...@@ -131,12 +131,12 @@ export interface Uni { ...@@ -131,12 +131,12 @@ export interface Uni {
* "app": { * "app": {
* "android": { * "android": {
* "osVer": "5.0", * "osVer": "5.0",
* "uniVer": "", * "uniVer": "x",
* "unixVer": "3.91" * "unixVer": "3.91"
* }, * },
* "ios": { * "ios": {
* "osVer": "10.0", * "osVer": "12.0",
* "uniVer": "", * "uniVer": "x",
* "unixVer": "x" * "unixVer": "x"
* } * }
* }, * },
...@@ -153,5 +153,5 @@ export interface Uni { ...@@ -153,5 +153,5 @@ export interface Uni {
* } * }
* } * }
*/ */
getPerformance: Performance getPerformance: GetPerformance
} }
...@@ -9,13 +9,16 @@ export const getProvider : GetProvider = (options: GetProviderOptions) : void => ...@@ -9,13 +9,16 @@ export const getProvider : GetProvider = (options: GetProviderOptions) : void =>
options.fail?.(uniError); options.fail?.(uniError);
} }
} else { } else {
const provider = UTSAndroid.getExtApiProviders(options.service) const providers = UTSAndroid.getProviders(options.service)
// TODO // TODO
// const providers: any[] = [] // const providers: any[] = []
if (options.success != null) { if (options.success != null) {
const result = { const result = {
service: options.service, service: options.service,
provider, provider: providers.map((provider): string => {
return provider.id
}),
providers,
errMsg: 'GetProvider:ok' errMsg: 'GetProvider:ok'
} as GetProviderSuccess; } as GetProviderSuccess;
options.success?.(result); options.success?.(result);
......
export type GetProviderSuccess = { export type GetProviderSuccess = {
/** /**
* 服务类型 * 服务类型
* - oauth: 授权登录 * - payment: 支付
* - share: 分享 * @type 'payment'
* - payment: 支付 */
* - push: 推送 service : 'payment',
* - location: 定位 /**
* @type 'oauth' | 'share' | 'payment' | 'push' | 'location' * 得到的服务供应商
*/ * @type PlusShareShareService['id'][] | PlusPushClientInfo['id'][] | PlusOauthAuthService['id'][] | PlusPaymentPaymentChannel['id'][]
service: 'oauth' | 'share' | 'payment' | 'push' | 'location', */
/** provider : string[],
* 得到的服务供应商 /**
* @type PlusShareShareService['id'][] | PlusPushClientInfo['id'][] | PlusOauthAuthService['id'][] | PlusPaymentPaymentChannel['id'][] * 得到的服务供应商服务对象
*/ * @uniPlatform {
provider: string[], * "app": {
/** * "android": {
* 描述信息 * "osVer": "5.0",
*/ * "uniVer": "√",
errMsg: string * "unixVer": "4.18"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "√",
* "unixVer": "4.18"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
*/
providers : UniProvider[],
/**
* 错误信息
*/
errMsg : string
}; };
export type GetProviderSuccessCallback = (result: GetProviderSuccess) => void; export type GetProviderSuccessCallback = (result : GetProviderSuccess) => void;
export type GetProviderFail = UniError; export type GetProviderFail = UniError;
export type GetProviderFailCallback = (result: GetProviderFail) => void; export type GetProviderFailCallback = (result : GetProviderFail) => void;
export type GetProviderComplete = any; export type GetProviderComplete = any;
export type GetProviderCompleteCallback = (result: GetProviderComplete) => void; export type GetProviderCompleteCallback = (result : GetProviderComplete) => void;
export type GetProviderOptions = { export type GetProviderOptions = {
/** /**
* 服务类型,可取值“oauth”、“share”、“payment”、“push”、“location” * 服务类型,可取值“payment”
* - oauth: 授权登录 * - payment: 支付 (Alipay、Wxpay)
* - share: 分享 * @type 'payment'
* - payment: 支付 */
* - push: 推送 service : 'payment',
* - location: 定位 /**
* @type 'oauth' | 'share' | 'payment' | 'push' | 'location' * 接口调用成功的回调
*/ */
service: 'oauth' | 'share' | 'payment' | 'push' | 'location', success ?: GetProviderSuccessCallback | null,
/** /**
* 接口调用成功的回调 * 接口调用失败的回调函数
*/ */
success?: GetProviderSuccessCallback | null, fail ?: GetProviderFailCallback | null,
/** /**
* 接口调用失败的回调函数 * 接口调用结束的回调函数(调用成功、失败都会执行)
*/ */
fail?: GetProviderFailCallback | null, complete ?: GetProviderCompleteCallback | null
/**
* 接口调用结束的回调函数(调用成功、失败都会执行)
*/
complete?: GetProviderCompleteCallback | null
}; };
export type GetProvider = (options: GetProviderOptions) => void; export type GetProvider = (options : GetProviderOptions) => void;
export interface Uni { export interface Uni {
/** /**
* 获取服务供应商 * 获取服务供应商
* @param {GetProviderOptions} options * @param {GetProviderOptions} options
* @return {void} * @return {void}
* @tutorial https://doc.dcloud.net.cn/uni-app-x/api/get-provider.html * @tutorial https://doc.dcloud.net.cn/uni-app-x/api/get-provider.html
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
* "osVer": "5.0", * "osVer": "5.0",
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "4.11" * "unixVer": "4.11"
* }, * },
* "ios": { * "ios": {
* "osVer": "9.0", * "osVer": "9.0",
* "uniVer": "√", * "uniVer": "√",
* "unixVer": "x" * "unixVer": "4.18"
* } * }
* }, * },
* "web": { * "web": {
* "uniVer": "√", * "uniVer": "x",
* "unixVer": "4.05" * "unixVer": "x"
* } * }
* } * }
* @example * @example
```typescript ```typescript
uni.getProvider({service: ''}) uni.getProvider({service: ''})
``` ```
*/ */
getProvider(options: GetProviderOptions) : void; getProvider(options : GetProviderOptions) : void;
} }
...@@ -77,6 +77,7 @@ export const getSystemInfoSync : GetSystemInfoSync = function () : GetSystemInfo ...@@ -77,6 +77,7 @@ export const getSystemInfoSync : GetSystemInfoSync = function () : GetSystemInfo
height: windowHeight - safeAreaInsets.top - safeAreaInsets.bottom height: windowHeight - safeAreaInsets.top - safeAreaInsets.bottom
} }
const osAndroidAPILevel = Build.VERSION.SDK_INT; const osAndroidAPILevel = Build.VERSION.SDK_INT;
const appTheme = UTSAndroid.getAppTheme();
const result = { const result = {
SDKVersion: "", SDKVersion: "",
...@@ -125,6 +126,7 @@ export const getSystemInfoSync : GetSystemInfoSync = function () : GetSystemInfo ...@@ -125,6 +126,7 @@ export const getSystemInfoSync : GetSystemInfoSync = function () : GetSystemInfo
safeAreaInsets: safeAreaInsets, safeAreaInsets: safeAreaInsets,
safeArea: safeArea, safeArea: safeArea,
osAndroidAPILevel: osAndroidAPILevel, osAndroidAPILevel: osAndroidAPILevel,
appTheme: appTheme,
} as GetSystemInfoResult; } as GetSystemInfoResult;
return result; return result;
} catch (e : Exception) { } catch (e : Exception) {
......
...@@ -16,12 +16,6 @@ export const getSystemInfoSync : GetSystemInfoSync = function () : GetSystemInfo ...@@ -16,12 +16,6 @@ export const getSystemInfoSync : GetSystemInfoSync = function () : GetSystemInfo
const osVersion = UIDevice.current.systemVersion const osVersion = UIDevice.current.systemVersion
let osTheme = 'light'
if(UTSiOS.available("iOS 13, *")){
let currentTraitCollection = UIApplication.shared.keyWindow?.traitCollection
osTheme = currentTraitCollection?.userInterfaceStyle == UIUserInterfaceStyle.dark ? "dark" : "light"
}
let deviceOrientation = 'portrait' let deviceOrientation = 'portrait'
const orient = UIApplication.shared.statusBarOrientation; const orient = UIApplication.shared.statusBarOrientation;
if (orient == UIInterfaceOrientation.landscapeLeft || orient == UIInterfaceOrientation.landscapeRight) { if (orient == UIInterfaceOrientation.landscapeLeft || orient == UIInterfaceOrientation.landscapeRight) {
...@@ -50,7 +44,7 @@ export const getSystemInfoSync : GetSystemInfoSync = function () : GetSystemInfo ...@@ -50,7 +44,7 @@ export const getSystemInfoSync : GetSystemInfoSync = function () : GetSystemInfo
osName: 'ios', osName: 'ios',
osVersion: osVersion, osVersion: osVersion,
osLanguage: UTSiOS.getOsLanguage(), osLanguage: UTSiOS.getOsLanguage(),
osTheme: osTheme, osTheme: UTSiOS.getOsTheme(),
pixelRatio: windowInfo.pixelRatio, pixelRatio: windowInfo.pixelRatio,
platform: 'ios', platform: 'ios',
screenWidth: windowInfo.screenWidth, screenWidth: windowInfo.screenWidth,
...@@ -74,6 +68,7 @@ export const getSystemInfoSync : GetSystemInfoSync = function () : GetSystemInfo ...@@ -74,6 +68,7 @@ export const getSystemInfoSync : GetSystemInfoSync = function () : GetSystemInfo
windowBottom: windowInfo.windowBottom, windowBottom: windowInfo.windowBottom,
safeAreaInsets: windowInfo.safeAreaInsets, safeAreaInsets: windowInfo.safeAreaInsets,
safeArea: windowInfo.safeArea, safeArea: windowInfo.safeArea,
appTheme: UTSiOS.getAppTheme(),
}; };
return result; return result;
} }
......
...@@ -343,6 +343,7 @@ function copyFile(fromFilePath : string, toFilePath : string) : boolean { ...@@ -343,6 +343,7 @@ function copyFile(fromFilePath : string, toFilePath : string) : boolean {
if (!fromFile.canRead()) { if (!fromFile.canRead()) {
return false; return false;
} }
fis = new FileInputStream(fromFile);
} }
if (fis == null) { if (fis == null) {
return false return false
...@@ -358,7 +359,6 @@ function copyFile(fromFilePath : string, toFilePath : string) : boolean { ...@@ -358,7 +359,6 @@ function copyFile(fromFilePath : string, toFilePath : string) : boolean {
toFile.createNewFile() toFile.createNewFile()
} }
try { try {
// let fis = new FileInputStream(fromFile)
let fos = new FileOutputStream(toFile) let fos = new FileOutputStream(toFile)
let byteArrays = ByteArray(1024) let byteArrays = ByteArray(1024)
var c = fis!!.read(byteArrays) var c = fis!!.read(byteArrays)
...@@ -592,6 +592,21 @@ export const getVideoInfo : GetVideoInfo = function (options : GetVideoInfoOptio ...@@ -592,6 +592,21 @@ export const getVideoInfo : GetVideoInfo = function (options : GetVideoInfoOptio
export const saveVideoToPhotosAlbum : SaveVideoToPhotosAlbum = function (options : SaveVideoToPhotosAlbumOptions) { export const saveVideoToPhotosAlbum : SaveVideoToPhotosAlbum = function (options : SaveVideoToPhotosAlbumOptions) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
let requestPermissionList : Array<string> = [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)) { if (TextUtils.isEmpty(options.filePath)) {
let error = new MediaErrorImpl(1101003, UniError_SaveVideoToPhotosAlbum); let error = new MediaErrorImpl(1101003, UniError_SaveVideoToPhotosAlbum);
options.fail?.(error) options.fail?.(error)
......
import { ChooseImageOptions, ChooseVideoOptions } from "./interface.uts" import { ChooseImageOptions, ChooseVideoOptions } from "../../interface.uts"
import { import {
UniError_ChooseImage, UniError_ChooseVideo, MediaErrorImpl UniError_ChooseImage, UniError_ChooseVideo, MediaErrorImpl
} from "./unierror.uts" } from "../../unierror.uts"
export const CODE_CAMERA_ERROR = 11; export const CODE_CAMERA_ERROR = 11;
export const CODE_GALLERY_ERROR = 12; export const CODE_GALLERY_ERROR = 12;
export const CODE_GET_IMAGE_INFO_CODE = 13 export const CODE_GET_IMAGE_INFO_CODE = 13
......
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
MediaErrorImpl MediaErrorImpl
} from "../../unierror.uts" } from "../../unierror.uts"
import { getVideoMetadata } from "./MediaUtils.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 { getUniActivity } from "io.dcloud.uts.android";
import Intent from 'android.content.Intent'; import Intent from 'android.content.Intent';
import File from 'java.io.File'; import File from 'java.io.File';
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册