diff --git a/admin-frontend/src/App.tsx b/admin-frontend/src/App.tsx index 9e8544a..a292b7f 100644 --- a/admin-frontend/src/App.tsx +++ b/admin-frontend/src/App.tsx @@ -1,9 +1,11 @@ import React, { useEffect } from 'react'; -import { Route, Routes } from 'react-router-dom'; +import { createBrowserRouter, RouterProvider } from 'react-router-dom'; import './App.css'; import { useAppDispatch, useAppSelector } from './app/hooks'; import Auth from './features/auth/Auth'; import { loadGlobalConf, selectGlobalConfLoaded } from './features/globalConf/globalConfSlice'; +import GroupManager from './features/subsribeConfigManager/GroupManager'; +import SubscribeManager from './features/subsribeConfigManager/SubscribeManager'; import Home from './pages/Home'; import Unauthed from './pages/Unauthed'; @@ -17,14 +19,36 @@ function App() { } }, [globalConfLoaded]); + const router = createBrowserRouter([ + { + path: '/auth/:code', + element: , + }, + { + path: '/unauthed', + element: , + }, + { + path: '/home/', + element: , + // loader: homeLoader, + children: [ + { + path: 'groups', + element: , + }, + { + path: 'groups/:groupNumber', + element: , + }, + ], + }, + ], { basename: '/bison' }); + return ( globalConfLoaded ? ( - - } /> - } /> - } /> - + ) :
loading
); } diff --git a/admin-frontend/src/features/subsribeConfigManager/GroupManager.tsx b/admin-frontend/src/features/subsribeConfigManager/GroupManager.tsx new file mode 100644 index 0000000..73f3f3a --- /dev/null +++ b/admin-frontend/src/features/subsribeConfigManager/GroupManager.tsx @@ -0,0 +1,36 @@ +import React from 'react'; +import { + Card, Typography, Grid, Button, +} from '@arco-design/web-react'; +import { Link } from 'react-router-dom'; +import { useGetSubsQuery } from './subscribeConfigSlice'; + +export default function GroupManager() { + const { data: subs } = useGetSubsQuery(); + return ( + <> + 群管理 +
+ { subs && ( + + { Object.keys(subs).map( + (groupNumber: string) => ( + + , + , + ]} + > +
{groupNumber}
+
+
+ ), + )} +
+ )} +
+ + ); +} diff --git a/admin-frontend/src/features/subsribeConfigManager/SubscribeManager.tsx b/admin-frontend/src/features/subsribeConfigManager/SubscribeManager.tsx index 5735724..03950a4 100644 --- a/admin-frontend/src/features/subsribeConfigManager/SubscribeManager.tsx +++ b/admin-frontend/src/features/subsribeConfigManager/SubscribeManager.tsx @@ -1,13 +1,87 @@ import React from 'react'; +import { + Button, Empty, Space, Table, Tag, +} from '@arco-design/web-react'; +import { useParams } from 'react-router-dom'; import { useGetSubsQuery } from './subscribeConfigSlice'; +import { useAppSelector } from '../../app/hooks'; +import { selectPlatformConf } from '../globalConf/globalConfSlice'; +import { SubscribeConfig } from '../../utils/type'; export default function SubscribeManager() { const { data: subs } = useGetSubsQuery(); + const { groupNumber } = useParams(); + const platformConf = useAppSelector(selectPlatformConf); - return ( - <> -
{ subs && JSON.stringify(subs) }
-
1
- - ); + const columns = [ + { + title: '平台名称', + dataIndex: 'platformName', + render: (col: any, record: SubscribeConfig) => ( + {platformConf[record.platformName].name} + ), + }, + { title: '帐号名称', dataIndex: 'targetName' }, + { title: '订阅帐号', dataIndex: 'target' }, + { + title: '订阅分类', + dataIndex: 'cats', + render: (col: any, record: SubscribeConfig) => ( + + + { + record.cats.map((catNumber: number) => ( + {platformConf[record.platformName].categories[catNumber]} + )) + } + + + ), + }, + { + title: '订阅标签', + dataIndex: 'tags', + render: (col: any, record: SubscribeConfig) => ( + + + { + record.tags.length === 0 ? 全部标签 + : record.tags.map((tag: string) => ( + {tag} + )) + } + + + ), + }, + { + title: '操作', + dataIndex: 'op', + render: (_: any, record: SubscribeConfig) => ( + + + + + + ), + }, + ]; + + if (subs && groupNumber) { + return ( + <> + + {subs[groupNumber].name} + {groupNumber} + + + `${record.platformName}-${record.target}`} + /> + + ); + } + return ; } diff --git a/admin-frontend/src/index.tsx b/admin-frontend/src/index.tsx index b77ca83..0648698 100644 --- a/admin-frontend/src/index.tsx +++ b/admin-frontend/src/index.tsx @@ -1,7 +1,6 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; import { Provider } from 'react-redux'; -import { BrowserRouter } from 'react-router-dom'; import { PersistGate } from 'redux-persist/integration/react'; import App from './App'; import { persistor, store } from './app/store'; @@ -16,9 +15,7 @@ root.render( - - - + , diff --git a/admin-frontend/src/pages/Home.css b/admin-frontend/src/pages/Home.css new file mode 100644 index 0000000..7f8cb90 --- /dev/null +++ b/admin-frontend/src/pages/Home.css @@ -0,0 +1,44 @@ +.layout-collapse-demo { + height: 100vh; + border: 1px solid var(--color-border); + background: var(--color-fill-2); +} + +.layout-collapse-demo .arco-layout-header .logo { + height: 32px; + margin: 12px 8px; + background: var(--color-fill-2); +} + +.layout-collapse-demo .arco-layout-content .arco-layout-footer, +.layout-collapse-demo .arco-layout-content .arco-layout-content { + color: var(--color-white); + /* text-align: center; */ + font-stretch: condensed; + font-size: 16px; + display: flex; + flex-direction: column; + /* justify-content: center; */ +} + +.layout-collapse-demo .arco-layout-footer { + color: var(--color-text-2); + height: 48px; + line-height: 48px; + font-weight: 400; + font-size: 14px; +} + +.layout-collapse-demo .arco-layout-content .arco-layout-content { + background: var(--color-bg-3); + color: var(--color-text-2); + font-weight: 400; + font-size: 14px; + height: 100%; +} + +.layout-collapse-demo .arco-layout-header { + height: 64px; + line-height: 64px; + background: var(--color-bg-3); +} diff --git a/admin-frontend/src/pages/Home.tsx b/admin-frontend/src/pages/Home.tsx index 8804035..b86073f 100644 --- a/admin-frontend/src/pages/Home.tsx +++ b/admin-frontend/src/pages/Home.tsx @@ -1,42 +1,102 @@ -import React, { ReactNode, useState } from 'react'; +import React, { ReactNode, useEffect, useState } from 'react'; import { Breadcrumb, Layout, Menu } from '@arco-design/web-react'; import { IconRobot, IconDashboard } from '@arco-design/web-react/icon'; +import './Home.css'; +// import SubscribeManager from '../features/subsribeConfigManager/SubscribeManager'; +import { + Link, Outlet, useLocation, useNavigate, +} from 'react-router-dom'; + +export function homeLoader() { +} export default function Home() { - const [selectedTab, changeSelectTab] = useState('1'); + const location = useLocation(); + const navigate = useNavigate(); + + const path = location.pathname; + useEffect(() => { + if (path === '/home') { + navigate('/home/groups'); + } + + if (path !== '/home/groups' && !path.startsWith('/home/groups/')) { + console.log(path); + navigate('/home/groups'); + } + }, [path]); + + let currentKey: string = ''; + if (path === '/home/groups') { + currentKey = 'groups'; + } else if (path.startsWith('/home/groups/')) { + currentKey = 'subs'; + } + + const [selectedTab, changeSelectTab] = useState(currentKey); + + const handleTabSelect = (tab: string) => { + changeSelectTab(tab); + if (tab === 'groups') { + navigate('/home/navigate'); + } else if (tab === 'weight') { + navigate('/home/weight'); + } + }; + let breadcrumbContent: ReactNode; - if (selectedTab === '1') { + if (selectedTab === 'groups') { breadcrumbContent = ( - - - 订阅管理 - + + + + 订阅管理 + + + ); + } else if (selectedTab === 'subs') { + breadcrumbContent = ( + + + + + 订阅管理 + + + + groupman + + ); } - // let content: ReactNode; return ( - + - heade +
- + - { changeSelectTab(key); }}> - + { handleTabSelect(key); }} + > + 订阅管理 - + 调度权重 - + { breadcrumbContent } - -
123
+ + + +
diff --git a/src/plugins/nonebot_bison/admin_page/api.py b/src/plugins/nonebot_bison/admin_page/api.py index 4297ffb..2a1895b 100644 --- a/src/plugins/nonebot_bison/admin_page/api.py +++ b/src/plugins/nonebot_bison/admin_page/api.py @@ -99,6 +99,7 @@ async def get_subs_info(jwt_obj: dict): "targetName": sub.target.target_name, "cats": sub.categories, "tags": sub.tags, + "target": sub.target.target, }, raw_subs, )