优化(自动化中心): 记住上次标签并默认展开趋势明细
This commit is contained in:
@@ -43,6 +43,17 @@ import AccountPlatformStatusPanel from "./douyu-tasks/AccountPlatformStatusPanel
|
||||
|
||||
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 }> = {
|
||||
success: { color: "green", text: "成功" },
|
||||
failed: { color: "red", text: "失败" },
|
||||
@@ -242,7 +253,7 @@ export default function AutomationPage() {
|
||||
const [loginQuota, setLoginQuota] = useState<AutomationLoginQuota | null>(null);
|
||||
const [budgetRecommendation, setBudgetRecommendation] =
|
||||
useState<AutomationLoginQuotaRecommendation | null>(null);
|
||||
const [activeTab, setActiveTab] = useState("overview");
|
||||
const [activeTab, setActiveTab] = useState<AutomationTabKey>(readAutomationTab);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [budgetLoading, setBudgetLoading] = useState(false);
|
||||
const [historyLoading, setHistoryLoading] = useState(false);
|
||||
@@ -351,6 +362,10 @@ export default function AutomationPage() {
|
||||
}
|
||||
}, [activeTab, loadBudget, loadHistory, loadManual]);
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem(AUTOMATION_ACTIVE_TAB_KEY, activeTab);
|
||||
}, [activeTab]);
|
||||
|
||||
const refreshVisible = async () => {
|
||||
const jobsPromise = loadJobs();
|
||||
const tabPromise = activeTab === "budget"
|
||||
@@ -968,7 +983,7 @@ export default function AutomationPage() {
|
||||
|
||||
<Tabs
|
||||
activeKey={activeTab}
|
||||
onChange={setActiveTab}
|
||||
onChange={(key) => setActiveTab(key as AutomationTabKey)}
|
||||
items={[
|
||||
{
|
||||
key: "overview",
|
||||
|
||||
@@ -753,6 +753,7 @@ export default function AccountPlatformStatusPanel() {
|
||||
</Row>
|
||||
<Collapse
|
||||
ghost
|
||||
defaultActiveKey={['trend-detail']}
|
||||
items={[
|
||||
{
|
||||
key: 'trend-detail',
|
||||
|
||||
Reference in New Issue
Block a user