From 52fca743eee17a2dec2c5d2590f3bf3addb0963a Mon Sep 17 00:00:00 2001 From: yangbo Date: Thu, 10 Aug 2023 14:13:29 +0800 Subject: [PATCH] documentPicker add option args Signed-off-by: yangbo Change-Id: Ia1397685ba1aae251538f6ff345fff64b9613e9b --- interfaces/kits/picker/picker.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/picker/picker.js b/interfaces/kits/picker/picker.js index 78428f99..ac9eb5be 100644 --- a/interfaces/kits/picker/picker.js +++ b/interfaces/kits/picker/picker.js @@ -158,6 +158,20 @@ function parseDocumentPickerSelectOption(args) { } }; + if (args.length > ARGS_ZERO && typeof args[ARGS_ZERO] === 'object') { + let option = args[ARGS_ZERO]; + + if (('maxSelectNumber' in option) && option.maxSelectNumber > 0) { + config.parameters.key_pick_num = option.maxSelectNumber;//选择文件数量 + } + if ('defaultFilePathUri' in option) { + config.parameters.key_pick_dir_path = option.defaultFilePathUri;//默认路径URI + } + if (('fileSuffixFilter' in option) && option.fileSuffixFilter.length > 0) { + config.parameters.fileSuffixFilter = option.fileSuffixFilter;//文件后缀选择 + } + } + return config; } @@ -222,10 +236,16 @@ function parseDocumentPickerSaveOption(args) { if (args.length > ARGS_ZERO && typeof args[ARGS_ZERO] === 'object') { let option = args[ARGS_ZERO]; - if (option.newFileNames.length > 0) { + if (('newFileNames' in option) && option.newFileNames.length > 0) { config.parameters.key_pick_file_name = option.newFileNames; config.parameters.saveFile = option.newFileNames[0]; } + if ('defaultFilePathUri' in option) { + config.parameters.key_pick_dir_path = option.defaultFilePathUri;//默认路径URI + } + if (('fileSuffixChoices' in option) && option.fileSuffixChoices.length > 0) { + config.parameters.key_pick_file_types = option.fileSuffixChoices;//文件后缀选择 + } } return config; @@ -328,10 +348,16 @@ function PhotoSaveOptions() { this.newFileNames = []; } -function DocumentSelectOptions() {} +function DocumentSelectOptions() { + this.defaultFilePathUri = undefined; + this.fileSuffixFilters = undefined; + this.maxSelectNumber = undefined; +} function DocumentSaveOptions() { this.newFileNames = []; + this.defaultFilePathUri = undefined; + this.fileSuffixChoices = undefined; } function AudioSelectOptions() {} -- Gitee