feat: 完善后台导入日志权限与备份恢复
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<n-card :title="t('menu.settings')" :bordered="false" style="max-width: 640px">
|
||||
<n-card :title="t('menu.settings')" :bordered="false" style="max-width: 760px">
|
||||
<n-form label-placement="top">
|
||||
<n-form-item :label="t('pages.settings.appName')">
|
||||
<n-input v-model:value="form.appName" />
|
||||
@@ -8,11 +8,14 @@
|
||||
<n-form-item :label="t('pages.settings.logRetentionDays')">
|
||||
<n-input-number v-model:value="form.logRetentionDays" :min="1" style="width: 220px" />
|
||||
</n-form-item>
|
||||
<n-form-item label="操作日志保留天数">
|
||||
<n-input-number v-model:value="form.operationLogRetentionDays" :min="1" style="width: 220px" />
|
||||
</n-form-item>
|
||||
<n-form-item :label="t('pages.settings.watermarkText')">
|
||||
<n-input v-model:value="form.watermarkText" />
|
||||
</n-form-item>
|
||||
<n-form-item :label="t('pages.settings.carouselInterval')">
|
||||
<div style="display: flex; flex-direction: column; gap: 4px">
|
||||
<div class="field-stack">
|
||||
<n-input-number
|
||||
v-model:value="form.carouselInterval"
|
||||
:min="0"
|
||||
@@ -21,9 +24,24 @@
|
||||
:precision="1"
|
||||
style="width: 220px"
|
||||
/>
|
||||
<span style="font-size: 12px; color: #999">{{ t('pages.settings.carouselIntervalHint') }}</span>
|
||||
<span class="field-tip">{{ t('pages.settings.carouselIntervalHint') }}</span>
|
||||
</div>
|
||||
</n-form-item>
|
||||
|
||||
<n-divider>备份策略</n-divider>
|
||||
<n-form-item label="启用定时备份">
|
||||
<n-switch v-model:value="form.backupEnabled" />
|
||||
</n-form-item>
|
||||
<n-form-item label="备份周期">
|
||||
<n-select v-model:value="form.backupSchedule" :options="backupScheduleOptions" style="width: 220px" />
|
||||
</n-form-item>
|
||||
<n-form-item label="备份保留天数">
|
||||
<n-input-number v-model:value="form.backupRetentionDays" :min="1" style="width: 220px" />
|
||||
</n-form-item>
|
||||
<n-form-item label="最多保留备份数量">
|
||||
<n-input-number v-model:value="form.backupRetentionCount" :min="1" style="width: 220px" />
|
||||
</n-form-item>
|
||||
|
||||
<n-button type="primary" :loading="saving" @click="save">{{ t('common.action.save') }}</n-button>
|
||||
</n-form>
|
||||
</n-card>
|
||||
@@ -38,33 +56,48 @@ import { message } from '@/utils/feedback';
|
||||
|
||||
const { t } = useI18n();
|
||||
const saving = ref(false);
|
||||
const form = reactive<{
|
||||
appName: string;
|
||||
logRetentionDays: number;
|
||||
watermarkText: string;
|
||||
carouselInterval: number;
|
||||
}>({
|
||||
const backupScheduleOptions = [
|
||||
{ label: '每天', value: 'daily' },
|
||||
{ label: '每周', value: 'weekly' },
|
||||
];
|
||||
const form = reactive({
|
||||
appName: '',
|
||||
logRetentionDays: 365,
|
||||
operationLogRetentionDays: 180,
|
||||
watermarkText: '',
|
||||
carouselInterval: 3,
|
||||
backupEnabled: false,
|
||||
backupSchedule: 'daily',
|
||||
backupRetentionDays: 30,
|
||||
backupRetentionCount: 10,
|
||||
});
|
||||
|
||||
async function load() {
|
||||
const s = await settingsApi.getAll();
|
||||
form.appName = s.appName || '';
|
||||
form.logRetentionDays = Number(s.logRetentionDays || 365);
|
||||
form.operationLogRetentionDays = Number(s.operationLogRetentionDays || 180);
|
||||
form.watermarkText = s.watermarkText || '';
|
||||
form.carouselInterval = Number(s.carouselInterval ?? 3);
|
||||
form.backupEnabled = s.backupEnabled === 'true';
|
||||
form.backupSchedule = s.backupSchedule || 'daily';
|
||||
form.backupRetentionDays = Number(s.backupRetentionDays || 30);
|
||||
form.backupRetentionCount = Number(s.backupRetentionCount || 10);
|
||||
}
|
||||
|
||||
async function save() {
|
||||
saving.value = true;
|
||||
try {
|
||||
await settingsApi.update({
|
||||
appName: form.appName,
|
||||
logRetentionDays: String(form.logRetentionDays),
|
||||
operationLogRetentionDays: String(form.operationLogRetentionDays),
|
||||
watermarkText: form.watermarkText,
|
||||
carouselInterval: String(form.carouselInterval),
|
||||
backupEnabled: String(form.backupEnabled),
|
||||
backupSchedule: form.backupSchedule,
|
||||
backupRetentionDays: String(form.backupRetentionDays),
|
||||
backupRetentionCount: String(form.backupRetentionCount),
|
||||
});
|
||||
message.success(t('pages.settings.saved'));
|
||||
} finally {
|
||||
@@ -73,3 +106,15 @@ async function save() {
|
||||
}
|
||||
onMounted(load);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.field-stack {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
.field-tip {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user