fix: 优化后台列表与系统设置布局
This commit is contained in:
@@ -1,234 +0,0 @@
|
||||
<template>
|
||||
<div class="page table-page backups-page">
|
||||
<div class="page-toolbar">
|
||||
<n-button type="primary" :loading="creating" @click="createBackup">创建备份</n-button>
|
||||
<n-upload :show-file-list="false" accept=".zip" :custom-request="previewRestore" :disabled="restoring">
|
||||
<n-button :loading="restoring">上传备份包预校验</n-button>
|
||||
</n-upload>
|
||||
<div class="spacer" />
|
||||
<n-button @click="load">刷新</n-button>
|
||||
</div>
|
||||
|
||||
<n-alert v-if="restorePreviewResult" type="warning" class="restore-alert" :show-icon="true">
|
||||
已通过备份包预校验:{{ restorePreviewResult.manifest?.createdAt || '-' }}。
|
||||
恢复会整库覆盖当前系统,确认前会自动生成当前快照。
|
||||
<n-button size="small" type="error" :loading="restoring" @click="commitRestore">确认恢复</n-button>
|
||||
</n-alert>
|
||||
|
||||
<n-data-table
|
||||
:columns="columns"
|
||||
:data="rows"
|
||||
:loading="loading"
|
||||
:pagination="false"
|
||||
class="table-fill"
|
||||
flex-height
|
||||
remote
|
||||
:scroll-x="1280"
|
||||
:row-key="(r) => r.id"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, h, onMounted, reactive, ref } from 'vue';
|
||||
import type { UploadCustomRequestOptions } from 'naive-ui';
|
||||
import { NButton, NDropdown, NIcon, NTag, type DataTableColumns, type DropdownOption } from 'naive-ui';
|
||||
import { DownloadOutline, FilterOutline, TrashOutline } from '@vicons/ionicons5';
|
||||
import { backupApi } from '@/api';
|
||||
import { dialog, message } from '@/utils/feedback';
|
||||
import { downloadFile } from '@/utils/download';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const creating = ref(false);
|
||||
const restoring = ref(false);
|
||||
const restorePreviewResult = ref<any>(null);
|
||||
const query = reactive({ status: null as string | null, mode: null as string | null });
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load, 20);
|
||||
|
||||
const statusOptions = ['PENDING', 'PROCESSING', 'SUCCESS', 'FAILED'].map((value) => ({ label: value, value }));
|
||||
const modeOptions = ['BACKUP', 'RESTORE', 'SCHEDULED', 'AUTO_BEFORE_RESTORE'].map((value) => ({ label: value, value }));
|
||||
|
||||
const columns = computed<DataTableColumns<any>>(() => [
|
||||
{ title: '创建时间', key: 'createdAt', width: 170, render: (row) => fmt(row.createdAt) },
|
||||
{ title: '文件名', key: 'fileName', minWidth: 260, ellipsis: { tooltip: true } },
|
||||
{
|
||||
title: () => renderFilterTitle('类型', query.mode, modeOptions, (value) => setFilter('mode', value)),
|
||||
key: 'mode',
|
||||
width: 170,
|
||||
},
|
||||
{
|
||||
title: () => renderFilterTitle('状态', query.status, statusOptions, (value) => setFilter('status', value)),
|
||||
key: 'status',
|
||||
width: 130,
|
||||
align: 'center',
|
||||
render: (row) => h(NTag, { size: 'small', type: statusType(row.status) }, { default: () => row.status }),
|
||||
},
|
||||
{ title: '大小', key: 'size', width: 120, render: (row) => formatSize(row.size) },
|
||||
{ title: '错误', key: 'error', minWidth: 260, ellipsis: { tooltip: true }, render: (row) => row.error || '-' },
|
||||
{
|
||||
title: '操作',
|
||||
key: 'ops',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
render: (row) =>
|
||||
h('div', { class: 'row-actions' }, [
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
quaternary: true,
|
||||
circle: true,
|
||||
size: 'small',
|
||||
disabled: row.status !== 'SUCCESS',
|
||||
title: '下载',
|
||||
onClick: () => downloadBackup(row),
|
||||
},
|
||||
{ icon: () => h(NIcon, null, { default: () => h(DownloadOutline) }) },
|
||||
),
|
||||
h(
|
||||
NButton,
|
||||
{ quaternary: true, circle: true, size: 'small', type: 'error', title: '删除', onClick: () => removeBackup(row) },
|
||||
{ icon: () => h(NIcon, null, { default: () => h(TrashOutline) }) },
|
||||
),
|
||||
]),
|
||||
},
|
||||
]);
|
||||
|
||||
function renderFilterTitle(label: string, value: string | null, options: { label: string; value: string }[], onSelect: (value: string | null) => void) {
|
||||
const dropdownOptions: DropdownOption[] = [{ label: '全部', key: '__all__' }, ...options.map((item) => ({ label: item.label, key: item.value }))];
|
||||
return h('div', { class: 'filter-title' }, [
|
||||
h('span', { class: 'filter-title-text' }, label),
|
||||
h(
|
||||
NDropdown,
|
||||
{ trigger: 'click', options: dropdownOptions, onSelect: (key) => onSelect(key === '__all__' ? null : String(key)) },
|
||||
{
|
||||
default: () =>
|
||||
h(
|
||||
NButton,
|
||||
{ quaternary: true, circle: true, size: 'tiny', class: ['filter-trigger', { active: !!value }], title: '筛选' },
|
||||
{ icon: () => h(NIcon, null, { default: () => h(FilterOutline) }) },
|
||||
),
|
||||
},
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
function setFilter(field: 'status' | 'mode', value: string | null) {
|
||||
query[field] = value;
|
||||
resetPage();
|
||||
void load();
|
||||
}
|
||||
|
||||
function formatSize(value: unknown) {
|
||||
const n = Number(value || 0);
|
||||
if (!n) return '-';
|
||||
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
|
||||
return `${(n / 1024 / 1024).toFixed(1)} MB`;
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res: any = await backupApi.list({
|
||||
status: query.status || undefined,
|
||||
mode: query.mode || undefined,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
});
|
||||
rows.value = res.list;
|
||||
setPageResult(res);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function createBackup() {
|
||||
creating.value = true;
|
||||
try {
|
||||
await backupApi.create();
|
||||
message.success('备份已创建');
|
||||
await load();
|
||||
} finally {
|
||||
creating.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadBackup(row: any) {
|
||||
await downloadFile(`/backups/${row.id}/download`, row.fileName || 'artveris-backup.zip');
|
||||
}
|
||||
|
||||
function removeBackup(row: any) {
|
||||
dialog.warning({
|
||||
title: '删除备份',
|
||||
content: '确认删除该备份记录和服务器上的备份包?',
|
||||
positiveText: '确认',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
await backupApi.remove(row.id);
|
||||
message.success('已删除');
|
||||
await load();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function previewRestore({ file, onFinish, onError }: UploadCustomRequestOptions) {
|
||||
restoring.value = true;
|
||||
try {
|
||||
const fd = new FormData();
|
||||
fd.append('file', file.file as File);
|
||||
restorePreviewResult.value = await backupApi.restorePreview(fd);
|
||||
message.success('备份包预校验通过');
|
||||
await load();
|
||||
onFinish();
|
||||
} catch (e) {
|
||||
message.error((e as Error)?.message || '预校验失败');
|
||||
onError();
|
||||
} finally {
|
||||
restoring.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function commitRestore() {
|
||||
if (!restorePreviewResult.value?.restoreId) return;
|
||||
dialog.warning({
|
||||
title: '确认恢复',
|
||||
content: '恢复会覆盖当前数据库和上传文件。系统会先自动备份当前状态,确认继续?',
|
||||
positiveText: '确认恢复',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
restoring.value = true;
|
||||
try {
|
||||
await backupApi.restoreCommit(restorePreviewResult.value.restoreId);
|
||||
restorePreviewResult.value = null;
|
||||
message.success('恢复完成,请重新检查数据');
|
||||
await load();
|
||||
} finally {
|
||||
restoring.value = false;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(load);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.backups-page {
|
||||
min-width: 0;
|
||||
}
|
||||
.restore-alert {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.restore-alert :deep(.n-alert-body__content) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
</style>
|
||||
@@ -11,7 +11,7 @@
|
||||
:data="rows"
|
||||
:loading="loading"
|
||||
:pagination="false"
|
||||
class="table-fill"
|
||||
class="table-fill operation-log-table"
|
||||
flex-height
|
||||
remote
|
||||
:scroll-x="1460"
|
||||
@@ -60,18 +60,20 @@ const resultOptions = [
|
||||
];
|
||||
|
||||
const columns = computed<DataTableColumns<any>>(() => [
|
||||
{ title: '时间', key: 'createdAt', width: 170, render: (row) => fmt(row.createdAt) },
|
||||
{ title: '账号', key: 'username', width: 130, render: (row) => row.username || '-' },
|
||||
{ title: '角色', key: 'role', width: 120 },
|
||||
{ title: '时间', key: 'createdAt', width: 170, ellipsis: { tooltip: true }, render: (row) => fmt(row.createdAt) },
|
||||
{ title: '账号', key: 'username', width: 130, ellipsis: { tooltip: true }, render: (row) => row.username || '-' },
|
||||
{ title: '角色', key: 'role', width: 130, ellipsis: { tooltip: true } },
|
||||
{
|
||||
title: () => renderFilterTitle('模块', query.module, moduleOptions, (value) => setFilter('module', value)),
|
||||
key: 'module',
|
||||
width: 140,
|
||||
ellipsis: { tooltip: true },
|
||||
},
|
||||
{
|
||||
title: () => renderFilterTitle('操作', query.action, actionOptions, (value) => setFilter('action', value)),
|
||||
key: 'action',
|
||||
width: 110,
|
||||
ellipsis: { tooltip: true },
|
||||
},
|
||||
{
|
||||
title: () => renderFilterTitle('结果', query.status, resultOptions, (value) => setFilter('status', value)),
|
||||
@@ -83,7 +85,7 @@ const columns = computed<DataTableColumns<any>>(() => [
|
||||
{ title: '目标 ID', key: 'targetId', width: 150, ellipsis: { tooltip: true }, render: (row) => row.targetId || '-' },
|
||||
{ title: '路径', key: 'path', width: 260, ellipsis: { tooltip: true } },
|
||||
{ title: 'IP', key: 'ip', width: 150, ellipsis: { tooltip: true } },
|
||||
{ title: '耗时', key: 'durationMs', width: 90, render: (row) => `${row.durationMs || 0}ms` },
|
||||
{ title: '耗时', key: 'durationMs', width: 90, ellipsis: { tooltip: true }, render: (row) => `${row.durationMs || 0}ms` },
|
||||
{ title: '消息', key: 'message', minWidth: 260, ellipsis: { tooltip: true }, render: (row) => row.message || '-' },
|
||||
]);
|
||||
|
||||
@@ -142,3 +144,9 @@ function onSearch() {
|
||||
watch(range, onSearch);
|
||||
onMounted(load);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.operation-log-table :deep(.n-data-table-td) {
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,80 +1,77 @@
|
||||
<template>
|
||||
<div class="page table-page outbound-page">
|
||||
<n-card :bordered="false" class="outbound-card">
|
||||
<template #header>出库批量导入</template>
|
||||
<template #header-extra>
|
||||
<n-space>
|
||||
<n-button @click="downloadTemplate">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
下载 ZIP 模板
|
||||
</n-button>
|
||||
<n-upload
|
||||
:show-file-list="false"
|
||||
accept=".zip"
|
||||
:custom-request="uploadPreview"
|
||||
:disabled="busy || !auth.canWrite"
|
||||
>
|
||||
<n-button type="primary" :loading="previewing">
|
||||
<template #icon><n-icon :component="CloudUploadOutline" /></template>
|
||||
上传 ZIP 并预览
|
||||
</n-button>
|
||||
</n-upload>
|
||||
</n-space>
|
||||
</template>
|
||||
<div class="page-toolbar outbound-toolbar">
|
||||
<div class="section-title">出库批量导入</div>
|
||||
<div class="spacer" />
|
||||
<n-button @click="downloadTemplate">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
下载 ZIP 模板
|
||||
</n-button>
|
||||
<n-upload
|
||||
:show-file-list="false"
|
||||
accept=".zip"
|
||||
:custom-request="uploadPreview"
|
||||
:disabled="busy || !auth.canWrite"
|
||||
>
|
||||
<n-button type="primary" :loading="previewing">
|
||||
<template #icon><n-icon :component="CloudUploadOutline" /></template>
|
||||
上传 ZIP 并预览
|
||||
</n-button>
|
||||
</n-upload>
|
||||
</div>
|
||||
|
||||
<n-alert type="info" :show-icon="true" class="section-alert">
|
||||
ZIP 内需要包含 1 个 xlsx 文件和 images 文件夹;xlsx 中出库实况图路径填写 images/xxx.jpg,多张用英文分号分隔。
|
||||
</n-alert>
|
||||
<n-alert type="info" :show-icon="true" class="section-alert">
|
||||
ZIP 内需要包含 1 个 xlsx 文件和 images 文件夹;xlsx 中出库实况图路径填写 images/xxx.jpg,多张用英文分号分隔。
|
||||
</n-alert>
|
||||
|
||||
<n-card v-if="session" embedded class="summary-card" :bordered="false">
|
||||
<n-space align="center" size="large" wrap>
|
||||
<n-statistic label="总行数" :value="session.total || 0" />
|
||||
<n-statistic label="有效行">
|
||||
<span class="success-text">{{ session.validCount || 0 }}</span>
|
||||
</n-statistic>
|
||||
<n-statistic label="错误行">
|
||||
<span class="danger-text">{{ session.invalidCount || 0 }}</span>
|
||||
</n-statistic>
|
||||
<n-tag :type="statusType(session.status)">{{ session.status }}</n-tag>
|
||||
<n-progress
|
||||
v-if="busy"
|
||||
type="line"
|
||||
:percentage="progressPercent"
|
||||
:indicator-placement="'inside'"
|
||||
class="progress"
|
||||
/>
|
||||
<n-button
|
||||
v-if="auth.canWrite"
|
||||
type="primary"
|
||||
:disabled="!canCommit"
|
||||
:loading="committing"
|
||||
@click="commitImport"
|
||||
>
|
||||
确认导入
|
||||
</n-button>
|
||||
<n-button v-if="result?.resultFileUrl" tag="a" :href="result.resultFileUrl" target="_blank">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
下载导入结果
|
||||
</n-button>
|
||||
</n-space>
|
||||
<n-text v-if="session.error" type="error" class="session-error">{{ session.error }}</n-text>
|
||||
</n-card>
|
||||
|
||||
<n-data-table
|
||||
:columns="columns"
|
||||
:data="rows"
|
||||
:loading="loading"
|
||||
:pagination="false"
|
||||
class="table-fill"
|
||||
flex-height
|
||||
remote
|
||||
:scroll-x="1320"
|
||||
:row-key="(r) => r.id"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
</div>
|
||||
<n-card v-if="session" embedded class="summary-card" :bordered="false">
|
||||
<n-space align="center" size="large" wrap>
|
||||
<n-statistic label="总行数" :value="session.total || 0" />
|
||||
<n-statistic label="有效行">
|
||||
<span class="success-text">{{ session.validCount || 0 }}</span>
|
||||
</n-statistic>
|
||||
<n-statistic label="错误行">
|
||||
<span class="danger-text">{{ session.invalidCount || 0 }}</span>
|
||||
</n-statistic>
|
||||
<n-tag :type="statusType(session.status)">{{ session.status }}</n-tag>
|
||||
<n-progress
|
||||
v-if="busy"
|
||||
type="line"
|
||||
:percentage="progressPercent"
|
||||
:indicator-placement="'inside'"
|
||||
class="progress"
|
||||
/>
|
||||
<n-button
|
||||
v-if="auth.canWrite"
|
||||
type="primary"
|
||||
:disabled="!canCommit"
|
||||
:loading="committing"
|
||||
@click="commitImport"
|
||||
>
|
||||
确认导入
|
||||
</n-button>
|
||||
<n-button v-if="result?.resultFileUrl" tag="a" :href="result.resultFileUrl" target="_blank">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
下载导入结果
|
||||
</n-button>
|
||||
</n-space>
|
||||
<n-text v-if="session.error" type="error" class="session-error">{{ session.error }}</n-text>
|
||||
</n-card>
|
||||
|
||||
<n-data-table
|
||||
:columns="columns"
|
||||
:data="rows"
|
||||
:loading="loading"
|
||||
:pagination="false"
|
||||
class="table-fill"
|
||||
flex-height
|
||||
remote
|
||||
:scroll-x="1320"
|
||||
:row-key="(r) => r.id"
|
||||
/>
|
||||
<div class="table-pagination">
|
||||
<n-pagination v-bind="pagination" :disabled="loading" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -267,20 +264,20 @@ async function loadRows() {
|
||||
.outbound-page {
|
||||
min-width: 0;
|
||||
}
|
||||
.outbound-card {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.outbound-toolbar {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.outbound-card :deep(.n-card__content) {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.outbound-toolbar :deep(.n-upload) {
|
||||
width: auto;
|
||||
}
|
||||
.section-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.section-alert {
|
||||
margin-bottom: 12px;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
.summary-card {
|
||||
margin-bottom: 12px;
|
||||
|
||||
@@ -1,50 +1,79 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<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" />
|
||||
</n-form-item>
|
||||
<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 class="field-stack">
|
||||
<n-input-number
|
||||
v-model:value="form.carouselInterval"
|
||||
:min="0"
|
||||
:max="30"
|
||||
:step="0.5"
|
||||
:precision="1"
|
||||
style="width: 220px"
|
||||
/>
|
||||
<span class="field-tip">{{ t('pages.settings.carouselIntervalHint') }}</span>
|
||||
<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="操作日志保留天数">
|
||||
<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-form-item>
|
||||
</n-tab-pane>
|
||||
|
||||
<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>
|
||||
<n-tab-pane name="backup" tab="备份与恢复">
|
||||
<div class="settings-backup-pane">
|
||||
<backup-restore-panel />
|
||||
</div>
|
||||
</n-tab-pane>
|
||||
</n-tabs>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -53,6 +82,7 @@ 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);
|
||||
@@ -104,17 +134,113 @@ async function save() {
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user