From 7049c8d9c9ce6e60c2253c5c2aee3ea0bb19fd93 Mon Sep 17 00:00:00 2001 From: hunili Date: Sat, 6 Apr 2024 17:28:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A8=A1=E6=80=81=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=20issue:=20Signed-off-by:=20hunili=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/kits/picker/picker.js | 65 +++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/interfaces/kits/picker/picker.js b/interfaces/kits/picker/picker.js index d5b451d5..5ba12a6c 100644 --- a/interfaces/kits/picker/picker.js +++ b/interfaces/kits/picker/picker.js @@ -57,6 +57,7 @@ const CREATE_FILE_NAME_LENGTH_LIMIT = 256; const ARGS_ZERO = 0; const ARGS_ONE = 1; const ARGS_TWO = 2; +const FILE_MANAGER_NAME = 'com.huawei.hmos.filemanager'; /* * UTF-8字符编码数值对应的存储长度: @@ -208,14 +209,7 @@ async function photoPickerSelect(...args) { return undefined; } -function parseDocumentPickerSelectOption(args, action) { - let config = { - action: action, - parameters: { - startMode: 'choose', - } - }; - +function parseDocumentPickerSelectOption(args, config) { if (args.length > ARGS_ZERO && typeof args[ARGS_ZERO] === 'object') { let option = args[ARGS_ZERO]; config.parameters.key_select_mode = option.selectMode; @@ -236,7 +230,6 @@ function parseDocumentPickerSelectOption(args, action) { } console.log('[picker] document select config: ' + JSON.stringify(config)); - return config; } function getDocumentPickerSelectResult(args) { @@ -289,12 +282,26 @@ async function documentPickerSelect(...args) { if (documentSelectContext === undefined) { throw getErr(ErrCode.CONTEXT_NO_EXIST); } - documentSelectConfig = parseDocumentPickerSelectOption(args, ACTION.SELECT_ACTION_MODAL); + documentSelectConfig = { + action: ACTION.SELECT_ACTION_MODAL, + bundleName: FILE_MANAGER_NAME, + abilityName: 'PickerServiceExtAbility', + parameters: { + startMode: 'choose', + } + }; + parseDocumentPickerSelectOption(args, documentSelectConfig); documentSelectResult = await documentSelectContext.requestDialogService(documentSelectConfig); } catch (paramError) { console.error('[picker] DocumentSelect paramError: ' + JSON.stringify(paramError)); try { - documentSelectConfig = parseDocumentPickerSelectOption(args, ACTION.SELECT_ACTION); + documentSelectConfig = { + action: ACTION.SELECT_ACTION, + parameters: { + startMode: 'choose', + } + }; + parseDocumentPickerSelectOption(args, documentSelectConfig); documentSelectResult = await documentSelectContext.startAbilityForResult(documentSelectConfig, {windowMode: 0}); } catch (error) { console.error('[picker] DocumentSelect error: ' + error); @@ -322,14 +329,7 @@ async function documentPickerSelect(...args) { return undefined; } -function parseDocumentPickerSaveOption(args, action) { - let config = { - action: action, - parameters: { - startMode: 'save', - } - }; - +function parseDocumentPickerSaveOption(args, config) { if (args.length > ARGS_ZERO && typeof args[ARGS_ZERO] === 'object') { let option = args[ARGS_ZERO]; if ((option.newFileNames !== undefined) && option.newFileNames.length > 0) { @@ -346,7 +346,6 @@ function parseDocumentPickerSaveOption(args, action) { } console.log('[picker] document save config: ' + JSON.stringify(config)); - return config; } function getDocumentPickerSaveResult(args) { @@ -400,12 +399,26 @@ async function documentPickerSave(...args) { if (documentSaveContext === undefined) { throw getErr(ErrCode.CONTEXT_NO_EXIST); } - documentSaveConfig = parseDocumentPickerSaveOption(args, ACTION.SAVE_ACTION_MODAL); + documentSaveConfig = { + action: ACTION.SAVE_ACTION_MODAL, + bundleName: FILE_MANAGER_NAME, + abilityName: 'PickerServiceExtAbility', + parameters: { + startMode: 'save', + } + }; + parseDocumentPickerSaveOption(args, documentSaveConfig); documentSaveResult = await documentSaveContext.requestDialogService(documentSaveConfig); } catch (paramError) { console.error('[picker] paramError: ' + JSON.stringify(paramError)); try { - documentSaveConfig = parseDocumentPickerSaveOption(args, ACTION.SAVE_ACTION); + documentSaveConfig = { + action: ACTION.SAVE_ACTION, + parameters: { + startMode: 'save', + } + }; + parseDocumentPickerSaveOption(args, documentSaveConfig); documentSaveResult = await documentSaveContext.startAbilityForResult(documentSaveConfig, {windowMode: 0}); } catch (error) { console.error('[picker] document save error: ' + error); @@ -440,7 +453,13 @@ async function audioPickerSelect(...args) { throw checkAudioArgsResult; } - const audioSelectConfig = parseDocumentPickerSelectOption(args, ACTION.SELECT_ACTION); + let audioSelectConfig = { + action: ACTION.SELECT_ACTION, + parameters: { + startMode: 'choose', + } + }; + parseDocumentPickerSelectOption(args, audioSelectConfig); console.log('[picker] audio select config: ' + JSON.stringify(audioSelectConfig)); let audioSelectContext = undefined; -- Gitee