fix: paper page use useAuth() instead of manual localStorage check
This commit is contained in:
parent
961cbc6bd8
commit
59910fe9cd
@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
import { useState, useEffect } from "react";
|
||||
import Link from "next/link";
|
||||
import { authFetch } from "@/lib/auth";
|
||||
import { authFetch, useAuth } from "@/lib/auth";
|
||||
import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer, ReferenceLine, Area, AreaChart } from "recharts";
|
||||
|
||||
// ─── 工具函数 ────────────────────────────────────────────────────
|
||||
@ -316,11 +316,9 @@ function StatsPanel() {
|
||||
// ─── 主页面 ──────────────────────────────────────────────────────
|
||||
|
||||
export default function PaperTradingPage() {
|
||||
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
||||
useEffect(() => {
|
||||
const token = typeof window !== "undefined" ? localStorage.getItem("token") : null;
|
||||
setIsLoggedIn(!!token);
|
||||
}, []);
|
||||
const { isLoggedIn, loading } = useAuth();
|
||||
|
||||
if (loading) return <div className="text-center text-slate-400 py-8">加载中...</div>;
|
||||
|
||||
if (!isLoggedIn) return (
|
||||
<div className="flex flex-col items-center justify-center h-64 gap-4">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user