diff --git a/frontend/src/pages/admin/cloud-variables/[id]/records.vue b/frontend/src/pages/admin/cloud-variables/[id]/records.vue index 13a4c0b..24e934a 100644 --- a/frontend/src/pages/admin/cloud-variables/[id]/records.vue +++ b/frontend/src/pages/admin/cloud-variables/[id]/records.vue @@ -8,9 +8,11 @@ import { useRoute, useRouter } from 'vue-router' import { toast } from 'vue-sonner' import ConfirmDialog from '@/components/confirm-dialog.vue' +import BulkActions from '@/components/data-table/bulk-actions.vue' import DataTable from '@/components/data-table/data-table.vue' import { SelectColumn } from '@/components/data-table/table-columns' import { generateVueTable } from '@/components/data-table/use-generate-vue-table' +import DataTableViewOptions from '@/components/data-table/view-options.vue' import { BasicPage } from '@/components/global-layout' import Badge from '@/components/ui/badge/Badge.vue' import Button from '@/components/ui/button/Button.vue' @@ -61,7 +63,7 @@ const dynamicKeys = computed(() => { Object.keys(record.data).forEach(key => keys.add(key)) } }) - return Array.from(keys) + return Array.from(keys).sort() }) const columns = computed[]>(() => { @@ -105,7 +107,7 @@ const columns = computed[]>(() => { if (typeof value === 'boolean') { return h(Badge, { variant: value ? 'default' : 'secondary' }, () => String(value)) } - return h('span', { class: 'truncate max-w-xs', title: String(value) }, String(value)) + return h('span', { class: 'truncate max-w-xs block', title: String(value) }, String(value)) }, size: 150, }) @@ -134,13 +136,7 @@ const columns = computed[]>(() => { try { const date = new Date(createdAt) if (Number.isNaN(date.getTime())) return '-' - return h('span', { class: 'text-muted-foreground text-xs' }, date.toLocaleString('zh-CN', { - year: 'numeric', - month: '2-digit', - day: '2-digit', - hour: '2-digit', - minute: '2-digit', - })) + return h('span', { class: 'text-muted-foreground text-xs' }, date.toLocaleString()) } catch { return '-' @@ -188,6 +184,21 @@ const table = generateVueTable({ serverPagination: serverPagination.value, }) +const columnLabels = computed(() => { + const labels: Record = { + select: 'admin.cloudVariables.select', + id: 'ID', + created_at: 'admin.cloudVariables.records.createdAt', + } + if (variable.value?.scope === 'user') { + labels.user = 'admin.cloudVariables.records.user' + } + dynamicKeys.value.forEach((key) => { + labels[`data_${key}`] = key + }) + return labels +}) + watch([page, pageSize], () => { fetchRecords() }) @@ -203,7 +214,7 @@ async function fetchVariable() { } } catch (error) { - console.error('获取变量信息失败:', error) + console.error('Fetch variable failed:', error) } } @@ -224,7 +235,7 @@ async function fetchRecords() { total.value = data?.total || 0 } catch (error) { - console.error('获取记录失败:', error) + console.error('Fetch records failed:', error) } finally { loading.value = false @@ -306,63 +317,122 @@ onMounted(async () => { ]" sticky > -
-
-
-
- - -
- - - -
-
- -
+
+
+ + + + {{ t('admin.cloudVariables.records.totalRecords') }} + + + + +
+ {{ total }} +
+
+
+ + + + + {{ t('admin.cloudVariables.types.stream') }} + + + +
+ {{ variable?.key || '-' }} +
+
+
+ + + + + {{ t('admin.cloudVariables.records.maxRecordsLabel') }} + + + +
+ {{ variable?.max_records || t('admin.cloudVariables.records.unlimited') }} +
+
+
+ + + + + {{ t('admin.cloudVariables.columns.scope') }} + + + +
+ {{ variable?.scope === 'user' ? t('admin.cloudVariables.userScope') : t('admin.cloudVariables.appScope') }} +
+
+
-
-
- - {{ t('admin.cloudVariables.types.stream') }} -
- · - {{ t('admin.cloudVariables.records.total', { count: total }) }} - · - {{ t('admin.cloudVariables.records.maxRecords', { count: variable.max_records }) }} -
- - + + + + + + +