From 5e989bca4ba8492c3dfe5a74b04637b544563dfd Mon Sep 17 00:00:00 2001 From: VirtualHotBar <96966978+VirtualHotBar@users.noreply.github.com> Date: Thu, 16 May 2024 14:16:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E6=8C=82=E8=BD=BD?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=90=8E=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../storage/mount/parameters/defaults.ts | 34 ++++++++++++------- src/page/mount/add.tsx | 4 +-- src/page/other/InputForm.tsx | 29 ++++++++++++---- src/type/rclone/storage/mount/parameters.d.ts | 3 +- 4 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/controller/storage/mount/parameters/defaults.ts b/src/controller/storage/mount/parameters/defaults.ts index c13c9bf..cde11e1 100644 --- a/src/controller/storage/mount/parameters/defaults.ts +++ b/src/controller/storage/mount/parameters/defaults.ts @@ -1,20 +1,29 @@ +import { StorageParamItemType } from "../../../../type/controller/storage/info"; import { MountOptions, VfsOptions } from "../../../../type/rclone/storage/mount/parameters"; +const vfsCacheModeParam: StorageParamItemType = { + label: 'CacheMode', + name: 'CacheMode', + description: 'CacheMode', + type: 'string', + default: 'full', + required: false, + advanced: false, + isPassword: false, + select: [ + { label: 'Full', value: 'full', help: '' }, + { label: 'Writes', value: 'writes', help: '' }, + { label: 'Minimal', value: 'minimal', help: '' }, + { label: 'Off', value: 'off', help: '' } + ] +} // 示例:初始化VfsOptions和MountOptions的默认值 const defaultVfsConfig: VfsOptions = { ReadOnly: false, CacheMaxAge: 3600000000000, CacheMaxSize: -1, - CacheMode: { - select: 'full', - values: [ - 'off', - 'minimal', - 'writes', - 'full', - ] - }, + CacheMode: 'full', CachePollInterval: 60000000000, CaseInsensitive: false, ChunkSize: 67108864, @@ -29,7 +38,7 @@ const defaultVfsConfig: VfsOptions = { ReadAhead: 0, ReadWait: 20000000, WriteBack: 5000000000, - WriteWait: 1000000000, + WriteWait: 1000000000, Refresh: false, BlockNormDupes: false, UsedIsSize: false, @@ -38,7 +47,6 @@ const defaultVfsConfig: VfsOptions = { UID: 4294967295, GID: 4294967295, Umask: 0, - }; const defaultMountConfig: MountOptions = { @@ -58,10 +66,10 @@ const defaultMountConfig: MountOptions = { NoAppleDouble: true, NoAppleXattr: false, WritebackCache: false, - DaemonWait: 0, + DaemonWait: 0, DeviceName: '', NetworkMode: false, //挂载为网络驱动器 //CaseInsensitive: null, }; -export { defaultVfsConfig, defaultMountConfig } \ No newline at end of file +export { defaultVfsConfig, defaultMountConfig,vfsCacheModeParam } \ No newline at end of file diff --git a/src/page/mount/add.tsx b/src/page/mount/add.tsx index c233444..925a7db 100644 --- a/src/page/mount/add.tsx +++ b/src/page/mount/add.tsx @@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next' import { useNavigate } from 'react-router-dom'; import { ParametersType } from '../../type/defaults'; import { formatPath, getProperties, getURLSearchParam, getWinFspInstallState, showPathInExplorer } from '../../utils/utils'; -import { defaultMountConfig, defaultVfsConfig } from '../../controller/storage/mount/parameters/defaults'; +import { defaultMountConfig, defaultVfsConfig, vfsCacheModeParam } from '../../controller/storage/mount/parameters/defaults'; import { rcloneInfo } from '../../services/rclone'; import { addMountStorage, getAvailableDriveLetter, getMountStorage, mountStorage } from '../../controller/storage/mount/mount'; import { osInfo } from '../../services/config'; @@ -152,7 +152,7 @@ export default function AddMount_page() { {
{ parameters.mountOpt = data }} overwriteValues={defaultMountConfig} setFormHook={(form) => { setMountOptFormHook(form) }} /> - { parameters.vfsOpt = data }} overwriteValues={defaultVfsConfig} setFormHook={(form) => { setVfsOptFormHook(form) }} /> + { parameters.vfsOpt = data }} overwriteValues={defaultVfsConfig} setFormHook={(form) => { setVfsOptFormHook(form) }} />
} diff --git a/src/page/other/InputForm.tsx b/src/page/other/InputForm.tsx index b52543e..79882bd 100644 --- a/src/page/other/InputForm.tsx +++ b/src/page/other/InputForm.tsx @@ -13,10 +13,12 @@ const Row = Grid.Row; const Col = Grid.Col; const FormItem = Form.Item; -function paramsType2FormItems(params: ParametersType, isAdvanced: boolean = false) { +function paramsType2FormItems(params: ParametersType, isAdvanced: boolean = false,filter:string[]=[]) {//丢弃key匹配filter的项 const formItems: StorageParamItemType[] = [] getProperties(params).forEach((item) => { + if (filter.includes(item.key)) return; + let valueType: 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' | 'array' = typeof item.value; let formItem: StorageParamItemType = { label: item.key, @@ -27,7 +29,7 @@ function paramsType2FormItems(params: ParametersType, isAdvanced: boolean = fals default: item.value, advanced: isAdvanced, isPassword: false, - mark: [] + //mark: [] } switch (valueType) { case 'boolean': @@ -36,6 +38,22 @@ function paramsType2FormItems(params: ParametersType, isAdvanced: boolean = fals case 'number': formItem.type = 'number' break; + case 'object': + if (item.value.select) {//选择器 + formItem.type = 'string' + formItem.default = item.value.default + formItem.select = item.value.select.map((item: string) => { + return { + label: item, + value: item, + help: item + } + }) + + } else { + formItem.type = 'string' + } + break; default: formItem.type = 'string' break; @@ -69,7 +87,7 @@ function StorageAndPathInputer({ value, onChange }: { value?: string, onChange?( if (tempPath.includes('/')) { value = tempPath.replace('/', ':') } else { - value = tempPath+':'; + value = tempPath + ':'; } } @@ -159,7 +177,7 @@ function InputFormItemContent_module({ data, formValuesResult /* style */ }: { for (const item of data.select) { //过滤 const filterState = (formValuesResult && item.filters) ? filter(item.filters, formValuesResult) : true; - + if (filterState) selectContent.push({t(item.label)}) } @@ -169,7 +187,6 @@ function InputFormItemContent_module({ data, formValuesResult /* style */ }: { } else { content = } - break; } @@ -187,7 +204,7 @@ function InputForm_module({ data, style, showAdvanced, footer, onChange, overwri overwriteValues?: ParametersType; setFormHook?: (form: FormInstance) => void; }) { - //console.log(data); + console.log(data); const { t } = useTranslation() const [form] = Form.useForm(); diff --git a/src/type/rclone/storage/mount/parameters.d.ts b/src/type/rclone/storage/mount/parameters.d.ts index 1955471..6eb530e 100644 --- a/src/type/rclone/storage/mount/parameters.d.ts +++ b/src/type/rclone/storage/mount/parameters.d.ts @@ -5,12 +5,11 @@ //https://github.com/rclone/rclone-webui-react/blob/master/src/utils/MountOptions.js //http://localhost:5572/options/get //https://rclone.org/commands/rclone_mount/#options-opt -import { ParametersType, ParamsSelectType } from "../../../defaults"; interface VfsOptions { CacheMaxAge: number; CacheMaxSize: number; - CacheMode: ParamsSelectType; + CacheMode: string; CachePollInterval: number; CaseInsensitive: boolean; ChunkSize: number;