mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-04 02:26:11 +08:00
✨ (admin) 完善 将site选择移动到侧边栏
This commit is contained in:
parent
24251c2728
commit
5b8d0440ee
@ -10,7 +10,6 @@ import WeightConfig from './features/weightConfig/WeightManager';
|
|||||||
import Home from './pages/Home';
|
import Home from './pages/Home';
|
||||||
import Unauthed from './pages/Unauthed';
|
import Unauthed from './pages/Unauthed';
|
||||||
import CookieManager from './features/cookieManager/CookieManager';
|
import CookieManager from './features/cookieManager/CookieManager';
|
||||||
import CookieTargetManager from './features/cookieTargetManager/CookieTargetManager';
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
@ -53,8 +52,8 @@ function App() {
|
|||||||
element: <CookieManager />,
|
element: <CookieManager />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'cookie/:cookieId',
|
path: 'cookie/:siteName',
|
||||||
element: <CookieTargetManager />,
|
element: <CookieManager />,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -1,118 +1,53 @@
|
|||||||
import React, { useState } from 'react';
|
import React from 'react';
|
||||||
import {
|
import {
|
||||||
Button,
|
Table, TableColumnProps, Typography,
|
||||||
Card, Descriptions, Grid, List, Popconfirm, Popover, Typography,
|
|
||||||
} from '@arco-design/web-react';
|
} from '@arco-design/web-react';
|
||||||
import { Link } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { IconDelete, IconEdit } from '@arco-design/web-react/icon';
|
|
||||||
import { selectSiteConf } from '../globalConf/globalConfSlice';
|
|
||||||
import { useAppSelector } from '../../app/hooks';
|
|
||||||
import { Cookie, SiteConfig } from '../../utils/type';
|
|
||||||
import { useGetCookiesQuery, useDeleteCookieMutation } from './cookieConfigSlice';
|
|
||||||
import CookieModal from './CookieModal';
|
|
||||||
import './CookieManager.css';
|
import './CookieManager.css';
|
||||||
|
|
||||||
interface CookieSite {
|
|
||||||
site: SiteConfig;
|
|
||||||
cookies: Cookie[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function CookieManager() {
|
export default function CookieManager() {
|
||||||
const siteConf = useAppSelector(selectSiteConf);
|
const { siteName } = useParams();
|
||||||
const { data: cookieDict } = useGetCookiesQuery();
|
|
||||||
const cookiesList = cookieDict ? Object.values(cookieDict) : [];
|
let data = [
|
||||||
const cookieSite = Object.values(siteConf).filter((site) => site.enable_cookie);
|
{
|
||||||
const cookieSiteList: CookieSite[] = cookieSite.map((site) => ({
|
id: 3,
|
||||||
site,
|
site_name: 'rss',
|
||||||
cookies: cookiesList.filter((cookie) => cookie.site_name === site.name),
|
friendly_name: 'rss [{"ewqe":"e]',
|
||||||
}));
|
last_usage: '1970-01-01T00:00:00',
|
||||||
const [showModal, setShowModal] = useState(false);
|
status: '',
|
||||||
const [siteName, setSiteName] = useState('');
|
cd_milliseconds: 10000,
|
||||||
const [deleteCookie] = useDeleteCookieMutation();
|
is_universal: false,
|
||||||
|
is_anonymous: false,
|
||||||
|
tags: {},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
if (siteName) {
|
||||||
|
data = data.filter((tSite) => tSite.site_name === siteName);
|
||||||
|
}
|
||||||
|
|
||||||
|
const columns: TableColumnProps[] = [
|
||||||
|
{
|
||||||
|
title: 'ID',
|
||||||
|
dataIndex: 'id',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Cookie 名称',
|
||||||
|
dataIndex: 'friendly_name',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '所属站点',
|
||||||
|
dataIndex: 'site_name',
|
||||||
|
},
|
||||||
|
|
||||||
|
];
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
const handleAddCookie = (newSiteName: string) => () => {
|
|
||||||
setSiteName(newSiteName);
|
|
||||||
setShowModal(true);
|
|
||||||
};
|
|
||||||
const handleDelCookie = (cookieId: string) => () => {
|
|
||||||
deleteCookie({
|
|
||||||
cookieId,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Typography.Title heading={4} style={{ margin: '15px' }}>Cookie 管理</Typography.Title>
|
<Typography.Title heading={4} style={{ margin: '15px' }}>Cookie 管理</Typography.Title>
|
||||||
|
|
||||||
<Grid.Row gutter={20}>
|
<Table columns={columns} data={data} />
|
||||||
{cookieSiteList && cookieSiteList.map(({ cookies, site }) => (
|
|
||||||
<Grid.Col xs={24} sm={12} md={8} lg={6} key={site.name} style={{ margin: '1em 0' }}>
|
|
||||||
<Card
|
|
||||||
title={site.name}
|
|
||||||
extra={(
|
|
||||||
<Button
|
|
||||||
type="primary"
|
|
||||||
onClick={handleAddCookie(site.name)}
|
|
||||||
>
|
|
||||||
添加
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
|
|
||||||
{cookies.map((cookie) => (
|
|
||||||
<List
|
|
||||||
bordered={false}
|
|
||||||
>
|
|
||||||
|
|
||||||
<List.Item
|
|
||||||
key={cookie.id}
|
|
||||||
style={{ padding: '20px 0', borderBottom: '1px solid var(--color-fill-3)' }}
|
|
||||||
>
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
||||||
|
|
||||||
<Popover
|
|
||||||
key={cookie.id}
|
|
||||||
title={cookie.friendly_name}
|
|
||||||
content={(
|
|
||||||
<Descriptions
|
|
||||||
column={1}
|
|
||||||
title="Cookie 详情"
|
|
||||||
data={Object.entries(cookie).map((entry) => ({
|
|
||||||
label: entry[0].toString(),
|
|
||||||
value: typeof (entry[1]) === 'object' ? JSON.stringify(entry[1]) : entry[1].toString(),
|
|
||||||
}))}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{cookie.friendly_name}
|
|
||||||
|
|
||||||
</Popover>
|
|
||||||
|
|
||||||
<div style={{ display: 'flex' }}>
|
|
||||||
|
|
||||||
<Link to={`/home/cookie/${cookie.id}`}>
|
|
||||||
<span className="list-actions-icon">
|
|
||||||
<IconEdit />
|
|
||||||
</span>
|
|
||||||
</Link>
|
|
||||||
<Popconfirm
|
|
||||||
title={`确定删除 Cookie ${cookie.friendly_name} ?`}
|
|
||||||
onOk={handleDelCookie(cookie.id.toString())}
|
|
||||||
>
|
|
||||||
<span className="list-actions-icon">
|
|
||||||
<IconDelete />
|
|
||||||
</span>
|
|
||||||
</Popconfirm>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</List.Item>
|
|
||||||
</List>
|
|
||||||
))}
|
|
||||||
</Card>
|
|
||||||
</Grid.Col>
|
|
||||||
))}
|
|
||||||
</Grid.Row>
|
|
||||||
<CookieModal visible={showModal} setVisible={setShowModal} siteName={siteName} />
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ export default function Home() {
|
|||||||
} else if (path.startsWith('/home/groups/')) {
|
} else if (path.startsWith('/home/groups/')) {
|
||||||
currentKey = 'subs';
|
currentKey = 'subs';
|
||||||
} else if (path.startsWith('/home/cookie/')) {
|
} else if (path.startsWith('/home/cookie/')) {
|
||||||
currentKey = 'cookie';
|
currentKey = path.substring(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
const [selectedTab, changeSelectTab] = useState(currentKey);
|
const [selectedTab, changeSelectTab] = useState(currentKey);
|
||||||
@ -52,6 +52,8 @@ export default function Home() {
|
|||||||
navigate('/home/weight');
|
navigate('/home/weight');
|
||||||
} else if (tab === 'cookie') {
|
} else if (tab === 'cookie') {
|
||||||
navigate('/home/cookie');
|
navigate('/home/cookie');
|
||||||
|
} else if (tab.startsWith('cookie/')) {
|
||||||
|
navigate(`/home/${tab}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -140,7 +142,7 @@ export default function Home() {
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{Object.values(siteConf).filter((site) => site.enable_cookie).map((site) => (
|
{Object.values(siteConf).filter((site) => site.enable_cookie).map((site) => (
|
||||||
<MenuItem key={site.name}>
|
<MenuItem key={`cookie/${site.name}`}>
|
||||||
{site.name}
|
{site.name}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
@ -149,7 +151,6 @@ export default function Home() {
|
|||||||
<IconDashboard />
|
<IconDashboard />
|
||||||
调度权重
|
调度权重
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
|
||||||
</Menu>
|
</Menu>
|
||||||
</Layout.Sider>
|
</Layout.Sider>
|
||||||
<Layout.Content style={{ padding: '0 1em' }}>
|
<Layout.Content style={{ padding: '0 1em' }}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user