247 lines
7.3 KiB
Vue
247 lines
7.3 KiB
Vue
<template>
|
|
<div class="page settings-page">
|
|
<div class="settings-shell">
|
|
<n-tabs type="line" animated class="settings-tabs">
|
|
<n-tab-pane name="base" tab="基础设置">
|
|
<div class="settings-base-pane">
|
|
<n-form class="settings-form" label-placement="top">
|
|
<section class="settings-section">
|
|
<div class="section-title">平台信息</div>
|
|
<div class="field-grid two">
|
|
<n-form-item :label="t('pages.settings.appName')">
|
|
<n-input v-model:value="form.appName" class="control-wide" />
|
|
</n-form-item>
|
|
<n-form-item :label="t('pages.settings.watermarkText')">
|
|
<n-input v-model:value="form.watermarkText" class="control-wide" />
|
|
</n-form-item>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="settings-section">
|
|
<div class="section-title">日志与展示</div>
|
|
<div class="field-grid three">
|
|
<n-form-item :label="t('pages.settings.logRetentionDays')">
|
|
<n-input-number v-model:value="form.logRetentionDays" :min="1" class="control-short" />
|
|
</n-form-item>
|
|
<n-form-item :label="t('pages.settings.operationLogRetentionDays')">
|
|
<n-input-number v-model:value="form.operationLogRetentionDays" :min="1" class="control-short" />
|
|
</n-form-item>
|
|
<n-form-item :label="t('pages.settings.carouselInterval')">
|
|
<div class="field-stack">
|
|
<n-input-number
|
|
v-model:value="form.carouselInterval"
|
|
:min="0"
|
|
:max="30"
|
|
:step="0.5"
|
|
:precision="1"
|
|
class="control-short"
|
|
/>
|
|
<span class="field-tip">{{ t('pages.settings.carouselIntervalHint') }}</span>
|
|
</div>
|
|
</n-form-item>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="settings-section">
|
|
<div class="section-title">备份策略</div>
|
|
<div class="field-grid four">
|
|
<n-form-item label="启用定时备份">
|
|
<div class="switch-field"><n-switch v-model:value="form.backupEnabled" /></div>
|
|
</n-form-item>
|
|
<n-form-item label="备份周期">
|
|
<n-select v-model:value="form.backupSchedule" :options="backupScheduleOptions" class="control-short" />
|
|
</n-form-item>
|
|
<n-form-item label="备份保留天数">
|
|
<n-input-number v-model:value="form.backupRetentionDays" :min="1" class="control-short" />
|
|
</n-form-item>
|
|
<n-form-item label="最多保留备份数量">
|
|
<n-input-number v-model:value="form.backupRetentionCount" :min="1" class="control-short" />
|
|
</n-form-item>
|
|
</div>
|
|
</section>
|
|
|
|
<div class="form-actions">
|
|
<n-button type="primary" :loading="saving" @click="save">{{ t('common.action.save') }}</n-button>
|
|
</div>
|
|
</n-form>
|
|
</div>
|
|
</n-tab-pane>
|
|
|
|
<n-tab-pane name="backup" tab="备份与恢复">
|
|
<div class="settings-backup-pane">
|
|
<backup-restore-panel />
|
|
</div>
|
|
</n-tab-pane>
|
|
</n-tabs>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { onMounted, reactive, ref } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { settingsApi } from '@/api';
|
|
import { message } from '@/utils/feedback';
|
|
import BackupRestorePanel from '@/components/BackupRestorePanel.vue';
|
|
|
|
const { t } = useI18n();
|
|
const saving = ref(false);
|
|
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 {
|
|
saving.value = false;
|
|
}
|
|
}
|
|
|
|
onMounted(load);
|
|
</script>
|
|
|
|
<style scoped>
|
|
.settings-page {
|
|
height: var(--admin-content-height);
|
|
min-height: calc(var(--admin-min-height) - var(--admin-header-height) - var(--admin-footer-height));
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
padding: 16px;
|
|
}
|
|
.settings-shell {
|
|
width: 100%;
|
|
height: 100%;
|
|
min-width: 0;
|
|
min-height: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
.settings-tabs {
|
|
flex: 1 1 auto;
|
|
width: 100%;
|
|
min-height: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
.settings-tabs :deep(.n-tabs-pane-wrapper) {
|
|
flex: 1 1 auto;
|
|
min-height: 0;
|
|
padding-top: 12px;
|
|
}
|
|
.settings-tabs :deep(.n-tab-pane) {
|
|
height: 100%;
|
|
min-height: 0;
|
|
}
|
|
.settings-base-pane {
|
|
height: 100%;
|
|
overflow: auto;
|
|
padding-right: 8px;
|
|
}
|
|
.settings-backup-pane {
|
|
height: 100%;
|
|
min-height: 0;
|
|
}
|
|
.settings-form {
|
|
width: min(980px, 100%);
|
|
}
|
|
.settings-section {
|
|
padding: 16px 0 10px;
|
|
border-bottom: 1px solid var(--n-border-color);
|
|
}
|
|
.section-title {
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
margin-bottom: 12px;
|
|
}
|
|
.field-grid {
|
|
display: grid;
|
|
gap: 12px 20px;
|
|
align-items: start;
|
|
}
|
|
.field-grid.two {
|
|
grid-template-columns: repeat(2, minmax(280px, 1fr));
|
|
}
|
|
.field-grid.three {
|
|
grid-template-columns: repeat(3, minmax(180px, 1fr));
|
|
}
|
|
.field-grid.four {
|
|
grid-template-columns: repeat(4, minmax(150px, 1fr));
|
|
}
|
|
.control-wide {
|
|
width: 100%;
|
|
}
|
|
.control-short {
|
|
width: 100%;
|
|
}
|
|
.field-stack {
|
|
width: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 4px;
|
|
}
|
|
.field-tip {
|
|
max-width: 320px;
|
|
font-size: 12px;
|
|
color: #999;
|
|
}
|
|
.switch-field {
|
|
display: flex;
|
|
align-items: center;
|
|
height: 34px;
|
|
}
|
|
.form-actions {
|
|
display: flex;
|
|
justify-content: flex-start;
|
|
padding-top: 18px;
|
|
}
|
|
@media (max-width: 900px) {
|
|
.settings-shell {
|
|
min-width: 0;
|
|
}
|
|
.field-grid.two,
|
|
.field-grid.three,
|
|
.field-grid.four {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
</style>
|