feat: 后台语言包合并默认中文、日夜主题切换、官方侧栏收缩、追溯码分组与批量

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Nixevol
2026-06-28 18:37:57 +08:00
co-authored by Cursor
parent 6578007c9e
commit b5170fe84b
21 changed files with 873 additions and 666 deletions
+10 -2
View File
@@ -1,5 +1,11 @@
<template>
<n-config-provider :theme-overrides="themeOverrides" :locale="naiveLocale" :date-locale="naiveDateLocale">
<n-config-provider
:theme="isDark ? darkTheme : null"
:theme-overrides="themeOverrides"
:locale="naiveLocale"
:date-locale="naiveDateLocale"
>
<n-global-style />
<router-view />
</n-config-provider>
</template>
@@ -7,10 +13,12 @@
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { zhCN, dateZhCN, enUS, dateEnUS } from 'naive-ui';
import { darkTheme, zhCN, dateZhCN, enUS, dateEnUS } from 'naive-ui';
import { themeOverrides } from '@/theme';
import { useTheme } from '@/composables/useTheme';
const { locale } = useI18n();
const { isDark } = useTheme();
const naiveLocale = computed(() => (locale.value === 'en-US' ? enUS : zhCN));
const naiveDateLocale = computed(() => (locale.value === 'en-US' ? dateEnUS : dateZhCN));
</script>
+13 -1
View File
@@ -44,13 +44,25 @@ export const artworkApi = {
};
export const traceCodeApi = {
generate: (data: { quantity: number; batchNo?: string }) => post('/trace-codes/batch', data),
generate: (data: { quantity: number; batchNo?: string; groupId?: number }) =>
post('/trace-codes/batch', data),
batches: (params: object) => get<PageResult<any>>('/batches', params),
list: (params: object) => get<PageResult<any>>('/trace-codes', params),
bind: (id: string, artworkId: number) => put(`/trace-codes/${id}/bind`, { artworkId }),
unbind: (id: string) => put(`/trace-codes/${id}/unbind`, {}),
qrUrl: (id: string) => `/api/trace-codes/${id}/qrcode`,
onchain: (id: string) => post(`/trace-codes/${id}/onchain`, {}),
// 分组
groups: () => get<any[]>('/trace-code-groups'),
createGroup: (data: { name: string; remark?: string }) => post('/trace-code-groups', data),
updateGroup: (id: number, data: { name: string; remark?: string }) =>
put(`/trace-code-groups/${id}`, data),
removeGroup: (id: number) => del(`/trace-code-groups/${id}`),
// 批量
batchGroup: (ids: string[], groupId: number | null) =>
put('/trace-codes/batch/group', { ids, groupId }),
batchStatus: (ids: string[], disabled: boolean) =>
put('/trace-codes/batch/status', { ids, disabled }),
};
export const outboundApi = {
+22
View File
@@ -0,0 +1,22 @@
<template>
<n-dropdown trigger="click" :options="options" @select="onSelect">
<n-button quaternary :title="t('common.lang.zh')">
<template #icon><n-icon :component="LanguageOutline" /></template>
{{ marker }}
</n-button>
</n-dropdown>
</template>
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { LanguageOutline } from '@vicons/ionicons5';
import { SUPPORTED_LOCALES, setLocale } from '@/locales';
const { t, locale } = useI18n();
const marker = computed(() => locale.value);
const options = SUPPORTED_LOCALES.map((l) => ({ label: `${l.label}(${l.value})`, key: l.value }));
function onSelect(key: string) {
setLocale(key);
}
</script>
+36
View File
@@ -0,0 +1,36 @@
<template>
<n-dropdown trigger="click" :options="options" :value="mode" @select="setMode">
<n-button quaternary circle :title="t('common.theme.title')">
<template #icon><n-icon :component="currentIcon" /></template>
</n-button>
</n-dropdown>
</template>
<script setup lang="ts">
import { computed, h } from 'vue';
import { useI18n } from 'vue-i18n';
import { NIcon } from 'naive-ui';
import { SunnyOutline, MoonOutline, ContrastOutline } from '@vicons/ionicons5';
import { useTheme, type ThemeMode } from '@/composables/useTheme';
const { t } = useI18n();
const { mode, isDark, setMode } = useTheme();
const ICONS: Record<ThemeMode, unknown> = {
light: SunnyOutline,
dark: MoonOutline,
auto: ContrastOutline,
};
const currentIcon = computed(() => (mode.value === 'auto' ? ContrastOutline : isDark.value ? MoonOutline : SunnyOutline));
function renderIcon(icon: unknown) {
return () => h(NIcon, null, { default: () => h(icon as never) });
}
const options = computed(() => [
{ label: t('common.theme.light'), key: 'light', icon: renderIcon(ICONS.light) },
{ label: t('common.theme.dark'), key: 'dark', icon: renderIcon(ICONS.dark) },
{ label: t('common.theme.auto'), key: 'auto', icon: renderIcon(ICONS.auto) },
]);
</script>
+21
View File
@@ -0,0 +1,21 @@
import { computed, ref } from 'vue';
export type ThemeMode = 'light' | 'dark' | 'auto';
const KEY = 'artveris_theme';
const media = window.matchMedia('(prefers-color-scheme: dark)');
const systemDark = ref(media.matches);
media.addEventListener('change', (e) => (systemDark.value = e.matches));
const mode = ref<ThemeMode>((localStorage.getItem(KEY) as ThemeMode) || 'light');
const isDark = computed(() => mode.value === 'dark' || (mode.value === 'auto' && systemDark.value));
function setMode(m: ThemeMode): void {
mode.value = m;
localStorage.setItem(KEY, m);
}
export function useTheme() {
return { mode, isDark, setMode };
}
+12 -40
View File
@@ -7,8 +7,7 @@
:collapsed-width="64"
:width="224"
:native-scrollbar="false"
:inverted="true"
show-trigger="bar"
show-trigger="arrow-circle"
@collapse="collapsed = true"
@expand="collapsed = false"
>
@@ -17,7 +16,6 @@
<span v-show="!collapsed" class="brand-name text-ellipsis">{{ appName }}</span>
</div>
<n-menu
:inverted="true"
:collapsed="collapsed"
:collapsed-width="64"
:value="activeKey"
@@ -28,18 +26,10 @@
<n-layout>
<n-layout-header bordered class="header">
<n-button quaternary circle @click="collapsed = !collapsed">
<template #icon><n-icon :component="MenuOutline" /></template>
</n-button>
<div class="header-title text-ellipsis">{{ currentTitle }}</div>
<div class="spacer" />
<n-select
v-model:value="currentLocale"
:options="localeOptions"
size="small"
style="width: 110px"
@update:value="changeLocale"
/>
<theme-switch />
<lang-switch />
<n-dropdown :options="userOptions" @select="onUser">
<n-button quaternary>
<template #icon><n-icon :component="PersonCircleOutline" /></template>
@@ -74,26 +64,23 @@ import {
ListOutline,
PeopleOutline,
SettingsOutline,
MenuOutline,
PersonCircleOutline,
LogOutOutline,
KeyOutline,
} from '@vicons/ionicons5';
import { useAuthStore } from '@/stores/auth';
import { settingsApi } from '@/api';
import { SUPPORTED_LOCALES, setLocale } from '@/locales';
import { dialog } from '@/utils/feedback';
import LangSwitch from '@/components/LangSwitch.vue';
import ThemeSwitch from '@/components/ThemeSwitch.vue';
const route = useRoute();
const router = useRouter();
const { t, locale } = useI18n();
const { t } = useI18n();
const auth = useAuthStore();
const collapsed = ref(window.innerWidth < 900);
const appName = ref(t('pages.login.title'));
const currentLocale = ref(locale.value);
const localeOptions = SUPPORTED_LOCALES.map((l) => ({ label: l.label, value: l.value }));
function renderIcon(icon: unknown) {
return () => h(NIcon, null, { default: () => h(icon as never) });
@@ -113,15 +100,8 @@ const menuOptions = computed<MenuOption[]>(() => {
return items.filter((i) => !i.superOnly || auth.isSuperAdmin);
});
const activeKey = computed(() => {
if (route.name === 'artwork-detail') return 'artworks';
return route.name as string;
});
const currentTitle = computed(() => {
const key = activeKey.value;
return key ? t(`menu.${key}`) : '';
});
const activeKey = computed(() => (route.name === 'artwork-detail' ? 'artworks' : (route.name as string)));
const currentTitle = computed(() => (activeKey.value ? t(`menu.${activeKey.value}`) : ''));
const userOptions = computed(() => [
{ label: t('menu.profile'), key: 'profile', icon: renderIcon(KeyOutline) },
@@ -132,11 +112,6 @@ function onMenu(key: string) {
router.push({ name: key });
}
function changeLocale(val: string) {
setLocale(val);
currentLocale.value = val;
}
function onUser(key: string) {
if (key === 'profile') {
router.push({ name: 'profile' });
@@ -177,8 +152,6 @@ onUnmounted(() => window.removeEventListener('resize', resizeHandler));
gap: 10px;
height: 56px;
padding: 0 16px;
color: #fff;
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand-logo {
display: inline-flex;
@@ -187,26 +160,26 @@ onUnmounted(() => window.removeEventListener('resize', resizeHandler));
width: 32px;
height: 32px;
border-radius: 8px;
background: #2e5496;
background: var(--brand);
color: #fff;
font-weight: 700;
flex-shrink: 0;
}
.brand-name {
font-size: 15px;
font-weight: 600;
color: var(--brand);
}
.header {
display: flex;
align-items: center;
gap: 12px;
gap: 10px;
height: 56px;
padding: 0 16px;
background: #fff;
}
.header-title {
font-size: 16px;
font-weight: 600;
color: #1f2937;
max-width: 40vw;
}
.spacer {
@@ -214,7 +187,6 @@ onUnmounted(() => window.removeEventListener('resize', resizeHandler));
}
.content {
height: calc(100vh - 56px);
background: #f0f2f5;
}
.fade-enter-active,
.fade-leave-active {
+280
View File
@@ -0,0 +1,280 @@
{
"common": {
"action": {
"add": "Add",
"edit": "Edit",
"delete": "Delete",
"save": "Save",
"cancel": "Cancel",
"confirm": "OK",
"search": "Search",
"reset": "Reset",
"export": "Export",
"download": "Download",
"downloadTemplate": "Template",
"upload": "Upload",
"view": "View",
"detail": "Detail",
"back": "Back",
"submit": "Submit",
"refresh": "Refresh",
"generate": "Generate",
"bind": "Bind",
"unbind": "Unbind",
"retry": "Retry",
"copy": "Copy",
"onchain": "On-chain",
"qrcode": "QR Code",
"manage": "Manage",
"apply": "Apply",
"open": "Open",
"changePassword": "Change Password",
"logout": "Logout"
},
"label": {
"keyword": "Keyword",
"status": "Status",
"type": "Type",
"createdAt": "Created",
"updatedAt": "Updated",
"operation": "Actions",
"all": "All",
"remark": "Remark",
"total": "{n} items",
"yes": "Yes",
"no": "No"
},
"status": {
"ENABLED": "Enabled",
"DISABLED": "Disabled",
"DRAFT": "Draft",
"ACTIVE": "Activated",
"ABNORMAL": "Abnormal",
"UNBOUND": "Unbound",
"INACTIVE": "Inactive",
"PENDING": "Pending",
"PROCESSING": "Processing",
"SUCCESS": "Success",
"PARTIAL": "Partial",
"FAILED": "Failed",
"ONCHAIN": "On-chain",
"GENERATING": "Generating",
"DONE": "Done"
},
"role": {
"SUPER_ADMIN": "Super Admin",
"OPERATOR": "Operator",
"AUDITOR": "Auditor",
"VIEWER": "Viewer"
},
"queryResult": {
"FIRST_ACTIVATE": "First Activation",
"REPEAT": "Repeat",
"INVALID": "Invalid",
"DISABLED": "Disabled",
"ABNORMAL": "Abnormal"
},
"fieldType": {
"TEXT": "Text",
"NUMBER": "Number",
"DATE": "Date",
"IMAGE": "Image",
"FILE": "File",
"LINK": "Link",
"TEXTAREA": "Textarea"
},
"nodeType": {
"CREATE": "Creation",
"PRODUCE": "Production",
"STORAGE": "Storage",
"OUTBOUND": "Outbound",
"OTHER": "Other"
},
"theme": {
"title": "Theme",
"light": "Light",
"dark": "Dark",
"auto": "System"
},
"msg": {
"confirmDelete": "Delete this record?",
"deleted": "Deleted",
"saved": "Saved",
"created": "Created",
"updated": "Updated",
"copied": "Copied",
"operationSuccess": "Success",
"loginExpired": "Session expired, please log in again",
"networkError": "Network error, please try again",
"noData": "No data"
},
"lang": { "zh": "中文", "en": "English" }
},
"menu": {
"dashboard": "Dashboard",
"templates": "Templates",
"artworks": "Artworks",
"traceCodes": "Trace Codes",
"outbound": "Outbound & Chain",
"queryLogs": "Query Logs",
"users": "Users",
"settings": "Settings",
"profile": "Profile"
},
"pages": {
"login": {
"title": "Artwork Traceability & Authentication",
"subtitle": "Management Console",
"username": "Username",
"password": "Password",
"submit": "Sign In",
"placeholderUser": "Enter username",
"placeholderPass": "Enter password",
"success": "Signed in"
},
"dashboard": {
"totalArtworks": "Artworks",
"boundCodes": "Bound Codes",
"activatedCodes": "Activated Codes",
"totalQueries": "Total Queries",
"todayQueries": "Today",
"abnormalQueries": "Abnormal",
"trendTitle": "Queries (Last 7 Days)",
"topTitle": "Top Queried Artworks",
"queryCount": "Queries",
"rank": "Rank"
},
"template": {
"name": "Template Name",
"fields": "Fields",
"fieldKey": "Field Key",
"fieldLabel": "Label",
"fieldType": "Type",
"required": "Required",
"sortOrder": "Order",
"addField": "Add Field",
"useCount": "Used By",
"create": "New Template",
"edit": "Edit Template",
"namePlaceholder": "Enter template name",
"fieldKeyTip": "Unique key, e.g. craft"
},
"artwork": {
"title": "Title",
"artist": "Artist",
"template": "Template",
"images": "Images",
"basicInfo": "Basic Info",
"dynamicFields": "Fields",
"nodes": "Timeline",
"certificates": "Certificates",
"traceCode": "Trace Code",
"status": "Status",
"create": "New Artwork",
"edit": "Edit Artwork",
"detail": "Artwork Detail",
"addNode": "Add Node",
"nodeTitle": "Node Title",
"nodeLocation": "Location",
"nodeTime": "Time",
"nodeDesc": "Description",
"addCert": "Add Certificate",
"certName": "Certificate Name",
"certIssuer": "Issuer",
"certType": "Type",
"originFile": "Original File",
"watermarkPreview": "Watermark",
"watermarkPending": "Generating watermark…",
"bindCode": "Bind Trace Code",
"noTrace": "No trace code bound"
},
"traceCode": {
"batches": "Batches",
"codes": "Trace Codes",
"batchNo": "Batch No.",
"quantity": "Quantity",
"generate": "Generate",
"generatedCount": "Generated",
"shortCode": "Short Code",
"code": "Trace Code",
"url": "Short URL",
"queryCount": "Queries",
"firstActivatedAt": "First Activated",
"exportBatch": "Export Batch",
"bindArtwork": "Bind Artwork",
"selectArtwork": "Select artwork",
"qrPreview": "QR Preview",
"generating": "Generating, please wait…",
"genSuccess": "Generation task submitted",
"group": "Group",
"groups": "Groups",
"allGroups": "All Groups",
"noGroup": "Ungrouped",
"manageGroups": "Manage Groups",
"createGroup": "New Group",
"editGroup": "Edit Group",
"groupName": "Group Name",
"batchGroup": "Set Group",
"batchEnable": "Enable",
"batchDisable": "Disable",
"selected": "{n} selected",
"assignGroup": "Assign group"
},
"outbound": {
"single": "Single Entry",
"import": "Batch Import",
"sku": "SKU",
"archiveNo": "Archive No.",
"outTime": "Outbound Time",
"selectFile": "Select File",
"importing": "Importing…",
"importResult": "Import Result",
"successCount": "Success",
"failCount": "Failed",
"downloadResult": "Download Details",
"tip": "Download the template first, fill it in and upload (xlsx)"
},
"blockchain": {
"title": "Blockchain Attestation",
"dataHash": "Data Hash",
"txHash": "Tx Hash",
"blockHeight": "Block Height",
"onchainAt": "On-chain Time",
"explorer": "Explorer",
"trigger": "Trigger On-chain",
"triggered": "On-chain task submitted"
},
"queryLog": {
"result": "Result",
"ip": "IP / Region",
"device": "Device",
"queriedAt": "Time",
"startTime": "Start",
"endTime": "End"
},
"user": {
"username": "Username",
"realName": "Name",
"role": "Role",
"create": "New User",
"edit": "Edit User",
"resetPassword": "Reset Password",
"newPassword": "New Password",
"lastLoginAt": "Last Login"
},
"settings": {
"appName": "Platform Name",
"logRetentionDays": "Log Retention (days)",
"watermarkText": "Certificate Watermark",
"saved": "Settings saved"
},
"profile": {
"title": "Profile",
"oldPassword": "Current Password",
"newPassword": "New Password",
"confirmPassword": "Confirm Password",
"passwordMismatch": "Passwords do not match",
"changed": "Password changed, please log in again"
}
}
}
-105
View File
@@ -1,105 +0,0 @@
{
"action": {
"add": "Add",
"edit": "Edit",
"delete": "Delete",
"save": "Save",
"cancel": "Cancel",
"confirm": "OK",
"search": "Search",
"reset": "Reset",
"export": "Export",
"download": "Download",
"downloadTemplate": "Template",
"upload": "Upload",
"view": "View",
"detail": "Detail",
"back": "Back",
"submit": "Submit",
"refresh": "Refresh",
"generate": "Generate",
"bind": "Bind",
"unbind": "Unbind",
"retry": "Retry",
"copy": "Copy",
"onchain": "On-chain",
"qrcode": "QR Code",
"changePassword": "Change Password",
"logout": "Logout"
},
"label": {
"keyword": "Keyword",
"status": "Status",
"type": "Type",
"createdAt": "Created",
"updatedAt": "Updated",
"operation": "Actions",
"all": "All",
"remark": "Remark",
"total": "{n} items",
"yes": "Yes",
"no": "No"
},
"status": {
"ENABLED": "Enabled",
"DISABLED": "Disabled",
"DRAFT": "Draft",
"ACTIVE": "Activated",
"ABNORMAL": "Abnormal",
"UNBOUND": "Unbound",
"INACTIVE": "Inactive",
"PENDING": "Pending",
"PROCESSING": "Processing",
"SUCCESS": "Success",
"PARTIAL": "Partial",
"FAILED": "Failed",
"ONCHAIN": "On-chain",
"GENERATING": "Generating",
"DONE": "Done"
},
"role": {
"SUPER_ADMIN": "Super Admin",
"OPERATOR": "Operator",
"AUDITOR": "Auditor",
"VIEWER": "Viewer"
},
"queryResult": {
"FIRST_ACTIVATE": "First Activation",
"REPEAT": "Repeat",
"INVALID": "Invalid",
"DISABLED": "Disabled",
"ABNORMAL": "Abnormal"
},
"fieldType": {
"TEXT": "Text",
"NUMBER": "Number",
"DATE": "Date",
"IMAGE": "Image",
"FILE": "File",
"LINK": "Link",
"TEXTAREA": "Textarea"
},
"nodeType": {
"CREATE": "Creation",
"PRODUCE": "Production",
"STORAGE": "Storage",
"OUTBOUND": "Outbound",
"OTHER": "Other"
},
"msg": {
"confirmDelete": "Delete this record?",
"deleted": "Deleted",
"saved": "Saved",
"created": "Created",
"updated": "Updated",
"copied": "Copied",
"operationSuccess": "Success",
"loginExpired": "Session expired, please log in again",
"networkError": "Network error, please try again",
"noData": "No data"
},
"lang": {
"zh": "中文",
"en": "English"
}
}
-11
View File
@@ -1,11 +0,0 @@
{
"dashboard": "Dashboard",
"templates": "Templates",
"artworks": "Artworks",
"traceCodes": "Trace Codes",
"outbound": "Outbound & Chain",
"queryLogs": "Query Logs",
"users": "Users",
"settings": "Settings",
"profile": "Profile"
}
-143
View File
@@ -1,143 +0,0 @@
{
"login": {
"title": "Artwork Traceability & Authentication",
"subtitle": "Management Console",
"username": "Username",
"password": "Password",
"submit": "Sign In",
"placeholderUser": "Enter username",
"placeholderPass": "Enter password",
"success": "Signed in"
},
"dashboard": {
"totalArtworks": "Artworks",
"boundCodes": "Bound Codes",
"activatedCodes": "Activated Codes",
"totalQueries": "Total Queries",
"todayQueries": "Today",
"abnormalQueries": "Abnormal",
"trendTitle": "Queries (Last 7 Days)",
"topTitle": "Top Queried Artworks",
"queryCount": "Queries",
"rank": "Rank"
},
"template": {
"name": "Template Name",
"fields": "Fields",
"fieldKey": "Field Key",
"fieldLabel": "Label",
"fieldType": "Type",
"required": "Required",
"sortOrder": "Order",
"addField": "Add Field",
"useCount": "Used By",
"create": "New Template",
"edit": "Edit Template",
"namePlaceholder": "Enter template name",
"fieldKeyTip": "Unique key, e.g. craft"
},
"artwork": {
"title": "Title",
"artist": "Artist",
"template": "Template",
"images": "Images",
"basicInfo": "Basic Info",
"dynamicFields": "Fields",
"nodes": "Timeline",
"certificates": "Certificates",
"traceCode": "Trace Code",
"status": "Status",
"create": "New Artwork",
"edit": "Edit Artwork",
"detail": "Artwork Detail",
"addNode": "Add Node",
"nodeTitle": "Node Title",
"nodeLocation": "Location",
"nodeTime": "Time",
"nodeDesc": "Description",
"addCert": "Add Certificate",
"certName": "Certificate Name",
"certIssuer": "Issuer",
"certType": "Type",
"originFile": "Original File",
"watermarkPreview": "Watermark",
"watermarkPending": "Generating watermark…",
"bindCode": "Bind Trace Code",
"noTrace": "No trace code bound"
},
"traceCode": {
"batches": "Batches",
"codes": "Trace Codes",
"batchNo": "Batch No.",
"quantity": "Quantity",
"generate": "Generate",
"generatedCount": "Generated",
"shortCode": "Short Code",
"code": "Trace Code",
"url": "Short URL",
"queryCount": "Queries",
"firstActivatedAt": "First Activated",
"exportBatch": "Export Batch",
"bindArtwork": "Bind Artwork",
"selectArtwork": "Select artwork",
"qrPreview": "QR Preview",
"generating": "Generating, please wait…",
"genSuccess": "Generation task submitted"
},
"outbound": {
"single": "Single Entry",
"import": "Batch Import",
"sku": "SKU",
"archiveNo": "Archive No.",
"outTime": "Outbound Time",
"selectFile": "Select File",
"importing": "Importing…",
"importResult": "Import Result",
"successCount": "Success",
"failCount": "Failed",
"downloadResult": "Download Details",
"tip": "Download the template first, fill it in and upload (xlsx)"
},
"blockchain": {
"title": "Blockchain Attestation",
"dataHash": "Data Hash",
"txHash": "Tx Hash",
"blockHeight": "Block Height",
"onchainAt": "On-chain Time",
"explorer": "Explorer",
"trigger": "Trigger On-chain",
"triggered": "On-chain task submitted"
},
"queryLog": {
"result": "Result",
"ip": "IP / Region",
"device": "Device",
"queriedAt": "Time",
"startTime": "Start",
"endTime": "End"
},
"user": {
"username": "Username",
"realName": "Name",
"role": "Role",
"create": "New User",
"edit": "Edit User",
"resetPassword": "Reset Password",
"newPassword": "New Password",
"lastLoginAt": "Last Login"
},
"settings": {
"appName": "Platform Name",
"logRetentionDays": "Log Retention (days)",
"watermarkText": "Certificate Watermark",
"saved": "Settings saved"
},
"profile": {
"title": "Profile",
"oldPassword": "Current Password",
"newPassword": "New Password",
"confirmPassword": "Confirm Password",
"passwordMismatch": "Passwords do not match",
"changed": "Password changed, please log in again"
}
}
+8 -10
View File
@@ -1,22 +1,20 @@
import { createI18n } from 'vue-i18n';
import zhCommon from './zh-CN/common.json';
import zhMenu from './zh-CN/menu.json';
import zhPages from './zh-CN/pages.json';
import enCommon from './en-US/common.json';
import enMenu from './en-US/menu.json';
import enPages from './en-US/pages.json';
import zhCN from './zh-CN.json';
import enUS from './en-US.json';
// 新增语言:在本目录添加 <locale>.json(与 zh-CN.json 同构),并在此注册即可。
export const SUPPORTED_LOCALES = [
{ value: 'zh-CN', label: '中文' },
{ value: 'en-US', label: 'English' },
];
const STORAGE_KEY = 'artveris_locale';
const DEFAULT_LOCALE = 'zh-CN';
export function getInitialLocale(): string {
const saved = localStorage.getItem(STORAGE_KEY);
if (saved && SUPPORTED_LOCALES.some((l) => l.value === saved)) return saved;
return navigator.language.startsWith('en') ? 'en-US' : 'zh-CN';
return DEFAULT_LOCALE;
}
export function setLocale(locale: string): void {
@@ -28,9 +26,9 @@ export function setLocale(locale: string): void {
export const i18n = createI18n({
legacy: false,
locale: getInitialLocale(),
fallbackLocale: 'zh-CN',
fallbackLocale: DEFAULT_LOCALE,
messages: {
'zh-CN': { common: zhCommon, menu: zhMenu, pages: zhPages },
'en-US': { common: enCommon, menu: enMenu, pages: enPages },
'zh-CN': zhCN,
'en-US': enUS,
},
});
+280
View File
@@ -0,0 +1,280 @@
{
"common": {
"action": {
"add": "新增",
"edit": "编辑",
"delete": "删除",
"save": "保存",
"cancel": "取消",
"confirm": "确定",
"search": "查询",
"reset": "重置",
"export": "导出",
"download": "下载",
"downloadTemplate": "下载模板",
"upload": "上传",
"view": "查看",
"detail": "详情",
"back": "返回",
"submit": "提交",
"refresh": "刷新",
"generate": "生成",
"bind": "绑定",
"unbind": "解绑",
"retry": "重试",
"copy": "复制",
"onchain": "上链存证",
"qrcode": "二维码",
"manage": "管理",
"apply": "应用",
"open": "打开",
"changePassword": "修改密码",
"logout": "退出登录"
},
"label": {
"keyword": "关键词",
"status": "状态",
"type": "类型",
"createdAt": "创建时间",
"updatedAt": "更新时间",
"operation": "操作",
"all": "全部",
"remark": "备注",
"total": "共 {n} 条",
"yes": "是",
"no": "否"
},
"status": {
"ENABLED": "启用",
"DISABLED": "停用",
"DRAFT": "草稿",
"ACTIVE": "已激活",
"ABNORMAL": "异常",
"UNBOUND": "未绑定",
"INACTIVE": "未激活",
"PENDING": "等待中",
"PROCESSING": "处理中",
"SUCCESS": "成功",
"PARTIAL": "部分成功",
"FAILED": "失败",
"ONCHAIN": "已上链",
"GENERATING": "生成中",
"DONE": "已完成"
},
"role": {
"SUPER_ADMIN": "超级管理员",
"OPERATOR": "平台运营",
"AUDITOR": "审核员",
"VIEWER": "只读监管"
},
"queryResult": {
"FIRST_ACTIVATE": "首次激活",
"REPEAT": "重复查询",
"INVALID": "无效",
"DISABLED": "停用",
"ABNORMAL": "异常"
},
"fieldType": {
"TEXT": "文本",
"NUMBER": "数字",
"DATE": "日期",
"IMAGE": "图片",
"FILE": "文件",
"LINK": "链接",
"TEXTAREA": "多行文本"
},
"nodeType": {
"CREATE": "创作",
"PRODUCE": "制作",
"STORAGE": "仓储",
"OUTBOUND": "出库",
"OTHER": "其他"
},
"theme": {
"title": "主题",
"light": "日间",
"dark": "夜间",
"auto": "跟随系统"
},
"msg": {
"confirmDelete": "确认删除该条数据?",
"deleted": "删除成功",
"saved": "保存成功",
"created": "创建成功",
"updated": "更新成功",
"copied": "已复制",
"operationSuccess": "操作成功",
"loginExpired": "登录已过期,请重新登录",
"networkError": "网络异常,请稍后再试",
"noData": "暂无数据"
},
"lang": { "zh": "中文", "en": "English" }
},
"menu": {
"dashboard": "数据看板",
"templates": "溯源模板",
"artworks": "艺术品建档",
"traceCodes": "追溯码管理",
"outbound": "出库与上链",
"queryLogs": "查询日志",
"users": "用户管理",
"settings": "系统设置",
"profile": "个人中心"
},
"pages": {
"login": {
"title": "艺术品可信溯源与认证平台",
"subtitle": "运营管理后台",
"username": "用户名",
"password": "密码",
"submit": "登 录",
"placeholderUser": "请输入用户名",
"placeholderPass": "请输入密码",
"success": "登录成功"
},
"dashboard": {
"totalArtworks": "作品总数",
"boundCodes": "已绑定追溯码",
"activatedCodes": "已激活追溯码",
"totalQueries": "总查询次数",
"todayQueries": "今日查询",
"abnormalQueries": "异常查询",
"trendTitle": "近 7 日查询趋势",
"topTitle": "高频查询作品榜",
"queryCount": "查询次数",
"rank": "排名"
},
"template": {
"name": "模板名称",
"fields": "字段配置",
"fieldKey": "字段键",
"fieldLabel": "字段名称",
"fieldType": "字段类型",
"required": "必填",
"sortOrder": "排序",
"addField": "添加字段",
"useCount": "使用作品数",
"create": "新建模板",
"edit": "编辑模板",
"namePlaceholder": "请输入模板名称",
"fieldKeyTip": "英文唯一标识,如 craft"
},
"artwork": {
"title": "作品名称",
"artist": "艺术家",
"template": "所属模板",
"images": "作品图片",
"basicInfo": "基础信息",
"dynamicFields": "动态字段",
"nodes": "溯源时间轴",
"certificates": "认证文件",
"traceCode": "追溯码",
"status": "状态",
"create": "新建作品",
"edit": "编辑作品",
"detail": "作品详情",
"addNode": "添加节点",
"nodeTitle": "节点标题",
"nodeLocation": "地点",
"nodeTime": "发生时间",
"nodeDesc": "说明",
"addCert": "添加认证文件",
"certName": "证书名称",
"certIssuer": "颁发机构",
"certType": "类型",
"originFile": "原始文件",
"watermarkPreview": "水印预览",
"watermarkPending": "水印生成中…",
"bindCode": "绑定追溯码",
"noTrace": "未绑定追溯码"
},
"traceCode": {
"batches": "批次列表",
"codes": "追溯码列表",
"batchNo": "批次编号",
"quantity": "数量",
"generate": "生成追溯码",
"generatedCount": "已生成",
"shortCode": "短码",
"code": "追溯码",
"url": "短链",
"queryCount": "查询次数",
"firstActivatedAt": "首次激活时间",
"exportBatch": "导出本批",
"bindArtwork": "绑定作品",
"selectArtwork": "选择作品",
"qrPreview": "二维码预览",
"generating": "正在生成,请稍候…",
"genSuccess": "生码任务已提交",
"group": "分组",
"groups": "分组",
"allGroups": "全部分组",
"noGroup": "未分组",
"manageGroups": "分组管理",
"createGroup": "新建分组",
"editGroup": "编辑分组",
"groupName": "分组名称",
"batchGroup": "批量分组",
"batchEnable": "批量启用",
"batchDisable": "批量停用",
"selected": "已选 {n} 项",
"assignGroup": "设为分组"
},
"outbound": {
"single": "单条录入",
"import": "批量导入",
"sku": "SKU",
"archiveNo": "档案编号",
"outTime": "出库时间",
"selectFile": "选择文件",
"importing": "导入中…",
"importResult": "导入结果",
"successCount": "成功",
"failCount": "失败",
"downloadResult": "下载结果明细",
"tip": "请先下载模板,按模板填写后上传(支持 xlsx)"
},
"blockchain": {
"title": "区块链存证",
"dataHash": "数据哈希",
"txHash": "交易哈希",
"blockHeight": "区块高度",
"onchainAt": "上链时间",
"explorer": "存证查询",
"trigger": "触发上链",
"triggered": "已提交上链任务"
},
"queryLog": {
"result": "查询结果",
"ip": "IP / 地区",
"device": "设备信息",
"queriedAt": "查询时间",
"startTime": "开始时间",
"endTime": "结束时间"
},
"user": {
"username": "用户名",
"realName": "姓名",
"role": "角色",
"create": "新建用户",
"edit": "编辑用户",
"resetPassword": "重置密码",
"newPassword": "新密码",
"lastLoginAt": "最近登录"
},
"settings": {
"appName": "平台名称",
"logRetentionDays": "日志保留天数",
"watermarkText": "证书水印文案",
"saved": "设置已保存"
},
"profile": {
"title": "个人中心",
"oldPassword": "原密码",
"newPassword": "新密码",
"confirmPassword": "确认新密码",
"passwordMismatch": "两次密码不一致",
"changed": "密码修改成功,请重新登录"
}
}
}
-105
View File
@@ -1,105 +0,0 @@
{
"action": {
"add": "新增",
"edit": "编辑",
"delete": "删除",
"save": "保存",
"cancel": "取消",
"confirm": "确定",
"search": "查询",
"reset": "重置",
"export": "导出",
"download": "下载",
"downloadTemplate": "下载模板",
"upload": "上传",
"view": "查看",
"detail": "详情",
"back": "返回",
"submit": "提交",
"refresh": "刷新",
"generate": "生成",
"bind": "绑定",
"unbind": "解绑",
"retry": "重试",
"copy": "复制",
"onchain": "上链存证",
"qrcode": "二维码",
"changePassword": "修改密码",
"logout": "退出登录"
},
"label": {
"keyword": "关键词",
"status": "状态",
"type": "类型",
"createdAt": "创建时间",
"updatedAt": "更新时间",
"operation": "操作",
"all": "全部",
"remark": "备注",
"total": "共 {n} 条",
"yes": "是",
"no": "否"
},
"status": {
"ENABLED": "启用",
"DISABLED": "停用",
"DRAFT": "草稿",
"ACTIVE": "已激活",
"ABNORMAL": "异常",
"UNBOUND": "未绑定",
"INACTIVE": "未激活",
"PENDING": "等待中",
"PROCESSING": "处理中",
"SUCCESS": "成功",
"PARTIAL": "部分成功",
"FAILED": "失败",
"ONCHAIN": "已上链",
"GENERATING": "生成中",
"DONE": "已完成"
},
"role": {
"SUPER_ADMIN": "超级管理员",
"OPERATOR": "平台运营",
"AUDITOR": "审核员",
"VIEWER": "只读监管"
},
"queryResult": {
"FIRST_ACTIVATE": "首次激活",
"REPEAT": "重复查询",
"INVALID": "无效",
"DISABLED": "停用",
"ABNORMAL": "异常"
},
"fieldType": {
"TEXT": "文本",
"NUMBER": "数字",
"DATE": "日期",
"IMAGE": "图片",
"FILE": "文件",
"LINK": "链接",
"TEXTAREA": "多行文本"
},
"nodeType": {
"CREATE": "创作",
"PRODUCE": "制作",
"STORAGE": "仓储",
"OUTBOUND": "出库",
"OTHER": "其他"
},
"msg": {
"confirmDelete": "确认删除该条数据?",
"deleted": "删除成功",
"saved": "保存成功",
"created": "创建成功",
"updated": "更新成功",
"copied": "已复制",
"operationSuccess": "操作成功",
"loginExpired": "登录已过期,请重新登录",
"networkError": "网络异常,请稍后再试",
"noData": "暂无数据"
},
"lang": {
"zh": "中文",
"en": "English"
}
}
-11
View File
@@ -1,11 +0,0 @@
{
"dashboard": "数据看板",
"templates": "溯源模板",
"artworks": "艺术品建档",
"traceCodes": "追溯码管理",
"outbound": "出库与上链",
"queryLogs": "查询日志",
"users": "用户管理",
"settings": "系统设置",
"profile": "个人中心"
}
-143
View File
@@ -1,143 +0,0 @@
{
"login": {
"title": "艺术品可信溯源与认证平台",
"subtitle": "运营管理后台",
"username": "用户名",
"password": "密码",
"submit": "登 录",
"placeholderUser": "请输入用户名",
"placeholderPass": "请输入密码",
"success": "登录成功"
},
"dashboard": {
"totalArtworks": "作品总数",
"boundCodes": "已绑定追溯码",
"activatedCodes": "已激活追溯码",
"totalQueries": "总查询次数",
"todayQueries": "今日查询",
"abnormalQueries": "异常查询",
"trendTitle": "近 7 日查询趋势",
"topTitle": "高频查询作品榜",
"queryCount": "查询次数",
"rank": "排名"
},
"template": {
"name": "模板名称",
"fields": "字段配置",
"fieldKey": "字段键",
"fieldLabel": "字段名称",
"fieldType": "字段类型",
"required": "必填",
"sortOrder": "排序",
"addField": "添加字段",
"useCount": "使用作品数",
"create": "新建模板",
"edit": "编辑模板",
"namePlaceholder": "请输入模板名称",
"fieldKeyTip": "英文唯一标识,如 craft"
},
"artwork": {
"title": "作品名称",
"artist": "艺术家",
"template": "所属模板",
"images": "作品图片",
"basicInfo": "基础信息",
"dynamicFields": "动态字段",
"nodes": "溯源时间轴",
"certificates": "认证文件",
"traceCode": "追溯码",
"status": "状态",
"create": "新建作品",
"edit": "编辑作品",
"detail": "作品详情",
"addNode": "添加节点",
"nodeTitle": "节点标题",
"nodeLocation": "地点",
"nodeTime": "发生时间",
"nodeDesc": "说明",
"addCert": "添加认证文件",
"certName": "证书名称",
"certIssuer": "颁发机构",
"certType": "类型",
"originFile": "原始文件",
"watermarkPreview": "水印预览",
"watermarkPending": "水印生成中…",
"bindCode": "绑定追溯码",
"noTrace": "未绑定追溯码"
},
"traceCode": {
"batches": "批次列表",
"codes": "追溯码列表",
"batchNo": "批次编号",
"quantity": "数量",
"generate": "生成追溯码",
"generatedCount": "已生成",
"shortCode": "短码",
"code": "追溯码",
"url": "短链",
"queryCount": "查询次数",
"firstActivatedAt": "首次激活时间",
"exportBatch": "导出本批",
"bindArtwork": "绑定作品",
"selectArtwork": "选择作品",
"qrPreview": "二维码预览",
"generating": "正在生成,请稍候…",
"genSuccess": "生码任务已提交"
},
"outbound": {
"single": "单条录入",
"import": "批量导入",
"sku": "SKU",
"archiveNo": "档案编号",
"outTime": "出库时间",
"selectFile": "选择文件",
"importing": "导入中…",
"importResult": "导入结果",
"successCount": "成功",
"failCount": "失败",
"downloadResult": "下载结果明细",
"tip": "请先下载模板,按模板填写后上传(支持 xlsx)"
},
"blockchain": {
"title": "区块链存证",
"dataHash": "数据哈希",
"txHash": "交易哈希",
"blockHeight": "区块高度",
"onchainAt": "上链时间",
"explorer": "存证查询",
"trigger": "触发上链",
"triggered": "已提交上链任务"
},
"queryLog": {
"result": "查询结果",
"ip": "IP / 地区",
"device": "设备信息",
"queriedAt": "查询时间",
"startTime": "开始时间",
"endTime": "结束时间"
},
"user": {
"username": "用户名",
"realName": "姓名",
"role": "角色",
"create": "新建用户",
"edit": "编辑用户",
"resetPassword": "重置密码",
"newPassword": "新密码",
"lastLoginAt": "最近登录"
},
"settings": {
"appName": "平台名称",
"logRetentionDays": "日志保留天数",
"watermarkText": "证书水印文案",
"saved": "设置已保存"
},
"profile": {
"title": "个人中心",
"oldPassword": "原密码",
"newPassword": "新密码",
"confirmPassword": "确认新密码",
"passwordMismatch": "两次密码不一致",
"changed": "密码修改成功,请重新登录"
}
}
+6 -3
View File
@@ -1,3 +1,9 @@
:root {
--brand: #13a8a8;
--brand-2: #1bb6b6;
--brand-from: #0f8f8f;
--brand-to: #1bb6b6;
}
* {
box-sizing: border-box;
}
@@ -10,9 +16,6 @@ body,
font-family: 'Microsoft YaHei', 'PingFang SC', -apple-system, BlinkMacSystemFont, 'Segoe UI',
Roboto, sans-serif;
}
body {
background: #f0f2f5;
}
.page {
padding: 16px;
}
+11 -36
View File
@@ -1,49 +1,24 @@
import type { GlobalThemeOverrides } from 'naive-ui';
// 商务深蓝主色 + 统一设计令牌
// 清凉主色(青绿色系),其余沿用 Naive 官方主题,保证日间/夜间所有控件覆盖。
export const BRAND = {
primary: '#1f3864',
primaryHover: '#2e5496',
primaryPressed: '#162a4d',
primarySuppl: '#2e5496',
primary: '#13a8a8',
hover: '#1fbcbc',
pressed: '#0e8c8c',
gradientFrom: '#0f8f8f',
gradientTo: '#1bb6b6',
radius: '8px',
};
export const themeOverrides: GlobalThemeOverrides = {
common: {
primaryColor: BRAND.primary,
primaryColorHover: BRAND.primaryHover,
primaryColorPressed: BRAND.primaryPressed,
primaryColorSuppl: BRAND.primarySuppl,
infoColor: BRAND.primaryHover,
primaryColorHover: BRAND.hover,
primaryColorPressed: BRAND.pressed,
primaryColorSuppl: BRAND.hover,
infoColor: BRAND.primary,
borderRadius: BRAND.radius,
borderRadiusSmall: '6px',
fontSize: '14px',
fontWeightStrong: '600',
},
Card: {
borderRadius: '12px',
},
Button: {
borderRadiusMedium: BRAND.radius,
},
DataTable: {
thColor: '#f4f7fc',
thTextColor: '#1f2937',
borderRadius: BRAND.radius,
},
Layout: {
siderColor: '#1f2a44',
},
Menu: {
itemTextColorInverted: 'rgba(255,255,255,0.82)',
itemIconColorInverted: 'rgba(255,255,255,0.82)',
itemTextColorHoverInverted: '#ffffff',
itemIconColorHoverInverted: '#ffffff',
itemColorActiveInverted: BRAND.primaryHover,
itemColorActiveHoverInverted: BRAND.primaryHover,
itemTextColorActiveInverted: '#ffffff',
itemIconColorActiveInverted: '#ffffff',
itemTextColorChildActiveInverted: '#ffffff',
},
Card: { borderRadius: '12px' },
};
+2 -3
View File
@@ -123,12 +123,11 @@ onMounted(async () => {
.stat-value {
font-size: 28px;
font-weight: 700;
color: #1f2937;
line-height: 1.2;
}
.stat-label {
font-size: 13px;
color: #6b7280;
opacity: 0.6;
}
.mt16 {
margin-top: 16px;
@@ -147,6 +146,6 @@ onMounted(async () => {
}
.top-count {
font-weight: 600;
color: #2e5496;
color: var(--brand);
}
</style>
+4 -19
View File
@@ -1,13 +1,7 @@
<template>
<div class="login-wrap">
<div class="login-lang">
<n-select
v-model:value="currentLocale"
:options="localeOptions"
size="small"
style="width: 120px"
@update:value="changeLocale"
/>
<lang-switch />
</div>
<div class="login-left">
<div class="login-left-inner">
@@ -56,29 +50,22 @@ import { useI18n } from 'vue-i18n';
import type { FormInst, FormRules } from 'naive-ui';
import { PersonOutline, LockClosedOutline } from '@vicons/ionicons5';
import { useAuthStore } from '@/stores/auth';
import { SUPPORTED_LOCALES, setLocale } from '@/locales';
import { message } from '@/utils/feedback';
import LangSwitch from '@/components/LangSwitch.vue';
const { t, locale } = useI18n();
const { t } = useI18n();
const router = useRouter();
const auth = useAuthStore();
const formRef = ref<FormInst | null>(null);
const form = ref({ username: '', password: '' });
const loading = ref(false);
const currentLocale = ref(locale.value);
const localeOptions = SUPPORTED_LOCALES.map((l) => ({ label: l.label, value: l.value }));
const rules: FormRules = {
username: { required: true, message: () => t('pages.login.placeholderUser'), trigger: 'blur' },
password: { required: true, message: () => t('pages.login.placeholderPass'), trigger: 'blur' },
};
function changeLocale(val: string) {
setLocale(val);
currentLocale.value = val;
}
async function onSubmit() {
try {
await formRef.value?.validate();
@@ -103,7 +90,6 @@ async function onSubmit() {
position: relative;
display: flex;
height: 100vh;
background: #f0f2f5;
}
.login-lang {
position: absolute;
@@ -113,7 +99,7 @@ async function onSubmit() {
}
.login-left {
flex: 1 1 55%;
background: linear-gradient(135deg, #1f3864 0%, #2e5496 100%);
background: linear-gradient(135deg, var(--brand-from) 0%, var(--brand-to) 100%);
color: #fff;
display: flex;
align-items: center;
@@ -158,7 +144,6 @@ async function onSubmit() {
.login-card-title {
margin: 0 0 24px;
font-size: 22px;
color: #1f2937;
text-align: center;
}
@media (max-width: 768px) {
+167 -34
View File
@@ -1,12 +1,20 @@
<template>
<div class="page">
<div class="page-toolbar">
<n-select
v-model:value="query.groupId"
:options="groupFilterOptions"
clearable
:placeholder="t('pages.traceCode.allGroups')"
style="width: 170px"
@update:value="onSearch"
/>
<n-select
v-model:value="query.batchId"
:options="batchOptions"
clearable
:placeholder="t('pages.traceCode.batchNo')"
style="width: 200px"
style="width: 190px"
@update:value="onSearch"
/>
<n-select
@@ -14,14 +22,14 @@
:options="statusOptions"
clearable
:placeholder="t('common.label.status')"
style="width: 140px"
style="width: 130px"
@update:value="onSearch"
/>
<n-input
v-model:value="query.keyword"
:placeholder="t('pages.traceCode.shortCode')"
clearable
style="width: 180px"
style="width: 160px"
@keyup.enter="onSearch"
/>
<n-button type="primary" @click="onSearch">
@@ -29,6 +37,10 @@
{{ t('common.action.search') }}
</n-button>
<div class="spacer" />
<n-button v-if="auth.canWrite" @click="groupModal = true">
<template #icon><n-icon :component="FolderOutline" /></template>
{{ t('pages.traceCode.manageGroups') }}
</n-button>
<n-button v-if="auth.canWrite && query.batchId" @click="exportBatch">
<template #icon><n-icon :component="DownloadOutline" /></template>
{{ t('pages.traceCode.exportBatch') }}
@@ -39,6 +51,21 @@
</n-button>
</div>
<!-- 批量操作条 -->
<n-card v-if="auth.canWrite && checkedKeys.length" size="small" class="batch-bar" :bordered="false">
<n-space align="center">
<span>{{ t('pages.traceCode.selected', { n: checkedKeys.length }) }}</span>
<n-dropdown trigger="click" :options="groupAssignOptions" @select="batchAssignGroup">
<n-button size="small">
<template #icon><n-icon :component="FolderOutline" /></template>
{{ t('pages.traceCode.batchGroup') }}
</n-button>
</n-dropdown>
<n-button size="small" @click="batchStatus(false)">{{ t('pages.traceCode.batchEnable') }}</n-button>
<n-button size="small" type="warning" @click="batchStatus(true)">{{ t('pages.traceCode.batchDisable') }}</n-button>
</n-space>
</n-card>
<n-data-table
:columns="columns"
:data="rows"
@@ -46,14 +73,19 @@
:pagination="pagination"
remote
:row-key="(r) => r.id"
v-model:checked-row-keys="checkedKeys"
@update:page="onPage"
/>
<n-modal v-model:show="genModal" preset="card" :title="t('pages.traceCode.generate')" style="width: 420px">
<!-- 生成 -->
<n-modal v-model:show="genModal" preset="card" :title="t('pages.traceCode.generate')" style="width: 440px">
<n-form :model="genForm" label-placement="top">
<n-form-item :label="t('pages.traceCode.quantity')">
<n-input-number v-model:value="genForm.quantity" :min="1" :max="10000" style="width: 100%" />
</n-form-item>
<n-form-item :label="t('pages.traceCode.group')">
<n-select v-model:value="genForm.groupId" :options="groupPlainOptions" clearable :placeholder="t('pages.traceCode.noGroup')" />
</n-form-item>
<n-form-item :label="t('pages.traceCode.batchNo')">
<n-input v-model:value="genForm.batchNo" placeholder="(auto)" />
</n-form-item>
@@ -67,24 +99,47 @@
</template>
</n-modal>
<!-- 二维码 -->
<n-modal v-model:show="qrModal" preset="card" :title="t('pages.traceCode.qrPreview')" style="width: 360px">
<div style="text-align: center">
<img :src="qrSrc" alt="qrcode" style="width: 280px; height: 280px" />
<div style="margin-top: 8px; color: #6b7280; word-break: break-all">{{ qrUrl }}</div>
<div style="margin-top: 8px; opacity: 0.6; word-break: break-all">{{ qrUrl }}</div>
</div>
</n-modal>
<!-- 分组管理 -->
<n-modal v-model:show="groupModal" preset="card" :title="t('pages.traceCode.manageGroups')" style="width: 520px">
<div class="page-toolbar">
<n-input v-model:value="groupForm.name" :placeholder="t('pages.traceCode.groupName')" style="width: 200px" />
<n-button type="primary" :disabled="!groupForm.name" @click="saveGroup">
{{ editingGroup ? t('common.action.save') : t('pages.traceCode.createGroup') }}
</n-button>
<n-button v-if="editingGroup" @click="resetGroupForm">{{ t('common.action.cancel') }}</n-button>
</div>
<n-list bordered>
<n-list-item v-for="g in groups" :key="g.id">
<div class="group-row">
<span>{{ g.name }}<n-text depth="3">({{ g._count?.traceCodes ?? 0 }})</n-text></span>
<span>
<n-button text type="primary" size="small" @click="editGroup(g)">{{ t('common.action.edit') }}</n-button>
<n-button text type="error" size="small" style="margin-left: 10px" @click="removeGroup(g)">{{ t('common.action.delete') }}</n-button>
</span>
</div>
</n-list-item>
</n-list>
</n-modal>
</div>
</template>
<script setup lang="ts">
import { h, onMounted, reactive, ref } from 'vue';
import { computed, h, onMounted, reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { NButton, NIcon, NTag, NText, type DataTableColumns } from 'naive-ui';
import { SearchOutline, AddOutline, DownloadOutline, QrCodeOutline } from '@vicons/ionicons5';
import { SearchOutline, AddOutline, DownloadOutline, QrCodeOutline, FolderOutline, OpenOutline } from '@vicons/ionicons5';
import { TraceCodeStatus } from '@artveris/shared';
import { traceCodeApi, jobApi } from '@/api';
import { useAuthStore } from '@/stores/auth';
import { message } from '@/utils/feedback';
import { message, dialog } from '@/utils/feedback';
import { fmt, statusType } from '@/utils/format';
import { downloadFile } from '@/utils/download';
@@ -93,7 +148,9 @@ const auth = useAuthStore();
const rows = ref<any[]>([]);
const loading = ref(false);
const query = reactive<{ batchId: number | null; status: string | null; keyword: string; page: number; pageSize: number }>({
const checkedKeys = ref<Array<string | number>>([]);
const query = reactive<{ groupId: number | null; batchId: number | null; status: string | null; keyword: string; page: number; pageSize: number }>({
groupId: null,
batchId: null,
status: null,
keyword: '',
@@ -102,57 +159,76 @@ const query = reactive<{ batchId: number | null; status: string | null; keyword:
});
const pagination = reactive({ page: 1, pageSize: 10, itemCount: 0 });
const statusOptions = Object.values(TraceCodeStatus).map((v) => ({ label: t(`common.status.${v}`), value: v }));
const batches = ref<any[]>([]);
const batchOptions = ref<{ label: string; value: number }[]>([]);
const groups = ref<any[]>([]);
const groupFilterOptions = computed(() => groups.value.map((g) => ({ label: g.name, value: g.id })));
const groupPlainOptions = computed(() => groups.value.map((g) => ({ label: g.name, value: g.id })));
const groupAssignOptions = computed(() => [
{ label: t('pages.traceCode.noGroup'), key: '__none__' },
...groups.value.map((g) => ({ label: g.name, key: String(g.id) })),
]);
const genModal = ref(false);
const generating = ref(false);
const genForm = reactive<{ quantity: number; batchNo: string }>({ quantity: 100, batchNo: '' });
const genForm = reactive<{ quantity: number; batchNo: string; groupId: number | null }>({ quantity: 100, batchNo: '', groupId: null });
const qrModal = ref(false);
const qrSrc = ref('');
const qrUrl = ref('');
const columns: DataTableColumns<any> = [
{ title: () => t('pages.traceCode.shortCode'), key: 'shortCode', width: 130 },
{ title: () => t('pages.traceCode.url'), key: 'url', ellipsis: { tooltip: true } },
const groupModal = ref(false);
const groupForm = reactive<{ name: string }>({ name: '' });
const editingGroup = ref<number | null>(null);
const columns = computed<DataTableColumns<any>>(() => [
{ type: 'selection' },
{ title: () => t('pages.traceCode.shortCode'), key: 'shortCode', width: 120 },
{
title: () => t('pages.artwork.title'),
key: 'artwork',
width: 150,
render: (r) => r.artwork?.title || '-',
title: () => t('pages.traceCode.url'),
key: 'url',
ellipsis: { tooltip: true },
render: (r) =>
h(
'a',
{ href: r.url, target: '_blank', rel: 'noopener', style: 'color: var(--brand); text-decoration: none' },
[r.url, h(NIcon, { component: OpenOutline, style: 'vertical-align:-2px;margin-left:4px' })],
),
},
{ title: () => t('pages.traceCode.group'), key: 'group', width: 110, render: (r) => r.group?.name || h(NText, { depth: 3 }, { default: () => t('pages.traceCode.noGroup') }) },
{ title: () => t('pages.artwork.title'), key: 'artwork', width: 140, render: (r) => r.artwork?.title || '-' },
{
title: () => t('common.label.status'),
key: 'status',
width: 100,
width: 96,
render: (r) => h(NTag, { size: 'small', type: statusType(r.status) }, { default: () => t(`common.status.${r.status}`) }),
},
{ title: () => t('pages.traceCode.queryCount'), key: 'queryCount', width: 90 },
{ title: () => t('pages.traceCode.firstActivatedAt'), key: 'firstActivatedAt', width: 160, render: (r) => fmt(r.firstActivatedAt) },
{ title: () => t('pages.traceCode.queryCount'), key: 'queryCount', width: 80 },
{
title: () => t('common.label.operation'),
key: 'ops',
width: 80,
width: 70,
render: (r) =>
h(
NButton,
{ quaternary: true, circle: true, size: 'small', onClick: () => showQr(r) },
{ icon: () => h(NIcon, null, { default: () => h(QrCodeOutline) }) },
),
h(NButton, { quaternary: true, circle: true, size: 'small', onClick: () => showQr(r) }, { icon: () => h(NIcon, null, { default: () => h(QrCodeOutline) }) }),
},
];
]);
async function loadBatches() {
const res: any = await traceCodeApi.batches({ pageSize: 100 });
batches.value = res.list;
batchOptions.value = res.list.map((b: any) => ({ label: `${b.batchNo} (${b.generatedCount}/${b.quantity})`, value: b.id }));
}
async function loadGroups() {
groups.value = await traceCodeApi.groups();
}
async function load() {
loading.value = true;
checkedKeys.value = [];
try {
const res: any = await traceCodeApi.list({
groupId: query.groupId || undefined,
batchId: query.batchId || undefined,
status: query.status || undefined,
keyword: query.keyword || undefined,
@@ -178,14 +254,16 @@ function onPage(p: number) {
async function generate() {
generating.value = true;
try {
const res: any = await traceCodeApi.generate({ quantity: genForm.quantity, batchNo: genForm.batchNo || undefined });
const res: any = await traceCodeApi.generate({
quantity: genForm.quantity,
batchNo: genForm.batchNo || undefined,
groupId: genForm.groupId || undefined,
});
message.success(t('pages.traceCode.genSuccess'));
// 轮询任务
const jobId = res.jobId;
for (let i = 0; i < 30; i++) {
await new Promise((r) => setTimeout(r, 700));
const job: any = await jobApi.get(jobId);
if (job.status === 'SUCCESS' || job.status === 'FAILED' || job.status === 'PARTIAL') break;
const job: any = await jobApi.get(res.jobId);
if (['SUCCESS', 'FAILED', 'PARTIAL'].includes(job.status)) break;
}
genModal.value = false;
await loadBatches();
@@ -200,14 +278,60 @@ function showQr(r: any) {
qrUrl.value = r.url;
qrModal.value = true;
}
async function exportBatch() {
if (!query.batchId) return;
await downloadFile('/trace-codes/export', `trace-codes-${query.batchId}.xlsx`, { batchId: query.batchId });
}
/* 批量操作 */
async function batchAssignGroup(key: string) {
const groupId = key === '__none__' ? null : Number(key);
await traceCodeApi.batchGroup(checkedKeys.value.map(String), groupId);
message.success(t('common.msg.operationSuccess'));
await load();
}
async function batchStatus(disabled: boolean) {
await traceCodeApi.batchStatus(checkedKeys.value.map(String), disabled);
message.success(t('common.msg.operationSuccess'));
await load();
}
/* 分组管理 */
function resetGroupForm() {
editingGroup.value = null;
groupForm.name = '';
}
function editGroup(g: any) {
editingGroup.value = g.id;
groupForm.name = g.name;
}
async function saveGroup() {
if (editingGroup.value) {
await traceCodeApi.updateGroup(editingGroup.value, { name: groupForm.name });
} else {
await traceCodeApi.createGroup({ name: groupForm.name });
}
message.success(t('common.msg.saved'));
resetGroupForm();
await loadGroups();
}
function removeGroup(g: any) {
dialog.warning({
title: t('common.action.delete'),
content: t('common.msg.confirmDelete'),
positiveText: t('common.action.confirm'),
negativeText: t('common.action.cancel'),
onPositiveClick: async () => {
await traceCodeApi.removeGroup(g.id);
message.success(t('common.msg.deleted'));
await loadGroups();
await load();
},
});
}
onMounted(async () => {
await loadBatches();
await Promise.all([loadBatches(), loadGroups()]);
await load();
});
</script>
@@ -216,4 +340,13 @@ onMounted(async () => {
.mr8 {
margin-right: 8px;
}
.batch-bar {
margin-bottom: 12px;
}
.group-row {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
}
</style>