fix(miniprogram): 深度审查修复多个功能问题
Some checks failed
CI / security-audit (push) Has been cancelled
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled

- settings: 清除缓存不再错误读取明文 token,改由 auth store restore 恢复
- appointment: 移除多余的 detail_cache Storage 写入
- reports: 未选择就诊人时显示引导提示而非空白
- health/input: 血压录入验证舒张压必填
- followups: tab 切换时不再清空列表导致闪烁
This commit is contained in:
iven
2026-04-24 18:36:56 +08:00
parent 81cc84e4b2
commit a63043f447
5 changed files with 32 additions and 26 deletions

View File

@@ -1,7 +1,7 @@
import React, { useState, useCallback, useRef } from 'react';
import { View, Text } from '@tarojs/components';
import Taro, { useDidShow, useReachBottom, usePullDownRefresh } from '@tarojs/taro';
import { listAppointments, cancelAppointment } from '../../services/appointment';
import { listAppointments } from '../../services/appointment';
import type { Appointment } from '../../services/appointment';
import EmptyState from '../../components/EmptyState';
import Loading from '../../components/Loading';
@@ -64,10 +64,6 @@ export default function AppointmentList() {
};
const goDetail = (id: string) => {
const item = appointments.find((a) => a.id === id);
if (item) {
Taro.setStorageSync('appointment_detail_cache', item);
}
Taro.navigateTo({ url: `/pages/appointment/detail/index?id=${id}` });
};

View File

@@ -51,13 +51,25 @@ export default function HealthInput() {
const currentIndicator = INDICATORS[indicatorIdx].value;
if (currentIndicator === 'blood_pressure') {
if (!systolic || !diastolic) {
Taro.showToast({ title: '请填写收缩压和舒张压', icon: 'none' });
return;
}
} else {
if (!value) {
Taro.showToast({ title: '请输入数值', icon: 'none' });
return;
}
}
const input = currentIndicator === 'blood_pressure'
? { indicator_type: 'blood_pressure' as const, value: parseFloat(systolic), extra: { systolic: parseFloat(systolic), diastolic: parseFloat(diastolic) } }
: { indicator_type: currentIndicator as any, value: parseFloat(value) };
const result = vitalSignSchema.safeParse(input);
if (!result.success) {
Taro.showToast({ title: result.error.errors[0].message, icon: 'none' });
Taro.showToast({ title: result.error.issues[0].message, icon: 'none' });
return;
}
@@ -77,7 +89,7 @@ export default function HealthInput() {
});
clearCache();
Taro.showToast({ title: '录入成功', icon: 'success' });
trackEvent('health_data_input', { type: indicatorType });
trackEvent('health_data_input', { type: currentIndicator });
setTimeout(() => Taro.navigateBack(), 1000);
} catch (e: unknown) {
const msg = e instanceof Error ? e.message : '录入失败';

View File

@@ -35,7 +35,6 @@ export default function MyFollowUps() {
const handleTabChange = (key: string) => {
setActiveTab(key);
setTasks([]);
fetchTasks(key);
};

View File

@@ -6,8 +6,6 @@ import EmptyState from '../../../components/EmptyState';
import Loading from '../../../components/Loading';
import './index.scss';
const PAGE_SIZE = 20;
export default function MyReports() {
const [reports, setReports] = useState<LabReport[]>([]);
const [page, setPage] = useState(1);
@@ -16,7 +14,10 @@ export default function MyReports() {
const fetchData = useCallback(async (p: number, append = false) => {
const patientId = Taro.getStorageSync('current_patient_id') || '';
if (!patientId) return;
if (!patientId) {
setReports([]);
return;
}
setLoading(true);
try {
const res = await listReports(patientId, p);
@@ -80,7 +81,7 @@ export default function MyReports() {
</View>
{reports.length === 0 && !loading && (
<EmptyState text='暂无报告记录' />
<EmptyState text={Taro.getStorageSync('current_patient_id') ? '暂无报告记录' : '请先在就诊人管理中选择就诊人'} />
)}
{loading && (

View File

@@ -13,23 +13,21 @@ export default function Settings() {
content: '确定要清除本地缓存数据吗?不会影响账号信息。',
}).then((res) => {
if (res.confirm) {
// 保留登录态和核心设置
const token = Taro.getStorageSync('access_token');
const refreshToken = Taro.getStorageSync('refresh_token');
const user = Taro.getStorageSync('user');
const currentPatient = Taro.getStorageSync('current_patient');
const currentPatientId = Taro.getStorageSync('current_patient_id');
const tenantId = Taro.getStorageSync('tenant_id');
// 保留登录态和核心设置(使用明确的 key 列表,不依赖明文 token
const preservedKeys = ['user', 'current_patient', 'current_patient_id', 'tenant_id', 'wechat_openid'];
const preservedData: Record<string, unknown> = {};
for (const key of preservedKeys) {
const val = Taro.getStorageSync(key);
if (val) preservedData[key] = val;
}
Taro.clearStorageSync();
// 恢复登录态
if (token) Taro.setStorageSync('access_token', token);
if (refreshToken) Taro.setStorageSync('refresh_token', refreshToken);
if (user) Taro.setStorageSync('user', user);
if (currentPatient) Taro.setStorageSync('current_patient', currentPatient);
if (currentPatientId) Taro.setStorageSync('current_patient_id', currentPatientId);
if (tenantId) Taro.setStorageSync('tenant_id', tenantId);
// 恢复非敏感数据
for (const [key, val] of Object.entries(preservedData)) {
Taro.setStorageSync(key, val);
}
// 安全存储的 token 由 auth store restore() 在下次页面显示时自动恢复
Taro.showToast({ title: '缓存已清除', icon: 'success' });
}