From d2ec5a7498e81eb1cade3d8360d2c5c445a37878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A3=8A?= <13466513767@163.com> Date: Tue, 12 May 2026 10:06:41 +0800 Subject: [PATCH] =?UTF-8?q?'=E5=AD=97=E6=AE=B5=E5=90=8D=E7=A7=B0=E6=9B=B4?= =?UTF-8?q?=E6=8D=A2'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../User/UserArchiveDetailDialog.vue | 19 +++-- src/utils/storage.ts | 14 +++- .../GraphDescription/GraphDescriptionList.vue | 1 - src/views/user/archiveDetail.vue | 82 +++++++++++-------- 4 files changed, 72 insertions(+), 44 deletions(-) diff --git a/src/components/User/UserArchiveDetailDialog.vue b/src/components/User/UserArchiveDetailDialog.vue index 19cfd2c..fdd588f 100644 --- a/src/components/User/UserArchiveDetailDialog.vue +++ b/src/components/User/UserArchiveDetailDialog.vue @@ -76,13 +76,16 @@ import { ElMessage } from 'element-plus'; import { buildImageEntries, type ImageEntry, type StateAngles } from '@/utils/userArchiveImages'; const CONTENT_LABELS: Record = { - health_score: '评分', - mild_abnormality: '色素', - moderate_abnormality: '红区', - normal_area: '肤色', - severe_abnormality: '炎敏', + health_score: '健康评分', + predicted_age: '预测年龄', + mild_abnormality: '轻微异常', + moderate_abnormality: '中度异常', + normal_area: '正常区域', + severe_abnormality: '严重异常', }; +const METRIC_KEYS_ORDER = ['health_score', 'predicted_age', 'mild_abnormality', 'moderate_abnormality', 'normal_area', 'severe_abnormality']; + interface Props { visible: boolean; archiveId: number; @@ -127,14 +130,14 @@ const createTime = computed(() => detail.value?.create_time ?? ''); const metricRows = computed(() => { const c = detail.value?.contents; - if (!c || typeof c !== 'object') return []; - return Object.entries(c).map(([key, val]) => { + return METRIC_KEYS_ORDER.map((key) => { + const val = c?.[key]; const n = Number(val); const pct = Number.isFinite(n) ? Math.min(100, Math.max(0, n)) : 0; return { key, label: CONTENT_LABELS[key] || key, - value: String(val ?? '--'), + value: val !== undefined && val !== null ? String(val) : '--', pct, }; }); diff --git a/src/utils/storage.ts b/src/utils/storage.ts index 6e348fb..131a181 100644 --- a/src/utils/storage.ts +++ b/src/utils/storage.ts @@ -9,7 +9,12 @@ export const localStorage = { // 获取永久缓存 get(key: string) { const json: any = window.localStorage.getItem(key); - return JSON.parse(json); + if (json === null || json === undefined) return null; + try { + return JSON.parse(json); + } catch { + return json; // 如果不是 JSON 格式,直接返回原始字符串 + } }, // 移除永久缓存 remove(key: string) { @@ -32,7 +37,12 @@ export const sessionStorage = { // 获取临时缓存 get(key: string) { const json: any = window.sessionStorage.getItem(key); - return JSON.parse(json); + if (json === null || json === undefined) return null; + try { + return JSON.parse(json); + } catch { + return json; // 如果不是 JSON 格式,直接返回原始字符串 + } }, // 移除临时缓存 remove(key: string) { diff --git a/src/views/GraphDescription/GraphDescriptionList.vue b/src/views/GraphDescription/GraphDescriptionList.vue index 08acbe3..1c9cf3e 100644 --- a/src/views/GraphDescription/GraphDescriptionList.vue +++ b/src/views/GraphDescription/GraphDescriptionList.vue @@ -13,7 +13,6 @@ - diff --git a/src/views/user/archiveDetail.vue b/src/views/user/archiveDetail.vue index 5cb2748..9ab99df 100644 --- a/src/views/user/archiveDetail.vue +++ b/src/views/user/archiveDetail.vue @@ -109,13 +109,13 @@ @@ -146,14 +164,16 @@ import { } from '@/utils/userArchiveImages'; const CONTENT_LABELS: Record = { - health_score: '评分', - mild_abnormality: '色素', - moderate_abnormality: '红区', - normal_area: '肤色', - severe_abnormality: '炎敏', - yumin: '肤质综合', + health_score: '健康评分', + predicted_age: '预测年龄', + mild_abnormality: '轻微异常', + moderate_abnormality: '中度异常', + normal_area: '正常区域', + severe_abnormality: '严重异常', }; +const METRIC_KEYS_ORDER = ['health_score', 'predicted_age', 'mild_abnormality', 'moderate_abnormality', 'normal_area', 'severe_abnormality']; + const route = useRoute(); const loading = ref(false); const thumbExpanded = ref(true); @@ -219,35 +239,16 @@ const hasTriple2 = computed(() => !!(c2Left.value || c2Front.value || c2Right.va const singleUrl1 = computed(() => c1Front.value || c1Left.value || c1Right.value || ''); const singleUrl2 = computed(() => c2Front.value || c2Left.value || c2Right.value || ''); -/** 同一人对比:评估指标只展示一份,优先用检测一有 contents,否则用检测二 */ -const metricRecord = computed(() => { - const a = firstRecord.value; - const b = secondRecord.value; - const hasContents = (r: any) => r?.contents && typeof r.contents === 'object' && Object.keys(r.contents).length; - if (a && hasContents(a)) return a; - if (b && hasContents(b)) return b; - return a ?? b ?? null; -}); - -const metricTimeHint = computed(() => { - const a = firstRecord.value?.create_time; - const b = secondRecord.value?.create_time; - if (secondRecord.value && a && b && a !== b) { - return `检测一 ${a} · 检测二 ${b}`; - } - return metricRecord.value?.create_time || ''; -}); - function metricRows(record: any) { const c = record?.contents; - if (!c || typeof c !== 'object') return []; - return Object.entries(c).map(([key, val]) => { + return METRIC_KEYS_ORDER.map((key) => { + const val = c?.[key]; const n = Number(val); const pct = Number.isFinite(n) ? Math.min(100, Math.max(0, n)) : 0; return { key, label: CONTENT_LABELS[key] || key, - value: String(val ?? '--'), + value: val !== undefined && val !== null ? String(val) : '--', pct, }; }); @@ -740,6 +741,21 @@ html.dark .viewer-card { overflow: hidden; background: var(--el-bg-color); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06); + margin-bottom: 16px; + + &:last-child { + margin-bottom: 0; + } + + &--b { + .metric-card-head { + background: linear-gradient(180deg, rgba(64, 158, 255, 0.08) 0%, var(--el-fill-color-extra-light) 100%); + } + + .metric-num { + color: $accent-blue; + } + } } .metric-card-head {