From 45ef99a3363a52d239ceeac03bca6d439cea8c12 Mon Sep 17 00:00:00 2001 From: Lan Date: Sat, 11 Jul 2026 17:50:38 +0800 Subject: [PATCH] feat: add storage capacity setting --- src/composables/useSystemConfig.ts | 11 +++++++ src/i18n/locales/en-US.ts | 3 ++ src/i18n/locales/zh-CN.ts | 2 ++ src/types/config.ts | 1 + src/utils/config-storage.ts | 1 + src/views/manage/SystemSettingsView.vue | 41 +++++++++++++++++++++++++ 6 files changed, 59 insertions(+) diff --git a/src/composables/useSystemConfig.ts b/src/composables/useSystemConfig.ts index b219e2f..af02458 100644 --- a/src/composables/useSystemConfig.ts +++ b/src/composables/useSystemConfig.ts @@ -8,6 +8,7 @@ import { getErrorMessage } from '@/utils/common' import { buildConfigSubmitPayload, bytesToFileSizeForm, + fileSizeFormToBytes, secondsToSaveTimeForm, type FileSizeUnit, type SaveTimeUnit @@ -28,6 +29,8 @@ export function useSystemConfig() { const savedPayloadSnapshot = ref('') const fileSize = ref(1) const sizeUnit = ref('MB') + const storageLimit = ref(0) + const storageLimitUnit = ref('GB') const saveTime = ref(1) const saveTimeUnit = ref('天') const adminSessionDays = ref(30) @@ -41,6 +44,8 @@ export function useSystemConfig() { { value: saveTime.value, unit: saveTimeUnit.value } ) payload.adminSessionExpire = Math.round(adminSessionDays.value * SECONDS_PER_DAY) + payload.storageLimit = + storageLimit.value === 0 ? 0 : fileSizeFormToBytes(storageLimit.value, storageLimitUnit.value) if (!payload.admin_token) { delete payload.admin_token @@ -169,6 +174,10 @@ export function useSystemConfig() { fileSize.value = sizeForm.value sizeUnit.value = sizeForm.unit + const storageLimitForm = bytesToFileSizeForm(nextConfig.storageLimit) + storageLimit.value = storageLimitForm.value + storageLimitUnit.value = storageLimitForm.unit + const saveTimeForm = secondsToSaveTimeForm(nextConfig.max_save_seconds) saveTime.value = saveTimeForm.value saveTimeUnit.value = saveTimeForm.unit @@ -226,6 +235,8 @@ export function useSystemConfig() { isDirty, fileSize, sizeUnit, + storageLimit, + storageLimitUnit, saveTime, saveTimeUnit, adminSessionDays, diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index a0bc47c..dfda104 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -139,6 +139,9 @@ export default { notificationTitle: 'Announcement Title', notificationContent: 'Announcement Content', storageSettings: 'Storage', + storageLimit: 'Total Storage Capacity', + storageLimitHelp: + 'Active shares and pending uploads share this quota. Set to 0 for unlimited.', storagePath: 'Storage Path', storagePathPlaceholder: 'Leave empty for default path', storageMethod: 'Storage Type', diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index e538194..228bc4b 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -139,6 +139,8 @@ export default { notificationTitle: '公告标题', notificationContent: '公告内容', storageSettings: '存储配置', + storageLimit: '总存储容量上限', + storageLimitHelp: '所有有效分享与未完成上传共同占用容量,设置为 0 表示不限制。', storagePath: '文件存储路径', storagePathPlaceholder: '使用默认路径可留空', storageMethod: '存储方式', diff --git a/src/types/config.ts b/src/types/config.ts index 68c39d5..f09ac24 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -45,6 +45,7 @@ export interface ConfigState { allowed_file_types: string[] allowedFileTypes?: string[] storage_path: string + storageLimit: number uploadMinute: number max_save_seconds: number opacity: number diff --git a/src/utils/config-storage.ts b/src/utils/config-storage.ts index 9775dc8..077168a 100644 --- a/src/utils/config-storage.ts +++ b/src/utils/config-storage.ts @@ -54,6 +54,7 @@ export const DEFAULT_CONFIG_STATE: ConfigState = { allowed_file_types: DEFAULT_PUBLIC_CONFIG.allowedFileTypes, allowedFileTypes: DEFAULT_PUBLIC_CONFIG.allowedFileTypes, storage_path: '', + storageLimit: 0, uploadMinute: 1, max_save_seconds: DEFAULT_PUBLIC_CONFIG.max_save_seconds, opacity: 0.9, diff --git a/src/views/manage/SystemSettingsView.vue b/src/views/manage/SystemSettingsView.vue index f668200..79ed7ec 100644 --- a/src/views/manage/SystemSettingsView.vue +++ b/src/views/manage/SystemSettingsView.vue @@ -16,6 +16,8 @@ const { isDirty, fileSize, sizeUnit, + storageLimit, + storageLimitUnit, saveTime, saveTimeUnit, adminSessionDays, @@ -779,6 +781,45 @@ onMounted(() => { +
+ +
+ + +
+

+ {{ t('admin.settings.storageLimitHelp') }} +

+
+