diff --git a/interfaces/kits/picker/picker.js b/interfaces/kits/picker/picker.js index 88beed41e55d91fe423a0c074b0febaf2d62edc5..20ad2302edf53813d9bb80e0526e0cbfcdbde78f 100644 --- a/interfaces/kits/picker/picker.js +++ b/interfaces/kits/picker/picker.js @@ -602,21 +602,61 @@ function AudioViewPicker() { this.save = documentPickerSave; } +function parseOpenDirectory(args) { + let fileUri = ''; + let openLinkOptions = { + appLinkingOnly: false, + parameters: { + 'fileUri': '' + } + } + + if (args.length === ARGS_TWO && typeof args[ARGS_ONE] === 'string') { + fileUri = args[ARGS_ONE]; + openLinkOptions.parameters.fileUri = encodeURI(fileUri); + } + console.log('[picker] fileUri length: ' + fileUri.length); + return openLinkOptions; +} + +async function openDirectory(...args) { + let context = undefined; + let openLinkOptions = undefined; + let link = "filemanager://openDirectory" + try { + context = args[ARGS_ZERO]; + if (context === undefined) { + throw getErr(ErrCode.CONTEXT_NO_EXIST); + } + } catch (getContextError) { + console.error('[picker] getContext error: ' + getContextError); + throw getErr(ErrCode.CONTEXT_NO_EXIST); + } + try { + openLinkOptions = parseOpenDirectory(args); + await context.openLink( + link, + openLinkOptions) + } catch (paramError) { + console.error('[picker] paramError: ' + JSON.stringify(paramError)); + } +} export default { startModalPicker, - ExtTypes : ExtTypes, + ExtTypes: ExtTypes, PickerDetailType: PickerDetailType, - PhotoViewMIMETypes : PhotoViewMIMETypes, - PhotoSelectOptions : PhotoSelectOptions, - PhotoSelectResult : PhotoSelectResult, - PhotoSaveOptions : PhotoSaveOptions, - DocumentSelectMode : DocumentSelectMode, - DocumentPickerMode : DocumentPickerMode, - DocumentSelectOptions : DocumentSelectOptions, - DocumentSaveOptions : DocumentSaveOptions, - AudioSelectOptions : AudioSelectOptions, - AudioSaveOptions : AudioSaveOptions, - PhotoViewPicker : PhotoViewPicker, + PhotoViewMIMETypes: PhotoViewMIMETypes, + PhotoSelectOptions: PhotoSelectOptions, + PhotoSelectResult: PhotoSelectResult, + PhotoSaveOptions: PhotoSaveOptions, + DocumentSelectMode: DocumentSelectMode, + DocumentPickerMode: DocumentPickerMode, + DocumentSelectOptions: DocumentSelectOptions, + DocumentSaveOptions: DocumentSaveOptions, + AudioSelectOptions: AudioSelectOptions, + AudioSaveOptions: AudioSaveOptions, + PhotoViewPicker: PhotoViewPicker, DocumentViewPicker: DocumentViewPicker, - AudioViewPicker : AudioViewPicker, -} \ No newline at end of file + AudioViewPicker: AudioViewPicker, + openDirectory: openDirectory, +}; \ No newline at end of file