feat:前端修改

This commit is contained in:
2026-09-14 19:00:48 +08:00
parent 0fd9cb4686
commit ff37553e62
30 changed files with 3635 additions and 136 deletions
+4 -3
View File
@@ -4,6 +4,7 @@ import Link from "next/link";
import { ArrowLeft, Download, RefreshCw, Send } from "lucide-react";
import { FormEvent, useEffect, useState } from "react";
import { ApiError, apiFetch } from "@/lib/api";
import { USER_TYPE } from "@/lib/roles";
interface HistoryItem { query_id?: string; question?: string; status?: string; row_count?: number; create_time?: string; }
@@ -16,15 +17,15 @@ export default function Nl2SqlPage() {
const [message, setMessage] = useState("");
const [loading, setLoading] = useState(false);
const [userType, setUserType] = useState<string | null>(null);
const isAdmin = userType === "ADMIN";
const canQuery = userType === "EMPLOYEE";
const isAdmin = userType === USER_TYPE.ADMIN;
const canQuery = userType === USER_TYPE.EMPLOYEE || userType === USER_TYPE.ADMIN;
useEffect(() => {
void apiFetch<{ user: { user_type?: string } }>("/auth/me")
.then(({ user }) => {
const nextType = user.user_type ?? null;
setUserType(nextType);
if (nextType === "ADMIN") setTab("config");
if (nextType === USER_TYPE.ADMIN) setTab("config");
})
.catch(() => setUserType(null));
}, []);