优化(自动化中心): 记住上次标签并默认展开趋势明细

This commit is contained in:
yml
2026-11-25 22:44:03 +08:00
parent 9bdd2f4e1a
commit 4198f7ab39
2 changed files with 18 additions and 2 deletions
+17 -2
View File
@@ -43,6 +43,17 @@ import AccountPlatformStatusPanel from "./douyu-tasks/AccountPlatformStatusPanel
const { Text, Title } = Typography; const { Text, Title } = Typography;
const AUTOMATION_ACTIVE_TAB_KEY = "automation_active_tab";
const AUTOMATION_TABS = ["overview", "jobs", "budget", "manual", "history"] as const;
type AutomationTabKey = (typeof AUTOMATION_TABS)[number];
function readAutomationTab(): AutomationTabKey {
const saved = localStorage.getItem(AUTOMATION_ACTIVE_TAB_KEY);
return AUTOMATION_TABS.includes(saved as AutomationTabKey)
? (saved as AutomationTabKey)
: "overview";
}
const STATUS_TAG: Record<string, { color: string; text: string }> = { const STATUS_TAG: Record<string, { color: string; text: string }> = {
success: { color: "green", text: "成功" }, success: { color: "green", text: "成功" },
failed: { color: "red", text: "失败" }, failed: { color: "red", text: "失败" },
@@ -242,7 +253,7 @@ export default function AutomationPage() {
const [loginQuota, setLoginQuota] = useState<AutomationLoginQuota | null>(null); const [loginQuota, setLoginQuota] = useState<AutomationLoginQuota | null>(null);
const [budgetRecommendation, setBudgetRecommendation] = const [budgetRecommendation, setBudgetRecommendation] =
useState<AutomationLoginQuotaRecommendation | null>(null); useState<AutomationLoginQuotaRecommendation | null>(null);
const [activeTab, setActiveTab] = useState("overview"); const [activeTab, setActiveTab] = useState<AutomationTabKey>(readAutomationTab);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [budgetLoading, setBudgetLoading] = useState(false); const [budgetLoading, setBudgetLoading] = useState(false);
const [historyLoading, setHistoryLoading] = useState(false); const [historyLoading, setHistoryLoading] = useState(false);
@@ -351,6 +362,10 @@ export default function AutomationPage() {
} }
}, [activeTab, loadBudget, loadHistory, loadManual]); }, [activeTab, loadBudget, loadHistory, loadManual]);
useEffect(() => {
localStorage.setItem(AUTOMATION_ACTIVE_TAB_KEY, activeTab);
}, [activeTab]);
const refreshVisible = async () => { const refreshVisible = async () => {
const jobsPromise = loadJobs(); const jobsPromise = loadJobs();
const tabPromise = activeTab === "budget" const tabPromise = activeTab === "budget"
@@ -968,7 +983,7 @@ export default function AutomationPage() {
<Tabs <Tabs
activeKey={activeTab} activeKey={activeTab}
onChange={setActiveTab} onChange={(key) => setActiveTab(key as AutomationTabKey)}
items={[ items={[
{ {
key: "overview", key: "overview",
@@ -753,6 +753,7 @@ export default function AccountPlatformStatusPanel() {
</Row> </Row>
<Collapse <Collapse
ghost ghost
defaultActiveKey={['trend-detail']}
items={[ items={[
{ {
key: 'trend-detail', key: 'trend-detail',