fix(mp): 小程序页面优化 + E2E 测试报告更新
- 小程序各页面优化和修复 - 更新联调报告和 E2E 测试报告 - 更新 miniprogram wiki
This commit is contained in:
@@ -5,7 +5,9 @@ import { usePageData } from '@/hooks/usePageData';
|
||||
import { useHealthStore } from '@/stores/health';
|
||||
import TrendChart from '@/components/TrendChart';
|
||||
import Loading from '@/components/Loading';
|
||||
import ErrorState from '@/components/ErrorState';
|
||||
import EmptyState from '@/components/EmptyState';
|
||||
import SegmentTabs from '@/components/SegmentTabs';
|
||||
import { useElderClass } from '../../../hooks/useElderClass';
|
||||
import './index.scss';
|
||||
|
||||
@@ -32,14 +34,17 @@ export default function Trend() {
|
||||
const [range, setRange] = useState('7d');
|
||||
const [points, setPoints] = useState<{ date: string; value: number }[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState(false);
|
||||
const getTrend = useHealthStore((s) => s.getTrend);
|
||||
|
||||
const fetchTrend = useCallback(async () => {
|
||||
setLoading(true);
|
||||
setError(false);
|
||||
try {
|
||||
const data = await getTrend(indicator, range);
|
||||
setPoints(data);
|
||||
} catch {
|
||||
setError(true);
|
||||
setPoints([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -72,25 +77,17 @@ export default function Trend() {
|
||||
</View>
|
||||
|
||||
{/* 时间范围切换 */}
|
||||
<View className='trange-wrap'>
|
||||
{RANGE_OPTIONS.map((opt) => (
|
||||
<View
|
||||
key={opt.value}
|
||||
className={`trange-tab ${range === opt.value ? 'trange-tab-active' : ''}`}
|
||||
onClick={() => setRange(opt.value)}
|
||||
>
|
||||
<Text className={`trange-tab-text ${range === opt.value ? 'trange-tab-text-active' : ''}`}>
|
||||
{opt.label}
|
||||
</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
<SegmentTabs tabs={RANGE_OPTIONS.map(o => ({ key: o.value, label: o.label }))} activeKey={range} onChange={setRange} variant="pill" />
|
||||
|
||||
{/* ECharts 折线图 */}
|
||||
{loading ? (
|
||||
<View className='trend-chart-card'>
|
||||
<Loading />
|
||||
</View>
|
||||
) : error ? (
|
||||
<View className='trend-chart-card'>
|
||||
<ErrorState onRetry={fetchTrend} />
|
||||
</View>
|
||||
) : points.length === 0 ? (
|
||||
<View className='trend-chart-card'>
|
||||
<EmptyState text='暂无趋势数据' />
|
||||
|
||||
Reference in New Issue
Block a user