fix(mp): T40 UI 审查全量修复 + 设计体系一致性优化

Phase 0 基础设施:
- statusTag.ts: getStatusInlineStyle() 移除内联 borderRadius/padding/fontSize,仅返回 {background, color}
- 新增 SEVERITY_COLORS + getSeverityStyle() + getSeverityLabel() 统一告警严重程度样式
- variables.scss: 新增 9 个语义颜色别名 ($success/$danger/$warning/$info 等)
- mixins.scss: 新增 status-inline mixin 统一状态标签样式
- 7 个消费者页面添加 @include status-inline CSS 补偿

Phase 1 HIGH 修复 (4 页面):
- P46 随访管理: 移除 getTypeStyle() 硬编码 fontSize,替换文字 Loading 为组件
- P45 咨询详情医护: 添加 Loading/ErrorState 三态模板 + error ref
- P02 健康数据: 添加 loading ref + Loading 组件 + 错误 toast 提示
- P48 告警中心: 替换本地 SEVERITY_COLORS/SEVERITY_LABELS 为 statusTag.ts 导出

Phase 2 全局一致性:
- 2.1 触控补全: 17 页面为可点击元素添加 min-height: $touch-min
- 2.2 字号替换: 19 文件 31 处硬编码 px → Design Token CSS 变量
- 2.3 颜色替换: 18 文件 ~50 处硬编码十六进制 → SCSS 语义变量
- 2.4 elder-mode.scss: 新增 9 个选择器到触控放大清单

Phase 3 LOW 修复:
- 3.1 统一 Loading: 21 页面旧式文字加载 → <Loading> 组件
- 3.2 useElderClass: 8 页面补全长者模式 class 绑定
- 3.3 零散修复: 按钮 44px→48px,诊断记录添加 scroll-view 无限加载

同时新增 UniApp (Vue 3 + Vite) 小程序完整代码库 (146 文件)
This commit is contained in:
iven
2026-05-15 11:22:51 +08:00
parent 18fa6ce6d4
commit 2c567bd772
147 changed files with 36561 additions and 564 deletions

View File

@@ -0,0 +1,89 @@
<template>
<view :class="['detail-page', elderClass]">
<Loading v-if="loading" text="加载中..." />
<view v-else-if="!analysis" class="empty-wrap"><text class="empty-text">报告不存在</text></view>
<template v-else>
<view class="detail-card">
<text class="detail-type">{{ TYPE_LABELS[analysis.analysis_type] || analysis.analysis_type }}</text>
<view class="detail-meta">
<text class="meta-item">模型: {{ analysis.model_used }}</text>
<text class="meta-item">{{ new Date(analysis.created_at).toLocaleString('zh-CN') }}</text>
</view>
<view v-if="isAutoAnalysis" class="auto-badge">
<text class="auto-badge-text">系统自动分析</text>
</view>
</view>
<view v-if="isTrendAnalysis" class="trend-tip-card">
<text class="trend-tip-text">趋势分析基于最小二乘法线性回归和 2 倍标准差异常检测 越接近 1 表示趋势拟合越好</text>
</view>
<view class="content-card">
<rich-text class="report-content" :nodes="htmlContent" />
</view>
</template>
</view>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getAiAnalysisDetail, type AiAnalysisItem } from '@/services/ai-analysis'
import { useElderClass } from '@/composables/useElderClass'
import Loading from '@/components/Loading.vue'
const TYPE_LABELS: Record<string, string> = {
lab_report_interpretation: '化验单解读', health_trend_analysis: '趋势分析',
personalized_checkup_plan: '体检方案', report_summary_generation: '报告摘要',
}
function sanitizeHtml(html: string): string {
return html
.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '')
.replace(/<\/?(?:iframe|object|embed|form|input|textarea|style)\b[^>]*>/gi, '')
.replace(/<\/?(?:link|meta)\b[^>]*>/gi, '')
.replace(/\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, '')
}
function markdownToHtml(md: string): string {
const escaped = sanitizeHtml(md)
return escaped
.replace(/^### (.+)$/gm, '<h3>$1</h3>')
.replace(/^## (.+)$/gm, '<h2>$1</h2>')
.replace(/^# (.+)$/gm, '<h1>$1</h1>')
.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
.replace(/\*(.+?)\*/g, '<em>$1</em>')
.replace(/^- (.+)$/gm, '<li>$1</li>')
.replace(/(<li>[\s\S]*?<\/li>)/g, '<ul>$1</ul>')
.replace(/\n\n/g, '<br/><br/>')
.replace(/\n/g, '<br/>')
}
const { elderClass } = useElderClass()
const analysis = ref<AiAnalysisItem | null>(null)
const loading = ref(true)
const htmlContent = computed(() => analysis.value?.result_content ? markdownToHtml(analysis.value.result_content) : '<p>暂无分析结果</p>')
const isTrendAnalysis = computed(() => analysis.value?.analysis_type === 'trend')
const isAutoAnalysis = computed(() => (analysis.value?.result_metadata as Record<string, unknown>)?.auto_analysis === true)
onLoad((query) => {
const id = query?.id || ''
if (!id) { loading.value = false; return }
getAiAnalysisDetail(id).then(data => { analysis.value = data }).catch(() => uni.showToast({ title: '加载失败', icon: 'none' })).finally(() => { loading.value = false })
})
</script>
<style lang="scss" scoped>
.detail-page { min-height: 100vh; background: $bg; padding: 24px; }
.empty-wrap { @include flex-center; padding: 120px 0; }
.empty-text { font-size: var(--tk-font-body); color: $tx3; }
.detail-card { @include card; margin-bottom: 16px; }
.detail-type { font-size: var(--tk-font-title); font-weight: 600; color: $tx; display: block; margin-bottom: 8px; }
.detail-meta { display: flex; gap: 16px; }
.meta-item { font-size: var(--tk-font-cap); color: $tx3; }
.auto-badge { display: inline-block; margin-top: 8px; padding: 2px 10px; background: rgba($pri, 0.1); border-radius: 4px; }
.auto-badge-text { font-size: var(--tk-font-micro); color: $pri; }
.trend-tip-card { @include card; margin-bottom: 16px; background: rgba(250,173,20,0.08); }
.trend-tip-text { font-size: var(--tk-font-cap); color: $tx2; line-height: 1.6; }
.content-card { @include card; }
.report-content { font-size: var(--tk-font-body); line-height: 1.8; color: $tx; }
</style>

View File

@@ -0,0 +1,90 @@
<template>
<view :class="['ai-report-page', elderClass]">
<view class="page-title">AI 分析报告</view>
<view v-if="list.length === 0 && !loading" class="empty-wrap">
<EmptyState icon="" title="暂无 AI 分析报告" />
</view>
<scroll-view v-else scroll-y class="report-scroll" @scrolltolower="loadMore">
<view v-for="item in list" :key="item.id" class="report-card" @tap="goDetail(item)">
<view class="card-header">
<text class="card-type">{{ TYPE_LABELS[item.analysis_type] || item.analysis_type }}</text>
<text :class="['card-status', (STATUS_MAP[item.status] || { className: '' }).className]">
{{ (STATUS_MAP[item.status] || { text: item.status }).text }}
</text>
</view>
<view class="card-footer">
<text class="card-time">{{ new Date(item.created_at).toLocaleString('zh-CN') }}</text>
<text class="card-model">{{ item.model_used }}</text>
</view>
</view>
<Loading v-if="loading" text="加载中..." />
<view v-if="!loading && !hasMore && list.length > 0" class="no-more"><text class="no-more-text">没有更多了</text></view>
</scroll-view>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { onMounted } from 'vue'
import { listAiAnalysis, type AiAnalysisItem } from '@/services/ai-analysis'
import EmptyState from '@/components/EmptyState.vue'
import { useElderClass } from '@/composables/useElderClass'
import Loading from '@/components/Loading.vue'
const TYPE_LABELS: Record<string, string> = {
lab_report_interpretation: '化验单解读', health_trend_analysis: '趋势分析',
personalized_checkup_plan: '体检方案', report_summary_generation: '报告摘要',
}
const STATUS_MAP: Record<string, { text: string; className: string }> = {
completed: { text: '已完成', className: 'status-completed' },
streaming: { text: '分析中', className: 'status-streaming' },
failed: { text: '失败', className: 'status-failed' },
pending: { text: '等待中', className: 'status-pending' },
}
const { elderClass } = useElderClass()
const list = ref<AiAnalysisItem[]>([])
const loading = ref(true)
const page = ref(1)
const hasMore = ref(true)
const loadList = async (p: number) => {
loading.value = true
try {
const res = await listAiAnalysis(p, 20)
const items = res.data || []
list.value = p === 1 ? items : [...list.value, ...items]
page.value = p
hasMore.value = items.length >= 20
} catch { uni.showToast({ title: '加载失败', icon: 'none' }) }
finally { loading.value = false }
}
const goDetail = (item: AiAnalysisItem) => {
if (item.status === 'completed') uni.navigateTo({ url: `/pages-sub/ai-report/detail/index?id=${item.id}` })
}
const loadMore = () => { if (hasMore.value && !loading.value) loadList(page.value + 1) }
onMounted(() => loadList(1))
</script>
<style lang="scss" scoped>
.ai-report-page { min-height: 100vh; background: $bg; }
.page-title { font-size: var(--tk-font-title); font-weight: 600; color: $tx; padding: 24px 24px 16px; }
.report-scroll { height: calc(100vh - 64px); padding: 0 24px; }
.report-card { @include card; margin-bottom: 12px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-type { font-size: var(--tk-font-body); font-weight: 500; color: $tx; }
.card-status { font-size: var(--tk-font-cap); padding: 2px 8px; border-radius: 4px; }
.status-completed { color: $acc; background: rgba(82,196,26,0.1); }
.status-streaming { color: $pri; background: rgba($pri, 0.1); }
.status-failed { color: $dan; background: rgba(255,77,79,0.1); }
.status-pending { color: $tx3; background: rgba(0,0,0,0.05); }
.card-footer { display: flex; justify-content: space-between; }
.card-time, .card-model { font-size: var(--tk-font-cap); color: $tx3; }
.empty-wrap { padding-top: 120px; }
.no-more { @include flex-center; padding: 20px; }
.no-more-text { font-size: var(--tk-font-cap); color: $tx3; }
</style>