feat(miniprogram): 访客模式 + 长辈模式 + MCP 自动化脚本
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

访客模式:
- 未登录用户可见首页(轮播图+健康资讯+登录引导)和"我的"页面
- 健康和消息 tab 显示 GuestGuard 登录拦截
- 登录页增加"暂不登录,先看看"跳过入口
- 401 拦截器增加 hasToken 检查,避免访客被重定向到登录页
- 退出登录后 reLaunch 到首页而非登录页

长辈模式:
- 新增 stores/ui.ts 管理显示模式(标准/长辈)
- 长辈模式放大字体 ×1.3、间距 ×1.2、按钮加大
- "我的 → 账号 → 长辈模式"切换页
- 设置持久化到 Storage

修复:
- Health/Messages 页面 Hooks 顺序违规(条件 return 在 hooks 之间)
  导致访客模式下页面白屏,所有 hooks 移到条件判断之前

工程:
- scripts/mpsync.sh/ps1 自动清理残留 DevTools 进程
- project.config.json 默认关闭域名校验
This commit is contained in:
iven
2026-05-09 11:42:44 +08:00
parent 0c28969c3b
commit 085163ec7a
23 changed files with 1385 additions and 312 deletions

View File

@@ -1,6 +1,10 @@
@import '../../styles/variables.scss';
@import '../../styles/mixins.scss';
/* ═══════════════════════════════════════
登录后首页
═══════════════════════════════════════ */
.home-page {
min-height: 100vh;
background: $bg;
@@ -8,12 +12,12 @@
padding-bottom: calc(100px + env(safe-area-inset-bottom));
}
/* ─── 区域 1问候 + 日期 + 铃铛 ─── */
/* ─── 问候区 ─── */
.greeting-section {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 16px;
margin-bottom: 24px;
}
.greeting-left {
@@ -21,7 +25,8 @@
}
.greeting-text {
font-size: 24px;
@include serif-number;
font-size: 26px;
font-weight: 700;
color: $tx;
display: block;
@@ -35,8 +40,10 @@
.greeting-bell {
position: relative;
width: 40px;
height: 40px;
width: 44px;
height: 44px;
border-radius: 22px;
background: $pri-l;
@include flex-center;
flex-shrink: 0;
@@ -46,16 +53,27 @@
}
.greeting-bell-icon {
font-size: 22px;
font-size: 18px;
color: $pri-d;
}
/* ─── 区域 2今日体征完成度 ─── */
.greeting-bell-dot {
position: absolute;
top: 6px;
right: 6px;
width: 8px;
height: 8px;
border-radius: 4px;
background: $dan;
}
/* ─── 今日体征进度 ─── */
.checkin-card {
background: $card;
border-radius: $r;
box-shadow: $shadow-sm;
padding: 16px;
margin-bottom: 12px;
box-shadow: $shadow-md;
padding: 20px;
margin-bottom: 16px;
display: flex;
align-items: center;
gap: 16px;
@@ -106,9 +124,9 @@
}
}
/* ─── 区域 3今日体征 2x2 ─── */
/* ─── 今日体征 2x2 ─── */
.vitals-section {
margin-bottom: 12px;
margin-bottom: 16px;
}
.section-title {
@@ -136,37 +154,36 @@
font-size: 13px;
color: $tx2;
display: block;
margin-bottom: 4px;
margin-bottom: 6px;
}
.vital-value-row {
display: flex;
align-items: baseline;
margin-bottom: 4px;
margin-bottom: 6px;
}
.vital-value {
@include serif-number;
font-size: 32px;
font-size: 30px;
font-weight: 700;
color: $tx;
line-height: 1.1;
line-height: 1;
}
.vital-unit {
font-size: 12px;
color: $tx3;
margin-left: 2px;
margin-left: 3px;
}
.vital-bottom {
display: flex;
align-items: center;
gap: 0;
}
.vital-tag {
font-size: 12px;
font-size: 11px;
font-weight: 500;
padding: 2px 8px;
border-radius: $r-pill;
@@ -189,103 +206,85 @@
}
}
/* ─── 区域 4今日待办 ─── */
.todo-section {
margin-bottom: 12px;
}
.todo-empty {
background: $card;
/* ─── 智能提醒卡片 ─── */
.reminder-card {
background: linear-gradient(135deg, $pri 0%, $pri-d 100%);
border-radius: $r;
padding: 24px;
text-align: center;
box-shadow: $shadow-sm;
padding: 18px;
margin-bottom: 16px;
color: #fff;
}
.todo-empty-text {
font-size: 14px;
color: $tx2;
.reminder-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}
.todo-list {
background: $card;
border-radius: $r;
overflow: hidden;
box-shadow: $shadow-sm;
.reminder-title {
font-size: 15px;
font-weight: 600;
color: #fff;
}
.todo-item {
.reminder-count {
font-size: 12px;
opacity: 0.7;
color: #fff;
}
.reminder-item {
display: flex;
align-items: center;
gap: 10px;
padding: 12px 16px;
border-bottom: 1px solid $bd;
&:last-child {
border-bottom: none;
}
gap: 8px;
padding: 8px 0;
&:active {
background: $bd-l;
opacity: 0.8;
}
}
.todo-icon-wrap {
width: 36px;
height: 36px;
border-radius: 10px;
background: $pri-l;
@include flex-center;
.reminder-item-border {
border-top: 1px solid rgba(255, 255, 255, 0.15);
}
.reminder-tag {
font-size: 10px;
padding: 2px 6px;
border-radius: 4px;
background: rgba(255, 255, 255, 0.2);
font-weight: 500;
color: #fff;
flex-shrink: 0;
}
.todo-icon-char {
font-size: 18px;
font-weight: bold;
color: $pri;
}
.todo-info {
flex: 1;
min-width: 0;
}
.todo-title {
font-size: 15px;
color: $tx;
font-weight: 500;
display: block;
margin-bottom: 2px;
}
.todo-sub {
.reminder-text {
font-size: 13px;
color: $tx3;
display: block;
flex: 1;
color: #fff;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.todo-arrow {
font-size: 14px;
color: $tx3;
.reminder-arrow {
opacity: 0.5;
color: #fff;
flex-shrink: 0;
}
/* ─── 区域 5快捷操作 ─── */
/* ─── 快捷操作 ─── */
.action-section {
display: flex;
gap: 10px;
margin-top: 16px;
margin-top: 8px;
}
.action-btn {
flex: 1;
height: 52px;
border-radius: 14px;
font-size: 17px;
font-weight: 600;
@include flex-center;
&:active {
@@ -296,6 +295,7 @@
.action-primary {
background: $pri;
color: #fff;
box-shadow: 0 2px 8px rgba(196, 98, 58, 0.25);
}
.action-outline {
@@ -308,3 +308,166 @@
font-size: 17px;
font-weight: 600;
}
/* ═══════════════════════════════════════
访客首页
═══════════════════════════════════════ */
.guest-page {
min-height: 100vh;
background: $bg;
padding-bottom: calc(120px + env(safe-area-inset-bottom));
}
/* ─── 轮播图 ─── */
.guest-swiper {
width: 100%;
height: 360px;
}
.guest-slide {
width: 100%;
height: 100%;
position: relative;
overflow: hidden;
}
.guest-slide-bg {
position: absolute;
inset: 0;
&--1 {
background: linear-gradient(135deg, $pri-d 0%, $pri 60%, $pri-l 100%);
}
}
.guest-slide:nth-child(2) .guest-slide-bg {
background: linear-gradient(135deg, $acc 0%, #3D5A40 60%, $acc-l 100%);
}
.guest-slide:nth-child(3) .guest-slide-bg {
background: linear-gradient(135deg, #8B6F4E 0%, $wrn 60%, $wrn-l 100%);
}
.guest-slide-content {
position: relative;
z-index: 1;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
padding: 40px 32px;
}
.guest-slide-title {
font-family: 'Georgia', 'Times New Roman', serif;
font-size: 26px;
font-weight: 700;
color: #FFFFFF;
display: block;
margin-bottom: 8px;
}
.guest-slide-desc {
font-size: 16px;
color: rgba(255, 255, 255, 0.85);
display: block;
}
/* ─── 健康资讯 ─── */
.guest-section {
padding: 24px 24px 0;
}
.guest-section-title {
font-family: 'Georgia', 'Times New Roman', serif;
font-size: 22px;
font-weight: bold;
color: $tx;
display: block;
margin-bottom: 16px;
}
.guest-articles {
display: flex;
flex-direction: column;
gap: 12px;
}
.guest-article-card {
background: $card;
border-radius: $r;
padding: 16px 18px;
box-shadow: $shadow-sm;
&:active {
opacity: 0.85;
}
}
.guest-article-title {
font-size: 16px;
font-weight: 600;
color: $tx;
display: block;
margin-bottom: 4px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.guest-article-summary {
font-size: 13px;
color: $tx3;
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.guest-empty {
padding: 40px 0;
text-align: center;
}
.guest-empty-text {
font-size: 14px;
color: $tx3;
}
/* ─── 底部登录引导 ─── */
.guest-login-prompt {
margin: 24px 24px 0;
background: $card;
border-radius: $r;
padding: 20px;
box-shadow: $shadow-md;
display: flex;
align-items: center;
gap: 16px;
}
.guest-login-text {
flex: 1;
font-size: 13px;
color: $tx2;
}
.guest-login-btn {
height: 56px;
padding: 0 28px;
background: $pri;
border-radius: $r-pill;
@include flex-center;
flex-shrink: 0;
&:active {
opacity: 0.85;
}
}
.guest-login-btn-text {
font-size: 20px;
font-weight: 600;
color: #fff;
}

View File

@@ -1,7 +1,8 @@
import { View, Text } from '@tarojs/components';
import { useState } from 'react';
import { View, Text, Swiper, SwiperItem } from '@tarojs/components';
import { useState, useCallback } from 'react';
import Taro, { useDidShow, usePullDownRefresh } from '@tarojs/taro';
import { useAuthStore } from '../../stores/auth';
import { useUIStore } from '../../stores/ui';
import { useHealthStore } from '../../stores/health';
import ProgressRing from '../../components/ProgressRing';
import Loading from '../../components/Loading';
@@ -10,6 +11,7 @@ import * as appointmentApi from '@/services/appointment';
import * as followupApi from '@/services/followup';
import { listPendingSuggestions, type AiSuggestionItem } from '@/services/ai-analysis';
import { notificationService } from '@/services/notification';
import * as articleApi from '@/services/article';
import './index.scss';
interface ReminderItem {
@@ -19,7 +21,103 @@ interface ReminderItem {
tag: string;
}
export default function Index() {
// ─── 访客首页 ───
const CAROUSEL_SLIDES = [
{ id: 'slide-1', title: '专业血透中心', desc: '三甲级医护团队全程守护' },
{ id: 'slide-2', title: '智慧健康管理', desc: 'AI 驱动个性化健康方案' },
{ id: 'slide-3', title: '温馨就医环境', desc: '舒适安全的治疗体验' },
];
function GuestHome({ modeClass }: { modeClass: string }) {
const [articles, setArticles] = useState<articleApi.Article[]>([]);
const [loading, setLoading] = useState(false);
useDidShow(() => {
loadArticles();
trackPageView('guest-home');
});
const loadArticles = async () => {
setLoading(true);
try {
const res = await articleApi.listArticles({ page: 1, page_size: 4 });
setArticles(res.data || []);
} catch {
// 文章加载失败不阻塞
} finally {
setLoading(false);
}
};
return (
<View className={`guest-page ${modeClass}`}>
{/* 轮播图 */}
<Swiper
className='guest-swiper'
indicatorDots
indicatorColor='rgba(255,255,255,0.4)'
indicatorActiveColor='#FFFFFF'
autoplay
circular
interval={4000}
duration={500}
>
{CAROUSEL_SLIDES.map((slide) => (
<SwiperItem key={slide.id}>
<View className='guest-slide'>
<View className='guest-slide-bg guest-slide-bg--1' />
<View className='guest-slide-content'>
<Text className='guest-slide-title'>{slide.title}</Text>
<Text className='guest-slide-desc'>{slide.desc}</Text>
</View>
</View>
</SwiperItem>
))}
</Swiper>
{/* 健康资讯 */}
<View className='guest-section'>
<Text className='guest-section-title'></Text>
{loading ? (
<Loading />
) : articles.length > 0 ? (
<View className='guest-articles'>
{articles.map((a) => (
<View
key={a.id}
className='guest-article-card'
onClick={() => Taro.navigateTo({ url: `/pages/article/detail/index?id=${a.id}` })}
>
<Text className='guest-article-title'>{a.title}</Text>
{a.summary && <Text className='guest-article-summary'>{a.summary}</Text>}
</View>
))}
</View>
) : (
<View className='guest-empty'>
<Text className='guest-empty-text'></Text>
</View>
)}
</View>
{/* 底部登录引导 */}
<View className='guest-login-prompt'>
<Text className='guest-login-text'>使</Text>
<View
className='guest-login-btn'
onClick={() => Taro.navigateTo({ url: '/pages/login/index' })}
>
<Text className='guest-login-btn-text'></Text>
</View>
</View>
</View>
);
}
// ─── 登录后首页 ───
function HomeDashboard({ modeClass }: { modeClass: string }) {
const { user, currentPatient } = useAuthStore();
const { todaySummary, loading, refreshToday } = useHealthStore();
const [reminders, setReminders] = useState<ReminderItem[]>([]);
@@ -55,7 +153,6 @@ export default function Index() {
setRemindersLoading(true);
try {
const items: ReminderItem[] = [];
const [apptRes, taskRes, suggestRes] = await Promise.allSettled([
appointmentApi.listAppointments(patientId, 1),
followupApi.listTasks(patientId, 'pending'),
@@ -64,15 +161,9 @@ export default function Index() {
if (suggestRes.status === 'fulfilled') {
for (const s of suggestRes.value.data.slice(0, 1)) {
items.push({
id: s.id,
text: buildSuggestionText(s),
type: 'ai',
tag: 'AI 建议',
});
items.push({ id: s.id, text: buildSuggestionText(s), type: 'ai', tag: 'AI 建议' });
}
}
if (apptRes.status === 'fulfilled') {
for (const a of apptRes.value.data.slice(0, 1)) {
if (a.status === 'pending' || a.status === 'confirmed') {
@@ -85,7 +176,6 @@ export default function Index() {
}
}
}
if (taskRes.status === 'fulfilled') {
for (const t of taskRes.value.data.slice(0, 1)) {
items.push({
@@ -96,7 +186,6 @@ export default function Index() {
});
}
}
setReminders(items.slice(0, 3));
} catch {
setReminders([]);
@@ -110,12 +199,7 @@ export default function Index() {
const displayName = user?.display_name || currentPatient?.name || '访客';
const summary = todaySummary || {};
const indicators = [
!!summary.blood_pressure,
!!summary.heart_rate,
!!summary.blood_sugar,
!!summary.weight,
];
const indicators = [!!summary.blood_pressure, !!summary.heart_rate, !!summary.blood_sugar, !!summary.weight];
const completedCount = indicators.filter(Boolean).length;
const progressPercent = Math.round((completedCount / 4) * 100);
@@ -140,7 +224,7 @@ export default function Index() {
};
return (
<View className='home-page'>
<View className={`home-page ${modeClass}`}>
{/* 问候区 */}
<View className='greeting-section'>
<View className='greeting-left'>
@@ -149,20 +233,14 @@ export default function Index() {
{new Date().toLocaleDateString('zh-CN', { month: 'long', day: 'numeric', weekday: 'short' })}
</Text>
</View>
<View
className='greeting-bell'
onClick={() => Taro.switchTab({ url: '/pages/messages/index' })}
>
<View className='greeting-bell' onClick={() => Taro.switchTab({ url: '/pages/messages/index' })}>
<Text className='greeting-bell-icon'></Text>
{unreadCount > 0 && <View className='greeting-bell-dot' />}
</View>
</View>
{/* 今日体征进度 */}
<View
className='checkin-card'
onClick={() => Taro.switchTab({ url: '/pages/health/index' })}
>
<View className='checkin-card' onClick={() => Taro.switchTab({ url: '/pages/health/index' })}>
<View className='checkin-left'>
<ProgressRing percent={progressPercent} />
</View>
@@ -172,10 +250,7 @@ export default function Index() {
</Text>
<View className='checkin-capsules'>
{indicatorCapsules.map((cap) => (
<Text
key={cap.label}
className={`capsule ${cap.done ? 'capsule-done' : 'capsule-pending'}`}
>
<Text key={cap.label} className={`capsule ${cap.done ? 'capsule-done' : 'capsule-pending'}`}>
{cap.done ? '✓ ' : ''}{cap.label}
</Text>
))}
@@ -226,11 +301,8 @@ export default function Index() {
key={r.id}
className={`reminder-item ${i > 0 ? 'reminder-item-border' : ''}`}
onClick={() => {
if (r.type === 'appointment') {
Taro.navigateTo({ url: '/pages/appointment/index' });
} else if (r.type === 'followup') {
Taro.navigateTo({ url: `/pages/followup/detail/index?id=${r.id}` });
}
if (r.type === 'appointment') Taro.navigateTo({ url: '/pages/appointment/index' });
else if (r.type === 'followup') Taro.navigateTo({ url: `/pages/followup/detail/index?id=${r.id}` });
}}
>
<Text className='reminder-tag'>{r.tag}</Text>
@@ -243,16 +315,10 @@ export default function Index() {
{/* 快捷操作 */}
<View className='action-section'>
<View
className='action-btn action-primary'
onClick={() => Taro.switchTab({ url: '/pages/health/index' })}
>
<View className='action-btn action-primary' onClick={() => Taro.switchTab({ url: '/pages/health/index' })}>
<Text className='action-btn-text'></Text>
</View>
<View
className='action-btn action-outline'
onClick={() => Taro.navigateTo({ url: '/pages/appointment/create/index' })}
>
<View className='action-btn action-outline' onClick={() => Taro.navigateTo({ url: '/pages/appointment/create/index' })}>
<Text className='action-btn-text'></Text>
</View>
</View>
@@ -260,12 +326,21 @@ export default function Index() {
);
}
// ─── 首页入口:根据登录状态切换 ───
export default function Index() {
const user = useAuthStore((s) => s.user);
const mode = useUIStore((s) => s.mode);
const modeClass = mode === 'elder' ? 'elder-mode' : '';
if (!user) {
return <GuestHome modeClass={modeClass} />;
}
return <HomeDashboard modeClass={modeClass} />;
}
function buildSuggestionText(s: AiSuggestionItem): string {
const riskMap: Record<string, string> = {
high: '高风险',
medium: '中风险',
low: '低风险',
};
const riskMap: Record<string, string> = { high: '高风险', medium: '中风险', low: '低风险' };
const typeMap: Record<string, string> = {
vital_sign_anomaly: '体征异常',
lab_result_anomaly: '化验异常',