fix: 完善平台国际化覆盖
This commit is contained in:
@@ -19,6 +19,19 @@ const instance: AxiosInstance = axios.create({
|
||||
timeout: 30000,
|
||||
});
|
||||
|
||||
function resolveErrorMessage(body: any, fallbackKey = 'common.msg.networkError'): string {
|
||||
if (body?.code !== undefined && body?.code !== null) {
|
||||
const key = `common.errorCode.${body.code}`;
|
||||
const translated = i18n.global.t(key);
|
||||
if (translated !== key) return translated;
|
||||
}
|
||||
const rawMessage = body?.message;
|
||||
if (typeof rawMessage === 'string' && (i18n.global.locale.value !== 'en-US' || !/[\u3400-\u9fff]/.test(rawMessage))) {
|
||||
return rawMessage;
|
||||
}
|
||||
return i18n.global.t(fallbackKey);
|
||||
}
|
||||
|
||||
instance.interceptors.request.use((config) => {
|
||||
const token = getToken();
|
||||
if (token) {
|
||||
@@ -39,7 +52,7 @@ instance.interceptors.response.use(
|
||||
if (body.code === 0) {
|
||||
return body.data;
|
||||
}
|
||||
message.error(body.message || i18n.global.t('common.msg.networkError'));
|
||||
message.error(resolveErrorMessage(body));
|
||||
return Promise.reject(body);
|
||||
}
|
||||
return body;
|
||||
@@ -49,12 +62,12 @@ instance.interceptors.response.use(
|
||||
const body = error?.response?.data;
|
||||
if (status === 401) {
|
||||
clearToken();
|
||||
message.error(body?.message || i18n.global.t('common.msg.loginExpired'));
|
||||
message.error(resolveErrorMessage(body, 'common.msg.loginExpired'));
|
||||
if (location.hash.indexOf('/login') === -1) {
|
||||
location.hash = '#/login';
|
||||
}
|
||||
} else {
|
||||
message.error(body?.message || i18n.global.t('common.msg.networkError'));
|
||||
message.error(resolveErrorMessage(body));
|
||||
}
|
||||
return Promise.reject(error);
|
||||
},
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
<template>
|
||||
<div class="backup-panel">
|
||||
<div class="backup-toolbar">
|
||||
<n-button type="primary" :loading="creating" @click="createBackup">创建备份</n-button>
|
||||
<n-button type="primary" :loading="creating" @click="createBackup">{{ t('pages.backup.create') }}</n-button>
|
||||
<n-upload :show-file-list="false" accept=".zip" :custom-request="previewRestore" :disabled="restoring">
|
||||
<n-button :loading="restoring">上传备份包预校验</n-button>
|
||||
<n-button :loading="restoring">{{ t('pages.backup.uploadPreview') }}</n-button>
|
||||
</n-upload>
|
||||
<n-button @click="load">刷新</n-button>
|
||||
<n-button @click="load">{{ t('common.action.refresh') }}</n-button>
|
||||
</div>
|
||||
|
||||
<n-alert v-if="restorePreviewResult" type="warning" class="restore-alert" :show-icon="true">
|
||||
<div class="restore-content">
|
||||
<span>
|
||||
已通过备份包预校验:{{ restorePreviewResult.manifest?.createdAt || '-' }}。恢复会整库覆盖当前系统,确认前会自动生成当前快照。
|
||||
{{ t('pages.backup.previewPassed', { time: restorePreviewResult.manifest?.createdAt || '-' }) }}
|
||||
</span>
|
||||
<n-button size="small" type="error" :loading="restoring" @click="commitRestore">确认恢复</n-button>
|
||||
<n-button size="small" type="error" :loading="restoring" @click="commitRestore">{{ t('pages.backup.confirmRestore') }}</n-button>
|
||||
</div>
|
||||
</n-alert>
|
||||
|
||||
@@ -37,16 +37,19 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, h, onMounted, reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
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 { NButton, NIcon, NTag, type DataTableColumns } from 'naive-ui';
|
||||
import { DownloadOutline, 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';
|
||||
import { useRemoteSort } from '@/utils/tableSort';
|
||||
import { renderTableFilterTitle } from '@/utils/tableFilter';
|
||||
|
||||
const { t } = useI18n();
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const creating = ref(false);
|
||||
@@ -59,29 +62,30 @@ const { sortProps, onSorterChange, sortParams } = useRemoteSort(() => {
|
||||
return load();
|
||||
});
|
||||
|
||||
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 statusOptions = computed(() => ['PENDING', 'PROCESSING', 'SUCCESS', 'FAILED'].map((value) => ({ label: t(`common.status.${value}`), value })));
|
||||
const modeOptions = computed(() => ['BACKUP', 'RESTORE', 'SCHEDULED', 'AUTO_BEFORE_RESTORE'].map((value) => ({ label: t(`pages.backup.mode.${value}`), value })));
|
||||
|
||||
const columns = computed<DataTableColumns<any>>(() => [
|
||||
{ title: '创建时间', key: 'createdAt', width: 170, align: 'center', render: (row) => fmt(row.createdAt), ...sortProps('createdAt') },
|
||||
{ title: '文件名', key: 'fileName', minWidth: 360, ellipsis: { tooltip: true } },
|
||||
{ title: t('common.label.createdAt'), key: 'createdAt', width: 170, align: 'center', render: (row) => fmt(row.createdAt), ...sortProps('createdAt') },
|
||||
{ title: t('pages.backup.fileName'), key: 'fileName', minWidth: 360, ellipsis: { tooltip: true } },
|
||||
{
|
||||
title: () => renderFilterTitle('类型', query.mode, modeOptions, (value) => setFilter('mode', value)),
|
||||
title: () => renderTableFilterTitle(t('common.label.type'), query.mode, modeOptions.value, (value) => setFilter('mode', value ? String(value) : null)),
|
||||
key: 'mode',
|
||||
width: 170,
|
||||
align: 'center',
|
||||
render: (row) => t(`pages.backup.mode.${row.mode}`),
|
||||
},
|
||||
{
|
||||
title: () => renderFilterTitle('状态', query.status, statusOptions, (value) => setFilter('status', value)),
|
||||
title: () => renderTableFilterTitle(t('common.label.status'), query.status, statusOptions.value, (value) => setFilter('status', value ? String(value) : null)),
|
||||
key: 'status',
|
||||
width: 130,
|
||||
align: 'center',
|
||||
render: (row) => h(NTag, { size: 'small', type: statusType(row.status) }, { default: () => row.status }),
|
||||
render: (row) => h(NTag, { size: 'small', type: statusType(row.status) }, { default: () => t(`common.status.${row.status}`) }),
|
||||
},
|
||||
{ title: '大小', key: 'size', width: 120, align: 'center', render: (row) => formatSize(row.size) },
|
||||
{ title: '错误', key: 'error', minWidth: 320, ellipsis: { tooltip: true }, render: (row) => row.error || '-' },
|
||||
{ title: t('pages.backup.size'), key: 'size', width: 120, align: 'center', render: (row) => formatSize(row.size) },
|
||||
{ title: t('pages.backup.error'), key: 'error', minWidth: 320, ellipsis: { tooltip: true }, render: (row) => row.error || '-' },
|
||||
{
|
||||
title: '操作',
|
||||
title: t('common.label.operation'),
|
||||
key: 'ops',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
@@ -95,39 +99,20 @@ const columns = computed<DataTableColumns<any>>(() => [
|
||||
circle: true,
|
||||
size: 'small',
|
||||
disabled: row.status !== 'SUCCESS',
|
||||
title: '下载',
|
||||
title: t('common.action.download'),
|
||||
onClick: () => downloadBackup(row),
|
||||
},
|
||||
{ icon: () => h(NIcon, null, { default: () => h(DownloadOutline) }) },
|
||||
),
|
||||
h(
|
||||
NButton,
|
||||
{ quaternary: true, circle: true, size: 'small', type: 'error', title: '删除', onClick: () => removeBackup(row) },
|
||||
{ quaternary: true, circle: true, size: 'small', type: 'error', title: t('common.action.delete'), 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();
|
||||
@@ -162,7 +147,7 @@ async function createBackup() {
|
||||
creating.value = true;
|
||||
try {
|
||||
await backupApi.create();
|
||||
message.success('备份已创建');
|
||||
message.success(t('pages.backup.created'));
|
||||
await load();
|
||||
} finally {
|
||||
creating.value = false;
|
||||
@@ -175,13 +160,13 @@ async function downloadBackup(row: any) {
|
||||
|
||||
function removeBackup(row: any) {
|
||||
dialog.warning({
|
||||
title: '删除备份',
|
||||
content: '确认删除该备份记录和服务器上的备份包?',
|
||||
positiveText: '确认',
|
||||
negativeText: '取消',
|
||||
title: t('pages.backup.deleteTitle'),
|
||||
content: t('pages.backup.deleteConfirm'),
|
||||
positiveText: t('common.action.confirm'),
|
||||
negativeText: t('common.action.cancel'),
|
||||
onPositiveClick: async () => {
|
||||
await backupApi.remove(row.id);
|
||||
message.success('已删除');
|
||||
message.success(t('common.msg.deleted'));
|
||||
await load();
|
||||
},
|
||||
});
|
||||
@@ -193,11 +178,11 @@ async function previewRestore({ file, onFinish, onError }: UploadCustomRequestOp
|
||||
const fd = new FormData();
|
||||
fd.append('file', file.file as File);
|
||||
restorePreviewResult.value = await backupApi.restorePreview(fd);
|
||||
message.success('备份包预校验通过');
|
||||
message.success(t('pages.backup.previewSuccess'));
|
||||
await load();
|
||||
onFinish();
|
||||
} catch (e) {
|
||||
message.error((e as Error)?.message || '预校验失败');
|
||||
} catch {
|
||||
message.error(t('pages.backup.previewFailed'));
|
||||
onError();
|
||||
} finally {
|
||||
restoring.value = false;
|
||||
@@ -207,16 +192,16 @@ async function previewRestore({ file, onFinish, onError }: UploadCustomRequestOp
|
||||
function commitRestore() {
|
||||
if (!restorePreviewResult.value?.restoreId) return;
|
||||
dialog.warning({
|
||||
title: '确认恢复',
|
||||
content: '恢复会覆盖当前数据库和上传文件。系统会先自动备份当前状态,确认继续?',
|
||||
positiveText: '确认恢复',
|
||||
negativeText: '取消',
|
||||
title: t('pages.backup.restoreTitle'),
|
||||
content: t('pages.backup.restoreConfirm'),
|
||||
positiveText: t('pages.backup.confirmRestore'),
|
||||
negativeText: t('common.action.cancel'),
|
||||
onPositiveClick: async () => {
|
||||
restoring.value = true;
|
||||
try {
|
||||
await backupApi.restoreCommit(restorePreviewResult.value.restoreId);
|
||||
restorePreviewResult.value = null;
|
||||
message.success('恢复完成,请重新检查数据');
|
||||
message.success(t('pages.backup.restoreDone'));
|
||||
await load();
|
||||
} finally {
|
||||
restoring.value = false;
|
||||
|
||||
@@ -106,8 +106,8 @@ async function uploadOne(file: File) {
|
||||
...list.value,
|
||||
{ key: res.key, url: res.url, name: props.captionable ? '' : res.name, type },
|
||||
]);
|
||||
} catch (err) {
|
||||
message.error((err as Error)?.message || 'upload failed');
|
||||
} catch {
|
||||
message.error(t('common.msg.uploadFailed'));
|
||||
} finally {
|
||||
uploading.value = uploading.value.filter((u) => u.id !== holder.id);
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ async function uploadOne(file: File) {
|
||||
...items.value,
|
||||
{ key: res.key, url: res.url, name: res.name || file.name, type: props.type },
|
||||
]);
|
||||
} catch (err: any) {
|
||||
message.error(err?.message || 'upload failed');
|
||||
} catch {
|
||||
message.error(t('common.msg.uploadFailed'));
|
||||
} finally {
|
||||
uploading.value = uploading.value.filter((u) => u.id !== holder.id);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ function onUser(key: string) {
|
||||
} else if (key === 'logout') {
|
||||
dialog.warning({
|
||||
title: t('common.action.logout'),
|
||||
content: '确定退出登录?',
|
||||
content: t('common.msg.logoutConfirm'),
|
||||
positiveText: t('common.action.confirm'),
|
||||
negativeText: t('common.action.cancel'),
|
||||
onPositiveClick: () => {
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
"apply": "Apply",
|
||||
"open": "Open",
|
||||
"changePassword": "Change Password",
|
||||
"logout": "Logout"
|
||||
"logout": "Logout",
|
||||
"filter": "Filter"
|
||||
},
|
||||
"label": {
|
||||
"keyword": "Keyword",
|
||||
@@ -118,7 +119,38 @@
|
||||
"loginExpired": "Session expired, please log in again",
|
||||
"networkError": "Network error, please try again",
|
||||
"noData": "No data",
|
||||
"maxReached": "Up to {n} files"
|
||||
"maxReached": "Up to {n} files",
|
||||
"uploadFailed": "Upload failed",
|
||||
"logoutConfirm": "Are you sure you want to log out?"
|
||||
},
|
||||
"errorCode": {
|
||||
"1000": "Invalid request",
|
||||
"1001": "Not logged in or session expired",
|
||||
"1002": "You do not have permission",
|
||||
"1003": "Resource not found",
|
||||
"1004": "Validation failed",
|
||||
"1005": "Internal server error",
|
||||
"1006": "Too many requests. Please try again later.",
|
||||
"2001": "Incorrect username or password",
|
||||
"2002": "Session expired. Please log in again.",
|
||||
"2003": "This account has been disabled",
|
||||
"2004": "Current password is incorrect",
|
||||
"2005": "Username already exists",
|
||||
"3001": "Template not found",
|
||||
"3002": "Template is in use and cannot be deleted",
|
||||
"3003": "Artwork not found",
|
||||
"3004": "Trace code not found",
|
||||
"3005": "Trace code is invalid",
|
||||
"3006": "Trace code has been disabled",
|
||||
"3007": "Trace code status is abnormal",
|
||||
"3008": "Trace code is already bound to an artwork",
|
||||
"3009": "Import file parsing failed",
|
||||
"3010": "File type is not supported",
|
||||
"3011": "File exceeds the size limit",
|
||||
"3012": "Certificate not found",
|
||||
"3013": "Task not found",
|
||||
"3014": "Batch not found",
|
||||
"3015": "Artwork file has business data and cannot be deleted"
|
||||
},
|
||||
"lang": { "zh": "Simplified Chinese", "en": "English" }
|
||||
},
|
||||
@@ -289,6 +321,7 @@
|
||||
"assignGroup": "Assign group"
|
||||
},
|
||||
"outbound": {
|
||||
"batchImportTitle": "Outbound Batch Import",
|
||||
"import": "Batch Import",
|
||||
"outTime": "Outbound Time",
|
||||
"outImage": "Outbound Photo",
|
||||
@@ -314,7 +347,21 @@
|
||||
"errorReason": "Error",
|
||||
"previewReady": "Preview parsed",
|
||||
"uploadFailed": "Upload failed",
|
||||
"importDone": "Import completed"
|
||||
"importDone": "Import completed",
|
||||
"rowStatus": {
|
||||
"VALID": "Valid",
|
||||
"INVALID": "Invalid",
|
||||
"IMPORTED": "Imported",
|
||||
"FAILED": "Failed"
|
||||
},
|
||||
"sessionStatus": {
|
||||
"PARSING": "Parsing",
|
||||
"READY": "Ready",
|
||||
"IMPORTING": "Importing",
|
||||
"IMPORTED": "Imported",
|
||||
"FAILED": "Failed",
|
||||
"EXPIRED": "Expired"
|
||||
}
|
||||
},
|
||||
"blockchain": {
|
||||
"title": "Blockchain Attestation",
|
||||
@@ -346,6 +393,10 @@
|
||||
"lastLoginAt": "Last Login"
|
||||
},
|
||||
"settings": {
|
||||
"baseSettings": "Basic Settings",
|
||||
"platformInfo": "Platform Info",
|
||||
"logAndDisplay": "Logs & Display",
|
||||
"backupPolicy": "Backup Policy",
|
||||
"appName": "Platform Name",
|
||||
"appIcon": "System Icon",
|
||||
"logRetentionDays": "Query Log Retention (days)",
|
||||
@@ -354,6 +405,12 @@
|
||||
"filingInfo": "Filing Info",
|
||||
"carouselInterval": "Client Carousel Interval (s)",
|
||||
"carouselIntervalHint": "Seconds each media stays; decimals allowed. 0 disables auto-advance (manual loop still works).",
|
||||
"backupEnabled": "Enable Scheduled Backup",
|
||||
"backupSchedule": "Backup Schedule",
|
||||
"backupRetentionDays": "Backup Retention Days",
|
||||
"backupRetentionCount": "Max Backup Count",
|
||||
"scheduleDaily": "Daily",
|
||||
"scheduleWeekly": "Weekly",
|
||||
"saved": "Settings saved"
|
||||
},
|
||||
"profile": {
|
||||
@@ -402,6 +459,30 @@
|
||||
"restore": "Restore backup",
|
||||
"upload": "Upload file"
|
||||
}
|
||||
},
|
||||
"backup": {
|
||||
"title": "Backup & Restore",
|
||||
"create": "Create Backup",
|
||||
"uploadPreview": "Upload Backup for Pre-check",
|
||||
"previewPassed": "Backup package passed pre-check: {time}. Restore will overwrite the current system; a snapshot will be created before confirmation.",
|
||||
"confirmRestore": "Confirm Restore",
|
||||
"fileName": "File Name",
|
||||
"size": "Size",
|
||||
"error": "Error",
|
||||
"created": "Backup created",
|
||||
"deleteTitle": "Delete Backup",
|
||||
"deleteConfirm": "Delete this backup record and the backup package on the server?",
|
||||
"previewSuccess": "Backup package pre-check passed",
|
||||
"previewFailed": "Pre-check failed",
|
||||
"restoreTitle": "Confirm Restore",
|
||||
"restoreConfirm": "Restore will overwrite the current database and uploaded files. The system will create a backup first. Continue?",
|
||||
"restoreDone": "Restore completed. Please check the data again.",
|
||||
"mode": {
|
||||
"BACKUP": "Manual Backup",
|
||||
"RESTORE": "Restore",
|
||||
"SCHEDULED": "Scheduled Backup",
|
||||
"AUTO_BEFORE_RESTORE": "Auto Snapshot Before Restore"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
"apply": "应用",
|
||||
"open": "打开",
|
||||
"changePassword": "修改密码",
|
||||
"logout": "退出登录"
|
||||
"logout": "退出登录",
|
||||
"filter": "筛选"
|
||||
},
|
||||
"label": {
|
||||
"keyword": "关键词",
|
||||
@@ -118,7 +119,38 @@
|
||||
"loginExpired": "登录已过期,请重新登录",
|
||||
"networkError": "网络异常,请稍后再试",
|
||||
"noData": "暂无数据",
|
||||
"maxReached": "最多上传 {n} 个"
|
||||
"maxReached": "最多上传 {n} 个",
|
||||
"uploadFailed": "上传失败",
|
||||
"logoutConfirm": "确定退出登录?"
|
||||
},
|
||||
"errorCode": {
|
||||
"1000": "请求参数有误",
|
||||
"1001": "未登录或登录已过期",
|
||||
"1002": "没有操作权限",
|
||||
"1003": "资源不存在",
|
||||
"1004": "数据校验失败",
|
||||
"1005": "服务器内部错误",
|
||||
"1006": "请求过于频繁,请稍后再试",
|
||||
"2001": "用户名或密码错误",
|
||||
"2002": "登录已过期,请重新登录",
|
||||
"2003": "账号已被停用",
|
||||
"2004": "原密码不正确",
|
||||
"2005": "用户名已存在",
|
||||
"3001": "模板不存在",
|
||||
"3002": "模板已被使用,无法删除",
|
||||
"3003": "艺术品不存在",
|
||||
"3004": "追溯码不存在",
|
||||
"3005": "追溯码无效",
|
||||
"3006": "追溯码已停用",
|
||||
"3007": "追溯码状态异常",
|
||||
"3008": "追溯码已绑定作品",
|
||||
"3009": "导入文件解析失败",
|
||||
"3010": "不支持的文件类型",
|
||||
"3011": "文件超出大小限制",
|
||||
"3012": "认证文件不存在",
|
||||
"3013": "任务不存在",
|
||||
"3014": "批次不存在",
|
||||
"3015": "艺术品档案已有业务数据,无法删除"
|
||||
},
|
||||
"lang": { "zh": "简体中文", "en": "English" }
|
||||
},
|
||||
@@ -289,6 +321,7 @@
|
||||
"assignGroup": "设为分组"
|
||||
},
|
||||
"outbound": {
|
||||
"batchImportTitle": "出库批量导入",
|
||||
"import": "批量导入",
|
||||
"outTime": "出库时间",
|
||||
"outImage": "出库实况图",
|
||||
@@ -314,7 +347,21 @@
|
||||
"errorReason": "错误原因",
|
||||
"previewReady": "预览解析完成",
|
||||
"uploadFailed": "上传失败",
|
||||
"importDone": "导入完成"
|
||||
"importDone": "导入完成",
|
||||
"rowStatus": {
|
||||
"VALID": "有效",
|
||||
"INVALID": "无效",
|
||||
"IMPORTED": "已导入",
|
||||
"FAILED": "失败"
|
||||
},
|
||||
"sessionStatus": {
|
||||
"PARSING": "解析中",
|
||||
"READY": "待导入",
|
||||
"IMPORTING": "导入中",
|
||||
"IMPORTED": "已导入",
|
||||
"FAILED": "失败",
|
||||
"EXPIRED": "已过期"
|
||||
}
|
||||
},
|
||||
"blockchain": {
|
||||
"title": "区块链存证",
|
||||
@@ -346,6 +393,10 @@
|
||||
"lastLoginAt": "最近登录"
|
||||
},
|
||||
"settings": {
|
||||
"baseSettings": "基础设置",
|
||||
"platformInfo": "平台信息",
|
||||
"logAndDisplay": "日志与展示",
|
||||
"backupPolicy": "备份策略",
|
||||
"appName": "平台名称",
|
||||
"appIcon": "系统图标",
|
||||
"logRetentionDays": "查询日志保留天数",
|
||||
@@ -354,6 +405,12 @@
|
||||
"filingInfo": "备案信息",
|
||||
"carouselInterval": "客户端轮播间隔(秒)",
|
||||
"carouselIntervalHint": "每张媒体停留秒数,支持小数;填 0 则不自动切换(仍可手动循环切换)",
|
||||
"backupEnabled": "启用定时备份",
|
||||
"backupSchedule": "备份周期",
|
||||
"backupRetentionDays": "备份保留天数",
|
||||
"backupRetentionCount": "最多保留备份数量",
|
||||
"scheduleDaily": "每天",
|
||||
"scheduleWeekly": "每周",
|
||||
"saved": "设置已保存"
|
||||
},
|
||||
"profile": {
|
||||
@@ -402,6 +459,30 @@
|
||||
"restore": "恢复备份",
|
||||
"upload": "上传文件"
|
||||
}
|
||||
},
|
||||
"backup": {
|
||||
"title": "备份与恢复",
|
||||
"create": "创建备份",
|
||||
"uploadPreview": "上传备份包预校验",
|
||||
"previewPassed": "已通过备份包预校验:{time}。恢复会整库覆盖当前系统,确认前会自动生成当前快照。",
|
||||
"confirmRestore": "确认恢复",
|
||||
"fileName": "文件名",
|
||||
"size": "大小",
|
||||
"error": "错误",
|
||||
"created": "备份已创建",
|
||||
"deleteTitle": "删除备份",
|
||||
"deleteConfirm": "确认删除该备份记录和服务器上的备份包?",
|
||||
"previewSuccess": "备份包预校验通过",
|
||||
"previewFailed": "预校验失败",
|
||||
"restoreTitle": "确认恢复",
|
||||
"restoreConfirm": "恢复会覆盖当前数据库和上传文件。系统会先自动备份当前状态,确认继续?",
|
||||
"restoreDone": "恢复完成,请重新检查数据",
|
||||
"mode": {
|
||||
"BACKUP": "手动备份",
|
||||
"RESTORE": "恢复",
|
||||
"SCHEDULED": "定时备份",
|
||||
"AUTO_BEFORE_RESTORE": "恢复前自动快照"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
import { createDiscreteApi } from 'naive-ui';
|
||||
import { computed } from 'vue';
|
||||
import { createDiscreteApi, darkTheme, dateEnUS, dateZhCN, enUS, zhCN } from 'naive-ui';
|
||||
import { i18n } from '@/locales';
|
||||
import { themeOverrides } from '@/theme';
|
||||
import { useTheme } from '@/composables/useTheme';
|
||||
|
||||
// 全局可用的消息/对话框/加载条(含在 setup 之外,如 axios 拦截器)
|
||||
const { isDark } = useTheme();
|
||||
const { message, dialog, loadingBar } = createDiscreteApi(['message', 'dialog', 'loadingBar'], {
|
||||
configProviderProps: { themeOverrides },
|
||||
configProviderProps: computed(() => {
|
||||
const isEnglish = i18n.global.locale.value === 'en-US';
|
||||
return {
|
||||
theme: isDark.value ? darkTheme : null,
|
||||
themeOverrides,
|
||||
locale: isEnglish ? enUS : zhCN,
|
||||
dateLocale: isEnglish ? dateEnUS : dateZhCN,
|
||||
};
|
||||
}),
|
||||
});
|
||||
|
||||
export { message, dialog, loadingBar };
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { h } from 'vue';
|
||||
import { NButton, NDropdown, NIcon, type DropdownOption } from 'naive-ui';
|
||||
import { FilterOutline } from '@vicons/ionicons5';
|
||||
import { i18n } from '@/locales';
|
||||
|
||||
export interface TableFilterOption {
|
||||
label: string;
|
||||
@@ -12,7 +13,7 @@ export function renderTableFilterTitle(
|
||||
value: string | number | null | undefined,
|
||||
options: TableFilterOption[],
|
||||
onSelect: (value: string | number | null) => void,
|
||||
allLabel = '全部',
|
||||
allLabel = i18n.global.t('common.label.all'),
|
||||
) {
|
||||
const active = value !== null && value !== undefined && value !== '';
|
||||
const dropdownOptions: DropdownOption[] = [
|
||||
@@ -32,7 +33,7 @@ export function renderTableFilterTitle(
|
||||
default: () =>
|
||||
h(
|
||||
NButton,
|
||||
{ quaternary: true, circle: true, size: 'tiny', class: ['filter-trigger', { active }], title: '筛选' },
|
||||
{ quaternary: true, circle: true, size: 'tiny', class: ['filter-trigger', { active }], title: i18n.global.t('common.action.filter') },
|
||||
{ icon: () => h(NIcon, null, { default: () => h(FilterOutline) }) },
|
||||
),
|
||||
},
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<div class="page table-page outbound-page">
|
||||
<div class="page-toolbar outbound-toolbar">
|
||||
<div class="section-title">出库批量导入</div>
|
||||
<div class="section-title">{{ t('pages.outbound.batchImportTitle') }}</div>
|
||||
<div class="spacer" />
|
||||
<n-button :title="'下载模板包'" @click="downloadTemplate">
|
||||
<n-button :title="t('pages.outbound.downloadZipTemplate')" @click="downloadTemplate">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
下载模板包
|
||||
{{ t('pages.outbound.downloadZipTemplate') }}
|
||||
</n-button>
|
||||
<n-upload
|
||||
:show-file-list="false"
|
||||
@@ -15,21 +15,21 @@
|
||||
>
|
||||
<n-button type="primary" :loading="previewing">
|
||||
<template #icon><n-icon :component="CloudUploadOutline" /></template>
|
||||
上传并预览
|
||||
{{ t('pages.outbound.uploadZipPreview') }}
|
||||
</n-button>
|
||||
</n-upload>
|
||||
</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="有效行">
|
||||
<n-statistic :label="t('pages.outbound.totalRows')" :value="session.total || 0" />
|
||||
<n-statistic :label="t('pages.outbound.validRows')">
|
||||
<span class="success-text">{{ session.validCount || 0 }}</span>
|
||||
</n-statistic>
|
||||
<n-statistic label="错误行">
|
||||
<n-statistic :label="t('pages.outbound.invalidRows')">
|
||||
<span class="danger-text">{{ session.invalidCount || 0 }}</span>
|
||||
</n-statistic>
|
||||
<n-tag :type="statusType(session.status)">{{ session.status }}</n-tag>
|
||||
<n-tag :type="statusType(session.status)">{{ sessionStatusLabel(session.status) }}</n-tag>
|
||||
<n-progress
|
||||
v-if="busy"
|
||||
type="line"
|
||||
@@ -44,11 +44,11 @@
|
||||
:loading="committing"
|
||||
@click="commitImport"
|
||||
>
|
||||
确认导入
|
||||
{{ t('pages.outbound.confirmImport') }}
|
||||
</n-button>
|
||||
<n-button v-if="result?.resultFileUrl" tag="a" :href="result.resultFileUrl" target="_blank">
|
||||
<template #icon><n-icon :component="DownloadOutline" /></template>
|
||||
下载导入结果
|
||||
{{ t('pages.outbound.downloadResult') }}
|
||||
</n-button>
|
||||
</n-space>
|
||||
<n-text v-if="session.error" type="error" class="session-error">{{ session.error }}</n-text>
|
||||
@@ -74,6 +74,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, h, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { UploadCustomRequestOptions } from 'naive-ui';
|
||||
import { NButton, NIcon, NImage, NTag, NText, type DataTableColumns } from 'naive-ui';
|
||||
import { CloudUploadOutline, DownloadOutline } from '@vicons/ionicons5';
|
||||
@@ -86,6 +87,7 @@ import { useTablePage } from '@/composables/useTablePage';
|
||||
import { openMediaViewer } from '@/composables/openMediaViewer';
|
||||
import { useRemoteSort } from '@/utils/tableSort';
|
||||
|
||||
const { t } = useI18n();
|
||||
const auth = useAuthStore();
|
||||
const rows = ref<any[]>([]);
|
||||
const session = ref<any>(null);
|
||||
@@ -105,28 +107,28 @@ const { sortProps, onSorterChange, sortParams } = useRemoteSort(() => {
|
||||
});
|
||||
|
||||
const columns = computed<DataTableColumns<any>>(() => [
|
||||
{ title: '行号', key: 'rowNo', width: 80, align: 'center' },
|
||||
{ title: t('pages.outbound.rowNo'), key: 'rowNo', width: 80, align: 'center' },
|
||||
{
|
||||
title: '状态',
|
||||
title: t('common.label.status'),
|
||||
key: 'status',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
render: (row) => h(NTag, { size: 'small', type: row.status === 'VALID' || row.status === 'IMPORTED' ? 'success' : 'error' }, { default: () => row.status }),
|
||||
render: (row) => h(NTag, { size: 'small', type: row.status === 'VALID' || row.status === 'IMPORTED' ? 'success' : 'error' }, { default: () => statusLabel(row.status) }),
|
||||
},
|
||||
{ title: '追溯码', key: 'shortCode', minWidth: 150, align: 'center', ellipsis: { tooltip: true } },
|
||||
{ title: '批次编号', key: 'batchNo', minWidth: 180, align: 'center', ellipsis: { tooltip: true } },
|
||||
{ title: '出库时间', key: 'outTime', width: 170, align: 'center', render: (row) => fmt(row.outTime || row.preview?.outTime), ...sortProps('outTime') },
|
||||
{ title: t('pages.traceCode.shortCode'), key: 'shortCode', minWidth: 150, align: 'center', ellipsis: { tooltip: true } },
|
||||
{ title: t('pages.traceCode.batchNo'), key: 'batchNo', minWidth: 180, align: 'center', ellipsis: { tooltip: true } },
|
||||
{ title: t('pages.outbound.outTime'), key: 'outTime', width: 170, align: 'center', render: (row) => fmt(row.outTime || row.preview?.outTime), ...sortProps('outTime') },
|
||||
{
|
||||
title: '出库实况图',
|
||||
title: t('pages.outbound.outImage'),
|
||||
key: 'images',
|
||||
width: 240,
|
||||
align: 'center',
|
||||
render: (row) => renderImages(row),
|
||||
},
|
||||
{ title: '上链哈希', key: 'txHash', minWidth: 260, ellipsis: { tooltip: true } },
|
||||
{ title: '备注', key: 'remark', minWidth: 220, ellipsis: { tooltip: true } },
|
||||
{ title: t('pages.blockchain.txHash'), key: 'txHash', minWidth: 260, ellipsis: { tooltip: true } },
|
||||
{ title: t('common.label.remark'), key: 'remark', minWidth: 220, ellipsis: { tooltip: true } },
|
||||
{
|
||||
title: '错误原因',
|
||||
title: t('pages.outbound.errorReason'),
|
||||
key: 'reason',
|
||||
minWidth: 300,
|
||||
ellipsis: { tooltip: true },
|
||||
@@ -188,10 +190,10 @@ async function uploadPreview({ file, onFinish, onError }: UploadCustomRequestOpt
|
||||
await refreshSession();
|
||||
resetPage();
|
||||
await loadRows();
|
||||
message.success('预览解析完成');
|
||||
message.success(t('pages.outbound.previewReady'));
|
||||
onFinish();
|
||||
} catch (e) {
|
||||
message.error((e as Error)?.message || '上传失败');
|
||||
message.error(t('pages.outbound.uploadFailed'));
|
||||
onError();
|
||||
} finally {
|
||||
previewing.value = false;
|
||||
@@ -210,7 +212,7 @@ async function commitImport() {
|
||||
result.value = job;
|
||||
await refreshSession();
|
||||
await loadRows();
|
||||
message.success('导入完成');
|
||||
message.success(t('pages.outbound.importDone'));
|
||||
} finally {
|
||||
committing.value = false;
|
||||
progressPercent.value = 0;
|
||||
@@ -261,6 +263,14 @@ async function loadRows() {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function statusLabel(value?: string) {
|
||||
return value ? t(`pages.outbound.rowStatus.${value}`) : '-';
|
||||
}
|
||||
|
||||
function sessionStatusLabel(value?: string) {
|
||||
return value ? t(`pages.outbound.sessionStatus.${value}`) : '-';
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
<div class="page settings-page">
|
||||
<div class="settings-shell">
|
||||
<n-tabs type="line" animated class="settings-tabs">
|
||||
<n-tab-pane name="base" tab="基础设置">
|
||||
<n-tab-pane name="base" :tab="t('pages.settings.baseSettings')">
|
||||
<div class="settings-base-pane">
|
||||
<n-form class="settings-form" label-placement="top">
|
||||
<section class="settings-section">
|
||||
<div class="section-title">平台信息</div>
|
||||
<div class="section-title">{{ t('pages.settings.platformInfo') }}</div>
|
||||
<div class="field-grid two">
|
||||
<n-form-item :label="t('pages.settings.appName')">
|
||||
<n-input v-model:value="form.appName" class="control-wide" />
|
||||
@@ -27,7 +27,7 @@
|
||||
</section>
|
||||
|
||||
<section class="settings-section">
|
||||
<div class="section-title">日志与展示</div>
|
||||
<div class="section-title">{{ t('pages.settings.logAndDisplay') }}</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" />
|
||||
@@ -52,18 +52,18 @@
|
||||
</section>
|
||||
|
||||
<section class="settings-section">
|
||||
<div class="section-title">备份策略</div>
|
||||
<div class="section-title">{{ t('pages.settings.backupPolicy') }}</div>
|
||||
<div class="field-grid four">
|
||||
<n-form-item label="启用定时备份">
|
||||
<n-form-item :label="t('pages.settings.backupEnabled')">
|
||||
<div class="switch-field"><n-switch v-model:value="form.backupEnabled" /></div>
|
||||
</n-form-item>
|
||||
<n-form-item label="备份周期">
|
||||
<n-form-item :label="t('pages.settings.backupSchedule')">
|
||||
<n-select v-model:value="form.backupSchedule" :options="backupScheduleOptions" class="control-short" />
|
||||
</n-form-item>
|
||||
<n-form-item label="备份保留天数">
|
||||
<n-form-item :label="t('pages.settings.backupRetentionDays')">
|
||||
<n-input-number v-model:value="form.backupRetentionDays" :min="1" class="control-short" />
|
||||
</n-form-item>
|
||||
<n-form-item label="最多保留备份数量">
|
||||
<n-form-item :label="t('pages.settings.backupRetentionCount')">
|
||||
<n-input-number v-model:value="form.backupRetentionCount" :min="1" class="control-short" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
@@ -76,7 +76,7 @@
|
||||
</div>
|
||||
</n-tab-pane>
|
||||
|
||||
<n-tab-pane name="backup" tab="备份与恢复">
|
||||
<n-tab-pane name="backup" :tab="t('pages.backup.title')">
|
||||
<div class="settings-backup-pane">
|
||||
<backup-restore-panel />
|
||||
</div>
|
||||
@@ -98,8 +98,8 @@ import { DEFAULT_APP_ICON_URL, resolveAppIcon, setFavicon } from '@/utils/appIco
|
||||
const { t } = useI18n();
|
||||
const saving = ref(false);
|
||||
const backupScheduleOptions = [
|
||||
{ label: '每天', value: 'daily' },
|
||||
{ label: '每周', value: 'weekly' },
|
||||
{ label: t('pages.settings.scheduleDaily'), value: 'daily' },
|
||||
{ label: t('pages.settings.scheduleWeekly'), value: 'weekly' },
|
||||
];
|
||||
const form = reactive({
|
||||
appName: '',
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
"viewFile": "View file"
|
||||
},
|
||||
"privacy": {
|
||||
"note": "Privacy: for anti-counterfeit risk control and query statistics, this visit's necessary info (time, IP, region and device) is recorded."
|
||||
"note": "Privacy: for anti-counterfeit risk control and query statistics, this visit's necessary info (time, IP and device) is recorded."
|
||||
},
|
||||
"state": {
|
||||
"loading": "Loading…",
|
||||
@@ -64,5 +64,5 @@
|
||||
"next": "Next"
|
||||
},
|
||||
"artist": "Artist",
|
||||
"lang": { "zh": "中文", "en": "EN", "switch": "Switch language" }
|
||||
"lang": { "zh": "Simplified Chinese", "en": "English", "switch": "Switch language" }
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ const KEY = 'artveris_client_locale';
|
||||
|
||||
// 支持的语言列表(后续新增语言只需在此追加)
|
||||
export const SUPPORTED_LOCALES = [
|
||||
{ value: 'zh-CN', label: '中文' },
|
||||
{ value: 'zh-CN', label: '简体中文' },
|
||||
{ value: 'en-US', label: 'English' },
|
||||
];
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
"viewFile": "查看文件"
|
||||
},
|
||||
"privacy": {
|
||||
"note": "隐私说明:为防伪风控与查询统计,系统会记录本次访问的必要信息(如访问时间、IP、地区与设备信息)。"
|
||||
"note": "隐私说明:为防伪风控与查询统计,系统会记录本次访问的必要信息(如访问时间、IP 与设备信息)。"
|
||||
},
|
||||
"state": {
|
||||
"loading": "正在查询…",
|
||||
@@ -64,5 +64,5 @@
|
||||
"next": "下一个"
|
||||
},
|
||||
"artist": "艺术家",
|
||||
"lang": { "zh": "中文", "en": "EN", "switch": "切换语言" }
|
||||
"lang": { "zh": "简体中文", "en": "English", "switch": "切换语言" }
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { fetchAppInfo } from '@/api';
|
||||
import { setLocale } from '@/locales';
|
||||
import { setLocale, SUPPORTED_LOCALES } from '@/locales';
|
||||
import { resolveAppIcon, setFavicon } from '@/utils/appIcon';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const appName = ref('');
|
||||
const appIconUrl = ref(resolveAppIcon());
|
||||
const filingInfo = ref('');
|
||||
const otherLangLabel = computed(() => (locale.value === 'zh-CN' ? 'EN' : '中文'));
|
||||
const otherLangLabel = computed(() => SUPPORTED_LOCALES.find((item) => item.value !== locale.value)?.label || 'English');
|
||||
function toggleLang() {
|
||||
setLocale(locale.value === 'zh-CN' ? 'en-US' : 'zh-CN');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user