feat: add storage capacity setting

This commit is contained in:
Lan committed 2026-07-11 17:50:38 +08:00
1 parent 1cec0a46db
commit 45ef99a336
6 files changed
+59

No files matched your search

+11
View File
@@ -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<FileSizeUnit>('MB')
const storageLimit = ref(0)
const storageLimitUnit = ref<FileSizeUnit>('GB')
const saveTime = ref(1)
const saveTimeUnit = ref<SaveTimeUnit>('天')
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,
+3
View File
@@ -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',
+2
View File
@@ -139,6 +139,8 @@ export default {
notificationTitle: '公告标题',
notificationContent: '公告内容',
storageSettings: '存储配置',
storageLimit: '总存储容量上限',
storageLimitHelp: '所有有效分享与未完成上传共同占用容量,设置为 0 表示不限制。',
storagePath: '文件存储路径',
storagePathPlaceholder: '使用默认路径可留空',
storageMethod: '存储方式',
+1
View File
@@ -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
+1
View File
@@ -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,
+41
View File
@@ -16,6 +16,8 @@ const {
isDirty,
fileSize,
sizeUnit,
storageLimit,
storageLimitUnit,
saveTime,
saveTimeUnit,
adminSessionDays,
@@ -779,6 +781,45 @@ onMounted(() => {
</div>
</div>
<div class="space-y-2">
<label
class="block text-sm font-medium"
:class="[isDarkMode ? 'text-zinc-300' : 'text-zinc-700']"
>
{{ t('admin.settings.storageLimit') }}
</label>
<div class="flex items-center space-x-2">
<input
v-model.number="storageLimit"
type="number"
min="0"
step="1"
class="w-28 rounded-md border px-4 py-2.5 shadow-sm outline-none transition-all duration-200 focus:border-zinc-500 focus:ring-2 focus:ring-zinc-500"
:class="[
isDarkMode
? 'border-white/10 bg-zinc-950/45 text-white hover:border-white/20'
: 'border-zinc-200/80 bg-white/80 text-zinc-950 hover:border-zinc-300'
]"
/>
<select
v-model="storageLimitUnit"
class="rounded-md border px-4 py-2.5 shadow-sm outline-none transition-all duration-200 focus:border-zinc-500 focus:ring-2 focus:ring-zinc-500"
:class="[
isDarkMode
? 'border-white/10 bg-zinc-950/45 text-white hover:border-white/20'
: 'border-zinc-200/80 bg-white/80 text-zinc-950 hover:border-zinc-300'
]"
>
<option value="KB">KB</option>
<option value="MB">MB</option>
<option value="GB">GB</option>
</select>
</div>
<p class="text-xs" :class="[isDarkMode ? 'text-zinc-400' : 'text-zinc-500']">
{{ t('admin.settings.storageLimitHelp') }}
</p>
</div>
<SettingSwitch
:label="t('manage.settings.guestUpload')"
:model-value="config.openUpload"