优化(斗鱼工作台): 合并三个工作台入口并记住页签
新增斗鱼总工作台,统一精英宝典、电竞手册、和平小店三个页签;持久化上次选择并兼容旧路由跳转。
This commit is contained in:
@@ -20,7 +20,7 @@ const PlatformFulfillmentPage = lazy(() => import('./pages/PlatformFulfillmentPa
|
|||||||
const AutomationPage = lazy(() => import('./pages/AutomationPage'));
|
const AutomationPage = lazy(() => import('./pages/AutomationPage'));
|
||||||
const UsersPage = lazy(() => import('./pages/UsersPage'));
|
const UsersPage = lazy(() => import('./pages/UsersPage'));
|
||||||
const CookiePage = lazy(() => import('./pages/CookiePage'));
|
const CookiePage = lazy(() => import('./pages/CookiePage'));
|
||||||
const DouyuTasksPage = lazy(() => import('./pages/DouyuTasksPage'));
|
const DouyuWorkbenchPage = lazy(() => import('./pages/DouyuWorkbenchPage'));
|
||||||
const DouyuCollabPage = lazy(() => import('./pages/DouyuCollabPage'));
|
const DouyuCollabPage = lazy(() => import('./pages/DouyuCollabPage'));
|
||||||
const HuyaAccountsPage = lazy(() => import('./pages/HuyaAccountsPage'));
|
const HuyaAccountsPage = lazy(() => import('./pages/HuyaAccountsPage'));
|
||||||
const HuyaAssignmentsPage = lazy(() => import('./pages/HuyaAssignmentsPage'));
|
const HuyaAssignmentsPage = lazy(() => import('./pages/HuyaAssignmentsPage'));
|
||||||
@@ -93,10 +93,12 @@ function AppContent() {
|
|||||||
<Route path="assignments" element={lazyRoute(<AssignmentsPage />)} />
|
<Route path="assignments" element={lazyRoute(<AssignmentsPage />)} />
|
||||||
<Route path="login-tasks" element={lazyRoute(<LoginTasksPage />)} />
|
<Route path="login-tasks" element={lazyRoute(<LoginTasksPage />)} />
|
||||||
<Route path="cookies" element={lazyRoute(<CookiePage />)} />
|
<Route path="cookies" element={lazyRoute(<CookiePage />)} />
|
||||||
<Route path="douyu/tasks" element={<Navigate to="/douyu/elite" replace />} />
|
<Route path="douyu" element={<Navigate to="/douyu/workbench" replace />} />
|
||||||
<Route path="douyu/elite" element={lazyRoute(<DouyuTasksPage key="elite" handbook="elite" />)} />
|
<Route path="douyu/tasks" element={<Navigate to="/douyu/workbench" replace />} />
|
||||||
<Route path="douyu/esports" element={lazyRoute(<DouyuTasksPage key="esports" handbook="esports" />)} />
|
<Route path="douyu/workbench" element={lazyRoute(<DouyuWorkbenchPage />)} />
|
||||||
<Route path="douyu/peace" element={lazyRoute(<DouyuTasksPage key="peace" handbook="peace" />)} />
|
<Route path="douyu/elite" element={<Navigate to="/douyu/workbench?tab=elite" replace />} />
|
||||||
|
<Route path="douyu/esports" element={<Navigate to="/douyu/workbench?tab=esports" replace />} />
|
||||||
|
<Route path="douyu/peace" element={<Navigate to="/douyu/workbench?tab=peace" replace />} />
|
||||||
<Route path="douyu/collab" element={lazyRoute(<DouyuCollabPage />)} />
|
<Route path="douyu/collab" element={lazyRoute(<DouyuCollabPage />)} />
|
||||||
<Route path="platform-fulfillment" element={lazyRoute(<PlatformFulfillmentPage />)} />
|
<Route path="platform-fulfillment" element={lazyRoute(<PlatformFulfillmentPage />)} />
|
||||||
<Route path="huya/accounts" element={lazyRoute(<HuyaAccountsPage />)} />
|
<Route path="huya/accounts" element={lazyRoute(<HuyaAccountsPage />)} />
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
CloudServerOutlined, TeamOutlined, ApiOutlined, KeyOutlined,
|
CloudServerOutlined, TeamOutlined, ApiOutlined, KeyOutlined,
|
||||||
MenuFoldOutlined, MenuUnfoldOutlined, SwapOutlined,
|
MenuFoldOutlined, MenuUnfoldOutlined, SwapOutlined,
|
||||||
SunOutlined, MoonOutlined, DesktopOutlined, GiftOutlined, ApartmentOutlined, MobileOutlined, ShoppingCartOutlined,
|
SunOutlined, MoonOutlined, DesktopOutlined, GiftOutlined, ApartmentOutlined, MobileOutlined, ShoppingCartOutlined,
|
||||||
BookOutlined, TrophyOutlined, ShopOutlined, GlobalOutlined,
|
BookOutlined, GlobalOutlined,
|
||||||
SafetyCertificateOutlined, FileSearchOutlined, RobotOutlined, FileExcelOutlined, ThunderboltOutlined,
|
SafetyCertificateOutlined, FileSearchOutlined, RobotOutlined, FileExcelOutlined, ThunderboltOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { useNavigate, useLocation, Outlet } from 'react-router-dom';
|
import { useNavigate, useLocation, Outlet } from 'react-router-dom';
|
||||||
@@ -78,9 +78,7 @@ export default function MainLayout({ onLogout }: { onLogout?: () => void }) {
|
|||||||
douyuItems.push({ key: '/automation', label: '斗鱼自动化', icon: <RobotOutlined /> });
|
douyuItems.push({ key: '/automation', label: '斗鱼自动化', icon: <RobotOutlined /> });
|
||||||
}
|
}
|
||||||
if (can('douyu:task')) {
|
if (can('douyu:task')) {
|
||||||
douyuItems.push({ key: '/douyu/elite', label: '精英宝典', icon: <BookOutlined /> });
|
douyuItems.push({ key: '/douyu/workbench', label: '斗鱼总工作台', icon: <DesktopOutlined /> });
|
||||||
douyuItems.push({ key: '/douyu/esports', label: '电竞手册', icon: <TrophyOutlined /> });
|
|
||||||
douyuItems.push({ key: '/douyu/peace', label: '和平小店', icon: <ShopOutlined /> });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 外部单协作:权限独立,客服没有 douyu:task 也要能进共享台账。
|
// 外部单协作:权限独立,客服没有 douyu:task 也要能进共享台账。
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
export { default } from './douyu-tasks/DouyuTasksPage';
|
|
||||||
export type { HandbookKind } from './douyu-tasks/config';
|
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
|
import { Tabs, Typography } from 'antd';
|
||||||
|
import {
|
||||||
|
BookOutlined,
|
||||||
|
ShopOutlined,
|
||||||
|
TrophyOutlined,
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
import { useSearchParams } from 'react-router-dom';
|
||||||
|
|
||||||
|
import DouyuTasksPage from './douyu-tasks/DouyuTasksPage';
|
||||||
|
import type { HandbookKind } from './douyu-tasks/config';
|
||||||
|
|
||||||
|
const { Text } = Typography;
|
||||||
|
|
||||||
|
const ACTIVE_HANDBOOK_STORAGE_KEY = 'douyu_workbench_active_handbook';
|
||||||
|
const DEFAULT_HANDBOOK: HandbookKind = 'elite';
|
||||||
|
|
||||||
|
const WORKBENCH_TABS: Array<{
|
||||||
|
key: HandbookKind;
|
||||||
|
label: React.ReactNode;
|
||||||
|
}> = [
|
||||||
|
{
|
||||||
|
key: 'elite',
|
||||||
|
label: (
|
||||||
|
<>
|
||||||
|
<BookOutlined />
|
||||||
|
精英宝典
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'esports',
|
||||||
|
label: (
|
||||||
|
<>
|
||||||
|
<TrophyOutlined />
|
||||||
|
电竞手册
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'peace',
|
||||||
|
label: (
|
||||||
|
<>
|
||||||
|
<ShopOutlined />
|
||||||
|
和平小店
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
function normalizeHandbook(value: string | null): HandbookKind | null {
|
||||||
|
if (value === 'elite' || value === 'esports' || value === 'peace') {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function readStoredHandbook(): HandbookKind {
|
||||||
|
try {
|
||||||
|
return normalizeHandbook(localStorage.getItem(ACTIVE_HANDBOOK_STORAGE_KEY))
|
||||||
|
|| DEFAULT_HANDBOOK;
|
||||||
|
} catch {
|
||||||
|
return DEFAULT_HANDBOOK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function DouyuWorkbenchPage() {
|
||||||
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
|
const activeHandbook =
|
||||||
|
normalizeHandbook(searchParams.get('tab')) || readStoredHandbook();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
try {
|
||||||
|
localStorage.setItem(ACTIVE_HANDBOOK_STORAGE_KEY, activeHandbook);
|
||||||
|
} catch {
|
||||||
|
// 隐私模式下仍允许本次页面内切换。
|
||||||
|
}
|
||||||
|
}, [activeHandbook]);
|
||||||
|
|
||||||
|
const changeHandbook = (key: string) => {
|
||||||
|
const next = normalizeHandbook(key);
|
||||||
|
if (!next) return;
|
||||||
|
const params = new URLSearchParams(searchParams);
|
||||||
|
params.set('tab', next);
|
||||||
|
setSearchParams(params, { replace: true });
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
overflow: 'hidden',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<style>{`
|
||||||
|
.douyu-total-workbench-tabs {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.douyu-total-workbench-tabs .ant-tabs-nav {
|
||||||
|
flex-shrink: 0;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
.douyu-total-workbench-tabs .ant-tabs-content-holder,
|
||||||
|
.douyu-total-workbench-tabs .ant-tabs-content,
|
||||||
|
.douyu-total-workbench-tabs .ant-tabs-tabpane {
|
||||||
|
min-height: 0;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.douyu-total-workbench-tabs .ant-tabs-content-holder {
|
||||||
|
flex: 1;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.douyu-total-workbench-tabs .ant-tabs-tab-label {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
`}</style>
|
||||||
|
<div style={{ marginBottom: 4, flexShrink: 0 }}>
|
||||||
|
<h2 style={{ margin: 0 }}>斗鱼总工作台</h2>
|
||||||
|
<Text type="secondary">统一处理精英宝典、电竞手册与和平小店任务</Text>
|
||||||
|
</div>
|
||||||
|
<Tabs
|
||||||
|
className="douyu-total-workbench-tabs"
|
||||||
|
activeKey={activeHandbook}
|
||||||
|
onChange={changeHandbook}
|
||||||
|
items={WORKBENCH_TABS.map((tab) => ({
|
||||||
|
key: tab.key,
|
||||||
|
label: tab.label,
|
||||||
|
children: <DouyuTasksPage handbook={tab.key} showTitle={false} />,
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -196,7 +196,13 @@ function BindStatusTag({ status, label }: { status?: string; label?: string }) {
|
|||||||
return <Tag color={tone} style={{ marginInlineEnd: 0 }}>{label || status}</Tag>;
|
return <Tag color={tone} style={{ marginInlineEnd: 0 }}>{label || status}</Tag>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind }) {
|
export default function DouyuTasksPage({
|
||||||
|
handbook,
|
||||||
|
showTitle = true,
|
||||||
|
}: {
|
||||||
|
handbook: HandbookKind;
|
||||||
|
showTitle?: boolean;
|
||||||
|
}) {
|
||||||
const isPeaceHandbook = handbook === 'peace';
|
const isPeaceHandbook = handbook === 'peace';
|
||||||
const isEsportsHandbook = handbook === 'esports';
|
const isEsportsHandbook = handbook === 'esports';
|
||||||
const isEliteHandbook = handbook === 'elite';
|
const isEliteHandbook = handbook === 'elite';
|
||||||
@@ -2914,7 +2920,7 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
{/* 头部 */}
|
{/* 头部 */}
|
||||||
<Space style={{ justifyContent: 'space-between', width: '100%', marginBottom: 8, flexShrink: 0 }}>
|
<Space style={{ justifyContent: 'space-between', width: '100%', marginBottom: 8, flexShrink: 0 }}>
|
||||||
<div>
|
<div>
|
||||||
<h2 style={{ margin: 0 }}>{handbookTitle}</h2>
|
{showTitle ? <h2 style={{ margin: 0 }}>{handbookTitle}</h2> : null}
|
||||||
<Text type="secondary">{handbookDescription}</Text>
|
<Text type="secondary">{handbookDescription}</Text>
|
||||||
</div>
|
</div>
|
||||||
<Space>
|
<Space>
|
||||||
|
|||||||
Reference in New Issue
Block a user