mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-02 09:26:12 +08:00
✨ (admin) 支持添加cookie
This commit is contained in:
parent
3f3cc2d25e
commit
a18b2e4f7b
@ -1,13 +1,27 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
Button,
|
||||
Table, TableColumnProps, Typography,
|
||||
} from '@arco-design/web-react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
|
||||
import { useAppSelector } from '../../app/hooks'; import { useGetCookiesQuery, useDeleteCookieMutation } from './cookieConfigSlice';
|
||||
import './CookieManager.css';
|
||||
import { selectPlatformConf, selectSiteConf } from '../globalConf/globalConfSlice';
|
||||
import { PlatformConfig } from '../../utils/type';
|
||||
import CookieTargetModal from '../cookieTargetManager/CookieTargetModal';
|
||||
import CookieModal from './CookieModal';
|
||||
|
||||
export default function CookieManager() {
|
||||
const { siteName } = useParams();
|
||||
const siteConf = useAppSelector(selectSiteConf);
|
||||
const platformConf = useAppSelector(selectPlatformConf);
|
||||
const { data: cookieDict } = useGetCookiesQuery();
|
||||
const cookiesList = cookieDict ? Object.values(cookieDict) : [];
|
||||
|
||||
const [showModal, setShowModal] = React.useState(false);
|
||||
const handleAddCookie = () => () => {
|
||||
setShowModal(true);
|
||||
};
|
||||
|
||||
let data = [
|
||||
{
|
||||
@ -23,9 +37,13 @@ export default function CookieManager() {
|
||||
},
|
||||
];
|
||||
if (siteName) {
|
||||
data = data.filter((tSite) => tSite.site_name === siteName);
|
||||
data = cookiesList.filter((tSite) => tSite.site_name === siteName);
|
||||
}
|
||||
|
||||
console.log(Object.values(platformConf));
|
||||
const platformThatSiteSupport: Record<string, string> = Object.values(platformConf).reduce((p, c) => {
|
||||
p[c.siteName] = c.platformName;
|
||||
return p;
|
||||
}, {} as Record<string, string>);
|
||||
const columns: TableColumnProps[] = [
|
||||
{
|
||||
title: 'ID',
|
||||
@ -39,15 +57,32 @@ export default function CookieManager() {
|
||||
title: '所属站点',
|
||||
dataIndex: 'site_name',
|
||||
},
|
||||
{
|
||||
title: '最后使用时间',
|
||||
dataIndex: 'last_usage',
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
},
|
||||
{
|
||||
title: 'CD',
|
||||
dataIndex: 'cd_milliseconds',
|
||||
},
|
||||
|
||||
];
|
||||
console.log(data);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Typography.Title heading={4} style={{ margin: '15px' }}>Cookie 管理</Typography.Title>
|
||||
<div>
|
||||
|
||||
<Typography.Title heading={4} style={{ margin: '15px' }}>Cookie 管理</Typography.Title>
|
||||
|
||||
<Button style={{ width: '90px', margin: '20px 10px' }} type="primary" onClick={handleAddCookie()}>添加</Button>
|
||||
</div>
|
||||
|
||||
<Table columns={columns} data={data} />
|
||||
<CookieModal visible={showModal} setVisible={setShowModal} siteName={siteName || ''} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ export interface PlatformConfig {
|
||||
categories: CategoryConfig;
|
||||
enabledTag: boolean;
|
||||
platformName: string;
|
||||
siteName: string;
|
||||
hasTarget: boolean;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user