From d56890b6e245b6f25f6855ae8f8963a393ad304b Mon Sep 17 00:00:00 2001 From: zhouaoteng Date: Thu, 28 Mar 2024 22:11:20 +0800 Subject: [PATCH] fix:modify config Signed-off-by: zhouaoteng --- interfaces/kits/picker/picker.js | 64 ++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/interfaces/kits/picker/picker.js b/interfaces/kits/picker/picker.js index d5b451d5..c3659ca0 100644 --- a/interfaces/kits/picker/picker.js +++ b/interfaces/kits/picker/picker.js @@ -208,14 +208,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 +229,6 @@ function parseDocumentPickerSelectOption(args, action) { } console.log('[picker] document select config: ' + JSON.stringify(config)); - return config; } function getDocumentPickerSelectResult(args) { @@ -289,12 +281,26 @@ async function documentPickerSelect(...args) { if (documentSelectContext === undefined) { throw getErr(ErrCode.CONTEXT_NO_EXIST); } - documentSelectConfig = parseDocumentPickerSelectOption(args, ACTION.SELECT_ACTION_MODAL); + let documentSelectConfig = { + action: ACTION.SELECT_ACTION_MODAL, + bundleName: 'com.huawei.hmos.filemanager', + 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,13 +328,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]; @@ -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: 'com.huawei.hmos.filemanager', + 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); @@ -439,8 +452,13 @@ async function audioPickerSelect(...args) { console.log('[picker] Audio Invalid argument'); throw checkAudioArgsResult; } - - const audioSelectConfig = parseDocumentPickerSelectOption(args, ACTION.SELECT_ACTION); + let audioSelectConfig = { + action: ACTION.SELECT_ACTION, + parameters: { + startMode: 'choose', + } + }; + parseDocumentPickerSelectOption(args, ACTION.audioSelectConfig); console.log('[picker] audio select config: ' + JSON.stringify(audioSelectConfig)); let audioSelectContext = undefined; -- Gitee