838 lines
37 KiB
Vue
838 lines
37 KiB
Vue
<script setup lang="ts">
|
|
import { inject, onMounted, ref } from 'vue'
|
|
import { useI18n } from 'vue-i18n'
|
|
import { EyeIcon, EyeOffIcon, RefreshCwIcon, SaveIcon } from 'lucide-vue-next'
|
|
import BaseButton from '@/components/common/BaseButton.vue'
|
|
import SettingNumberInput from '@/components/common/SettingNumberInput.vue'
|
|
import SettingSwitch from '@/components/common/SettingSwitch.vue'
|
|
import { useSystemConfig } from '@/composables'
|
|
|
|
const isDarkMode = inject('isDarkMode')
|
|
const { t } = useI18n()
|
|
const showAdminPassword = ref(false)
|
|
const activeSection = ref('general')
|
|
const {
|
|
config,
|
|
isRefreshing,
|
|
isSaving,
|
|
isDirty,
|
|
fileSize,
|
|
sizeUnit,
|
|
saveTime,
|
|
saveTimeUnit,
|
|
refreshConfig,
|
|
submitConfig,
|
|
toggleConfigFlag
|
|
} = useSystemConfig()
|
|
|
|
const scrollToSection = (section: string) => {
|
|
activeSection.value = section
|
|
document.getElementById(`settings-${section}`)?.scrollIntoView({
|
|
behavior: window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth',
|
|
block: 'start'
|
|
})
|
|
}
|
|
|
|
const discardChanges = () => {
|
|
if (!window.confirm(t('manage.settings.discardChangesConfirm'))) return
|
|
void refreshConfig()
|
|
}
|
|
|
|
onMounted(() => {
|
|
void refreshConfig()
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<div class="p-4 pb-36 sm:p-6 sm:pb-28">
|
|
<div
|
|
class="mb-6 flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between"
|
|
>
|
|
<div>
|
|
<h2 class="text-2xl font-bold" :class="[isDarkMode ? 'text-white' : 'text-[#2d4650]']">
|
|
{{ t('admin.settings.title') }}
|
|
</h2>
|
|
<p
|
|
class="mt-1 text-sm"
|
|
:class="[isDirty ? 'text-amber-500' : isDarkMode ? 'text-gray-400' : 'text-[#586f75]']"
|
|
>
|
|
{{ isDirty ? t('manage.settings.unsavedChanges') : t('manage.settings.allChangesSaved') }}
|
|
</p>
|
|
</div>
|
|
|
|
<div class="hidden flex-wrap items-center gap-2 sm:flex">
|
|
<BaseButton
|
|
variant="secondary"
|
|
:loading="isRefreshing"
|
|
:disabled="isSaving || isDirty"
|
|
:title="isDirty ? t('manage.settings.refreshBlocked') : t('manage.settings.refreshConfig')"
|
|
@click="refreshConfig"
|
|
>
|
|
<template #icon>
|
|
<RefreshCwIcon class="mr-2 h-4 w-4" />
|
|
</template>
|
|
{{ isRefreshing ? t('manage.settings.refreshing') : t('manage.settings.refreshConfig') }}
|
|
</BaseButton>
|
|
|
|
<BaseButton :loading="isSaving" :disabled="!isDirty || isRefreshing" @click="submitConfig">
|
|
<template #icon>
|
|
<SaveIcon class="mr-2 h-4 w-4" />
|
|
</template>
|
|
{{ isSaving ? t('manage.settings.saving') : t('manage.settings.saveChanges') }}
|
|
</BaseButton>
|
|
</div>
|
|
</div>
|
|
|
|
<nav
|
|
class="mb-4 grid grid-cols-2 gap-2 sm:flex sm:overflow-x-auto sm:pb-2"
|
|
:aria-label="t('manage.settings.sectionNavigation')"
|
|
>
|
|
<button
|
|
v-for="section in [
|
|
['general', t('manage.settings.basicSettings')],
|
|
['storage', t('manage.settings.storageSettings')],
|
|
['upload', t('manage.settings.uploadLimits')],
|
|
['access', t('manage.settings.errorLimits')]
|
|
]"
|
|
:key="section[0]"
|
|
type="button"
|
|
class="inline-flex min-h-11 shrink-0 items-center justify-center rounded-full border px-3 text-center text-sm font-medium sm:px-4"
|
|
:class="activeSection === section[0]
|
|
? 'border-[#5f8796] bg-[#5f8796] text-white'
|
|
: isDarkMode
|
|
? 'border-[#40545c] bg-[#263941] text-[#d8e3e5]'
|
|
: 'border-[#c8d8dc] bg-[#edf4f5] text-[#415d66]'"
|
|
:aria-current="activeSection === section[0] ? 'true' : undefined"
|
|
@click="scrollToSection(section[0])"
|
|
>
|
|
{{ section[1] }}
|
|
</button>
|
|
</nav>
|
|
|
|
<div
|
|
class="theme-2026-card theme-2026-card-hover mx-auto max-w-6xl space-y-8 rounded-[24px] border p-4 shadow-md transition-all duration-200 hover:shadow-lg sm:rounded-[30px] sm:p-6"
|
|
:class="[
|
|
isDarkMode
|
|
? 'border-[#40545c] bg-[#202f36]/90 hover:border-[#7199a8] hover:bg-[#263941] hover:shadow-black/25'
|
|
: 'border-[#d7e3e5] bg-[#f8fbfb] hover:border-[#8fb2bf] hover:shadow-[#a9bdc2]/70'
|
|
]"
|
|
>
|
|
<!-- 基本设置 -->
|
|
<section id="settings-general" class="scroll-mt-4 space-y-4">
|
|
<h3 class="text-lg font-medium mb-4" :class="[isDarkMode ? 'text-white' : 'text-gray-800']">
|
|
{{ t('admin.settings.basicSettings') }}
|
|
</h3>
|
|
|
|
<!-- 网基本信息 -->
|
|
<div class="grid grid-cols-1 gap-6">
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('admin.settings.siteName') }}
|
|
</label>
|
|
<input
|
|
id="settings-site-name"
|
|
type="text"
|
|
v-model="config.name"
|
|
:aria-label="t('admin.settings.siteName')"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
</div>
|
|
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('admin.settings.websiteDescription') }}
|
|
</label>
|
|
<input
|
|
id="settings-description"
|
|
type="text"
|
|
v-model="config.description"
|
|
:aria-label="t('admin.settings.websiteDescription')"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
</div>
|
|
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('admin.settings.adminPassword') }}
|
|
</label>
|
|
<div class="relative">
|
|
<input
|
|
id="settings-admin-password"
|
|
:type="showAdminPassword ? 'text' : 'password'"
|
|
minlength="6"
|
|
v-model="config.admin_token"
|
|
:placeholder="t('admin.settings.passwordPlaceholder')"
|
|
autocomplete="new-password"
|
|
aria-describedby="settings-admin-password-note"
|
|
:aria-label="t('admin.settings.adminPassword')"
|
|
class="w-full rounded-md border px-4 py-2.5 pr-14 shadow-sm outline-none transition-all duration-200 ease-in-out focus:border-indigo-500 focus:ring-2 focus:ring-indigo-500"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
<button
|
|
type="button"
|
|
class="absolute inset-y-0 right-1 flex w-11 items-center justify-center rounded-lg"
|
|
:aria-label="showAdminPassword ? t('common.hidePassword') : t('common.showPassword')"
|
|
:title="showAdminPassword ? t('common.hidePassword') : t('common.showPassword')"
|
|
@click="showAdminPassword = !showAdminPassword"
|
|
>
|
|
<EyeOffIcon v-if="showAdminPassword" class="h-5 w-5" aria-hidden="true" />
|
|
<EyeIcon v-else class="h-5 w-5" aria-hidden="true" />
|
|
</button>
|
|
</div>
|
|
<p id="settings-admin-password-note" class="text-xs" :class="isDarkMode ? 'text-gray-300' : 'text-gray-600'">
|
|
{{ t('admin.settings.passwordNote') }}
|
|
</p>
|
|
</div>
|
|
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('admin.settings.keywords') }}
|
|
</label>
|
|
<input
|
|
id="settings-keywords"
|
|
type="text"
|
|
v-model="config.keywords"
|
|
:aria-label="t('admin.settings.keywords')"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
</div>
|
|
|
|
<!-- 主题选择 -->
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.themeSelection') }}
|
|
</label>
|
|
<select
|
|
id="settings-theme"
|
|
v-model="config.themesSelect"
|
|
:aria-label="t('manage.settings.themeSelection')"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border appearance-none bg-no-repeat bg-right focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none cursor-pointer"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400'
|
|
]"
|
|
style="
|
|
background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22none%22%3E%3Cpath%20d%3D%22M7%208l3%203%203-3%22%20stroke%3D%22%236B7280%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E');
|
|
"
|
|
>
|
|
<option v-for="item in config.themesChoices" :value="item.key" :key="item.key">
|
|
{{ item.name }} (by {{ item.author }} V{{ item.version }})
|
|
</option>
|
|
</select>
|
|
</div>
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.robotsFile') }}
|
|
</label>
|
|
<textarea
|
|
id="settings-robots"
|
|
v-model="config.robotsText"
|
|
:aria-label="t('manage.settings.robotsFile')"
|
|
rows="5"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border resize-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
></textarea>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 通知设置 -->
|
|
<div class="grid grid-cols-1 gap-6 mt-8">
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.notificationTitle') }}
|
|
</label>
|
|
<input
|
|
type="text"
|
|
v-model="config.notify_title"
|
|
:aria-label="t('manage.settings.notificationTitle')"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
</div>
|
|
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.notificationContent') }}
|
|
</label>
|
|
<textarea
|
|
v-model="config.notify_content"
|
|
:aria-label="t('manage.settings.notificationContent')"
|
|
rows="3"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border resize-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
></textarea>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 存储设置 -->
|
|
<div id="settings-storage" class="scroll-mt-4 space-y-4 border-t pt-8" :class="isDarkMode ? 'border-gray-700' : 'border-gray-200'">
|
|
<h3
|
|
class="text-lg font-medium mb-4"
|
|
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
|
>
|
|
{{ t('manage.settings.storageSettings') }}
|
|
</h3>
|
|
<!-- 通知设置 -->
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.storagePath') }}
|
|
</label>
|
|
<input
|
|
type="text"
|
|
:placeholder="t('manage.settings.storagePathPlaceholder')"
|
|
v-model="config.storage_path"
|
|
:aria-label="t('manage.settings.storagePath')"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
</div>
|
|
|
|
<div class="space-y-4">
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.storageMethod') }}
|
|
</label>
|
|
<select
|
|
v-model="config.file_storage"
|
|
:aria-label="t('manage.settings.storageMethod')"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border appearance-none bg-no-repeat bg-right focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none cursor-pointer"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400'
|
|
]"
|
|
style="
|
|
background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22none%22%3E%3Cpath%20d%3D%22M7%208l3%203%203-3%22%20stroke%3D%22%236B7280%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E');
|
|
"
|
|
>
|
|
<option value="local">{{ t('manage.settings.localStorage') }}</option>
|
|
<option value="s3">{{ t('manage.settings.s3Storage') }}</option>
|
|
<option value="webdav">{{ t('manage.settings.webdavStorage') }}</option>
|
|
</select>
|
|
</div>
|
|
<SettingSwitch
|
|
v-if="config.file_storage === 'local'"
|
|
:label="t('manage.settings.chunkUploadNote')"
|
|
:model-value="config.enableChunk"
|
|
:enabled-text="t('common.enabled')"
|
|
:disabled-text="t('common.disabled')"
|
|
@toggle="toggleConfigFlag('enableChunk')"
|
|
/>
|
|
<div v-if="config.file_storage === 'webdav'" class="space-y-4">
|
|
<!-- 通知设置 -->
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
Webdav URL
|
|
</label>
|
|
<input
|
|
type="text"
|
|
:placeholder="t('manage.settings.webdavUrlPlaceholder')"
|
|
v-model="config.webdav_url"
|
|
:aria-label="'WebDAV URL'"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
</div>
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
Webdav Username
|
|
</label>
|
|
<input
|
|
type="text"
|
|
:placeholder="t('manage.settings.webdavUsernamePlaceholder')"
|
|
v-model="config.webdav_username"
|
|
:aria-label="'WebDAV Username'"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
</div>
|
|
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
Webdav Password
|
|
</label>
|
|
<input
|
|
type="password"
|
|
:placeholder="t('manage.settings.webdavPasswordPlaceholder')"
|
|
v-model="config.webdav_password"
|
|
:aria-label="'WebDAV Password'"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- S3 配置 -->
|
|
<div v-if="config.file_storage === 's3'" class="space-y-4">
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.s3AccessKeyId') }}
|
|
</label>
|
|
<input
|
|
type="text"
|
|
v-model="config.s3_access_key_id"
|
|
:aria-label="t('manage.settings.s3AccessKeyId')"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
</div>
|
|
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.s3SecretAccessKey') }}
|
|
</label>
|
|
<input
|
|
type="password"
|
|
v-model="config.s3_secret_access_key"
|
|
:aria-label="t('manage.settings.s3SecretAccessKey')"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
</div>
|
|
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.s3BucketName') }}
|
|
</label>
|
|
<input
|
|
type="text"
|
|
v-model="config.s3_bucket_name"
|
|
:aria-label="t('manage.settings.s3BucketName')"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
</div>
|
|
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.s3EndpointUrl') }}
|
|
</label>
|
|
<input
|
|
type="text"
|
|
v-model="config.s3_endpoint_url"
|
|
:aria-label="t('manage.settings.s3EndpointUrl')"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
</div>
|
|
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.s3RegionName') }}
|
|
</label>
|
|
<input
|
|
type="text"
|
|
v-model="config.s3_region_name"
|
|
:aria-label="t('manage.settings.s3RegionName')"
|
|
:placeholder="t('manage.settings.autoPlaceholder')"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
</div>
|
|
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.s3SignatureVersion') }}
|
|
</label>
|
|
<select
|
|
v-model="config.s3_signature_version"
|
|
:aria-label="t('manage.settings.s3SignatureVersion')"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400'
|
|
]"
|
|
>
|
|
<option value="s3v2">{{ t('manage.settings.s3v2') }}</option>
|
|
<option value="s3v4">{{ t('manage.settings.s3v4') }}</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.s3Hostname') }}
|
|
</label>
|
|
<input
|
|
type="text"
|
|
v-model="config.s3_hostname"
|
|
:aria-label="t('manage.settings.s3Hostname')"
|
|
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
</div>
|
|
|
|
<SettingSwitch
|
|
:label="t('manage.settings.enableProxy')"
|
|
:model-value="config.s3_proxy"
|
|
:enabled-text="t('common.enabled')"
|
|
:disabled-text="t('common.disabled')"
|
|
@toggle="toggleConfigFlag('s3_proxy')"
|
|
/>
|
|
|
|
<SettingSwitch
|
|
:label="t('manage.settings.chunkUploadNote')"
|
|
:model-value="config.enableChunk"
|
|
:enabled-text="t('common.enabled')"
|
|
:disabled-text="t('common.disabled')"
|
|
@toggle="toggleConfigFlag('enableChunk')"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 上传限制 -->
|
|
<div id="settings-upload" class="scroll-mt-4 border-t pt-8" :class="isDarkMode ? 'border-gray-700' : 'border-gray-200'">
|
|
<h3
|
|
class="text-lg font-medium mb-4"
|
|
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
|
>
|
|
{{ t('manage.settings.uploadLimits') }}
|
|
</h3>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
<SettingNumberInput
|
|
v-model="config.uploadMinute"
|
|
:label="t('manage.settings.uploadPerMinute')"
|
|
:suffix="t('common.minute')"
|
|
/>
|
|
|
|
<SettingNumberInput
|
|
v-model="config.uploadCount"
|
|
:label="t('manage.settings.uploadCountLimit')"
|
|
:suffix="t('common.files')"
|
|
/>
|
|
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.fileSizeLimit') }}
|
|
</label>
|
|
<div class="flex items-center space-x-2">
|
|
<input
|
|
type="number"
|
|
v-model="fileSize"
|
|
:aria-label="t('manage.settings.fileSizeLimit')"
|
|
class="w-24 rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
<select
|
|
v-model="sizeUnit"
|
|
:aria-label="t('manage.settings.fileSizeUnit')"
|
|
class="rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400'
|
|
]"
|
|
>
|
|
<option value="KB">{{ t('manage.settings.fileSizeUnits.kb') }}</option>
|
|
<option value="MB">{{ t('manage.settings.fileSizeUnits.mb') }}</option>
|
|
<option value="GB">{{ t('manage.settings.fileSizeUnits.gb') }}</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium mb-2"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.expirationType') }}
|
|
</label>
|
|
<div class="flex flex-wrap gap-3">
|
|
<label
|
|
v-for="style in ['day', 'hour', 'minute', 'forever', 'count']"
|
|
:key="style"
|
|
class="relative inline-flex items-center group cursor-pointer"
|
|
>
|
|
<input
|
|
type="checkbox"
|
|
:value="style"
|
|
v-model="config.expireStyle"
|
|
class="peer sr-only"
|
|
/>
|
|
<div
|
|
class="px-4 py-2 rounded-full border-2 transition-all duration-200 select-none"
|
|
:class="[
|
|
config.expireStyle.includes(style)
|
|
? isDarkMode
|
|
? 'bg-indigo-600 border-indigo-600 text-white'
|
|
: 'bg-indigo-600 border-indigo-600 text-white'
|
|
: isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-gray-300 hover:border-indigo-500'
|
|
: 'bg-white border-gray-300 text-gray-700 hover:border-indigo-500'
|
|
]"
|
|
>
|
|
{{ t(`manage.settings.expiration.${style}`) }}
|
|
</div>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="space-y-2">
|
|
<label
|
|
class="block text-sm font-medium"
|
|
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
|
|
>
|
|
{{ t('manage.settings.maxSaveTime') }}
|
|
</label>
|
|
<div class="flex items-center space-x-2">
|
|
<input
|
|
type="number"
|
|
v-model="saveTime"
|
|
:aria-label="t('manage.settings.maxSaveTime')"
|
|
class="w-24 rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white placeholder-gray-400 hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400 placeholder-gray-500'
|
|
]"
|
|
/>
|
|
<select
|
|
v-model="saveTimeUnit"
|
|
:aria-label="t('manage.settings.timeUnit')"
|
|
class="rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
|
|
:class="[
|
|
isDarkMode
|
|
? 'bg-gray-700 border-gray-600 text-white hover:border-gray-500'
|
|
: 'border-gray-300 hover:border-gray-400'
|
|
]"
|
|
>
|
|
<option value="秒">{{ t('common.second') }}</option>
|
|
<option value="分">{{ t('common.minute') }}</option>
|
|
<option value="时">{{ t('common.hour') }}</option>
|
|
<option value="天">{{ t('common.day') }}</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<SettingNumberInput
|
|
v-model="config.trashRetentionDays"
|
|
:label="t('manage.settings.trashRetentionDays')"
|
|
:suffix="t('common.day')"
|
|
/>
|
|
|
|
<div class="col-span-full text-xs" :class="isDarkMode ? 'text-gray-400' : 'text-gray-600'">
|
|
{{ t('manage.settings.trashRetentionDaysNote') }}
|
|
</div>
|
|
|
|
<SettingSwitch
|
|
:label="t('manage.settings.guestUpload')"
|
|
:model-value="config.openUpload"
|
|
:enabled-text="t('common.enabled')"
|
|
:disabled-text="t('common.disabled')"
|
|
@toggle="toggleConfigFlag('openUpload')"
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 错误限制 -->
|
|
<div id="settings-access" class="scroll-mt-4 border-t pt-8" :class="isDarkMode ? 'border-gray-700' : 'border-gray-200'">
|
|
<h3
|
|
class="text-lg font-medium mb-4"
|
|
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
|
|
>
|
|
{{ t('manage.settings.errorLimits') }}
|
|
</h3>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
<SettingNumberInput
|
|
v-model="config.errorMinute"
|
|
:label="t('manage.settings.errorPerMinute')"
|
|
:suffix="t('common.minute')"
|
|
/>
|
|
|
|
<SettingNumberInput
|
|
v-model="config.errorCount"
|
|
:label="t('manage.settings.errorCountLimit')"
|
|
:suffix="t('common.times')"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<div
|
|
class="fixed inset-x-0 bottom-0 z-40 border-t px-4 pt-3 backdrop-blur-xl lg:left-64"
|
|
:class="isDarkMode ? 'border-[#31454d] bg-[#17252b]/95' : 'border-[#c8d7da] bg-[#f2f6f5]/95'"
|
|
role="status"
|
|
aria-live="polite"
|
|
>
|
|
<div
|
|
class="mx-auto grid max-w-6xl grid-cols-[minmax(0,1fr)_auto] items-center gap-3"
|
|
:style="{ paddingBottom: 'max(0.75rem, env(safe-area-inset-bottom))' }"
|
|
>
|
|
<div class="min-w-0">
|
|
<p class="truncate text-sm font-medium" :class="isDirty ? 'text-amber-600 dark:text-amber-300' : isDarkMode ? 'text-gray-300' : 'text-[#415d66]'">
|
|
{{ isDirty ? t('manage.settings.unsavedChanges') : t('manage.settings.allChangesSaved') }}
|
|
</p>
|
|
<BaseButton
|
|
v-if="isDirty"
|
|
variant="secondary"
|
|
size="sm"
|
|
class="mt-1 !min-h-9 !px-2 text-xs"
|
|
:loading="isRefreshing"
|
|
:disabled="isSaving"
|
|
@click="discardChanges"
|
|
>
|
|
{{ t('manage.settings.discardChanges') }}
|
|
</BaseButton>
|
|
</div>
|
|
<BaseButton class="min-w-28" :loading="isSaving" :disabled="!isDirty || isRefreshing" @click="submitConfig">
|
|
<template #icon><SaveIcon class="mr-2 h-4 w-4" /></template>
|
|
{{ isSaving ? t('manage.settings.saving') : t('common.save') }}
|
|
</BaseButton>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<style scoped>
|
|
:deep(input:not([type='checkbox'])),
|
|
:deep(select),
|
|
:deep(textarea) {
|
|
border-radius: 30px;
|
|
}
|
|
</style>
|