diff --git a/package.json b/package.json index 493a1a3ab2fd47b849d148343edb63079a599910..072d242a97471a94fba82ff432a3040f2a466e6e 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ }, "devDependencies": { "@babel/preset-env": "^7.14.7", - "@dcloudio/types": "^2.4.5", + "@dcloudio/types": "^2.4.6", "@jest/types": "^27.0.2", "@microsoft/api-extractor": "^7.13.2", "@rollup/plugin-alias": "^3.1.1", diff --git a/packages/uni-app-plus/dist/uni-app-service.es.js b/packages/uni-app-plus/dist/uni-app-service.es.js index 35b370970acd5eccffb5bebd53b068d22bda102a..982e06bffaf6ad8a5e0fab34a12b17597e09efb4 100644 --- a/packages/uni-app-plus/dist/uni-app-service.es.js +++ b/packages/uni-app-plus/dist/uni-app-service.es.js @@ -5672,12 +5672,8 @@ var serviceContext = (function (vue) { }, GetFileInfoProtocol, GetFileInfoOptions); const openDocument = defineAsyncApi(API_OPEN_DOCUMENT, ({ filePath, fileType }, { resolve, reject }) => { - plus.io.resolveLocalFileSystemURL(getRealPath(filePath), (entry) => { - plus.runtime.openFile(getRealPath(filePath)); - resolve(); - }, (err) => { - reject('openDocument:fail ' + err.message); - }); + const errorCallback = warpPlusErrorCallback(reject); + plus.runtime.openFile(getRealPath(filePath), undefined, errorCallback, resolve); }, OpenDocumentProtocol, OpenDocumentOptions); function getFileName(path) { diff --git a/packages/uni-app-plus/src/service/api/file/openDocument.ts b/packages/uni-app-plus/src/service/api/file/openDocument.ts index 4b4a19d3a5bc2119e6f836127938559e9a72c681..4cdadbca9b1a0e6d1a3744c31ccdc7dabf33ea69 100644 --- a/packages/uni-app-plus/src/service/api/file/openDocument.ts +++ b/packages/uni-app-plus/src/service/api/file/openDocument.ts @@ -5,20 +5,18 @@ import { OpenDocumentProtocol, OpenDocumentOptions, } from '@dcloudio/uni-api' - +import { warpPlusErrorCallback } from '../../../helpers/plus' import { getRealPath } from '../../../platform/getRealPath' + export const openDocument = defineAsyncApi( API_OPEN_DOCUMENT, ({ filePath, fileType }, { resolve, reject }) => { - plus.io.resolveLocalFileSystemURL( + const errorCallback = warpPlusErrorCallback(reject) + plus.runtime.openFile( getRealPath(filePath), - (entry) => { - plus.runtime.openFile(getRealPath(filePath)) - resolve() - }, - (err) => { - reject('openDocument:fail ' + err.message) - } + undefined, + errorCallback, + resolve ) }, OpenDocumentProtocol, diff --git a/yarn.lock b/yarn.lock index c539adc3b7da154c6d44849042ce85fd55bbc300..fcb027ee6a82146219a524681ab4c86e57304e29 100644 --- a/yarn.lock +++ b/yarn.lock @@ -922,10 +922,10 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@dcloudio/types@^2.4.5": - version "2.4.5" - resolved "https://registry.yarnpkg.com/@dcloudio/types/-/types-2.4.5.tgz#3ead18599a6da0052afb814b522bc007043d814c" - integrity sha512-6PUP4D4PZgm5Zc7hAegNZZreJN6D9VK8bEp/oHG3tevVJ0w9+C/9PBgcX1kStxIwqYcfR0dv8jTyjG08BF185Q== +"@dcloudio/types@^2.4.6": + version "2.4.6" + resolved "https://registry.yarnpkg.com/@dcloudio/types/-/types-2.4.6.tgz#cf4492885b292648e8d3e51c268e5e35376cd9f6" + integrity sha512-wNyfOBEGfAklzDe0BjWDGTZNgI+RIRL+9VfKbYcXNUHJwPfo8B70BHnuP+GwNxppjoDodI3v31eU8xpJEFqeQw== "@eslint/eslintrc@^0.4.3": version "0.4.3"