mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-02 09:26:12 +08:00
✨ 添加 CookieTarget 页面
This commit is contained in:
parent
4c20e47399
commit
75a55c009a
@ -9,7 +9,8 @@ import SubscribeManager from './features/subsribeConfigManager/SubscribeManager'
|
||||
import WeightConfig from './features/weightConfig/WeightManager';
|
||||
import Home from './pages/Home';
|
||||
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() {
|
||||
const dispatch = useAppDispatch();
|
||||
@ -51,6 +52,10 @@ function App() {
|
||||
path: 'cookie',
|
||||
element: <CookieManager />,
|
||||
},
|
||||
{
|
||||
path: 'cookie/:cookieId',
|
||||
element: <CookieTargetManager />,
|
||||
},
|
||||
],
|
||||
},
|
||||
], { basename: '/bison' });
|
||||
|
@ -3,6 +3,7 @@ import {
|
||||
Button,
|
||||
Card, Descriptions, Grid, List, Popconfirm, Popover, Typography,
|
||||
} from '@arco-design/web-react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { selectSiteConf } from '../globalConf/globalConfSlice';
|
||||
import { useAppSelector } from '../../app/hooks';
|
||||
import { Cookie, SiteConfig } from '../../utils/type';
|
||||
@ -10,8 +11,8 @@ import { useGetCookiesQuery, useDeleteCookieMutation } from './cookieConfigSlice
|
||||
import CookieModal from './CookieModal';
|
||||
|
||||
interface CookieSite {
|
||||
site: SiteConfig;
|
||||
cookies: Cookie[];
|
||||
site: SiteConfig;
|
||||
cookies: Cookie[];
|
||||
}
|
||||
|
||||
export default function CookieManager() {
|
||||
@ -54,7 +55,7 @@ export default function CookieManager() {
|
||||
>
|
||||
添加
|
||||
</Button>
|
||||
)}
|
||||
)}
|
||||
>
|
||||
|
||||
{cookies.map((cookie) => (
|
||||
@ -75,17 +76,31 @@ export default function CookieManager() {
|
||||
value: typeof (entry[1]) === 'object' ? JSON.stringify(entry[1]) : entry[1].toString(),
|
||||
}))}
|
||||
/>
|
||||
)}
|
||||
)}
|
||||
>
|
||||
{cookie.friendly_name}
|
||||
</Popover>
|
||||
<Popconfirm
|
||||
title={`确定删除 Cookie ${cookie.friendly_name} ?`}
|
||||
onOk={handleDelCookie(cookie.id.toString())}
|
||||
>
|
||||
|
||||
<Button type="primary" status="danger">删除</Button>
|
||||
</Popconfirm>
|
||||
</Popover>
|
||||
|
||||
<div>
|
||||
|
||||
<Link to={`/home/cookie/${cookie.id}`}>
|
||||
<Button
|
||||
type="primary"
|
||||
style={{ marginRight: '10px' }}
|
||||
>
|
||||
关联详情
|
||||
</Button>
|
||||
</Link>
|
||||
<Popconfirm
|
||||
title={`确定删除 Cookie ${cookie.friendly_name} ?`}
|
||||
onOk={handleDelCookie(cookie.id.toString())}
|
||||
>
|
||||
|
||||
<Button type="primary" status="danger">删除</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</List.Item>
|
||||
</List>
|
@ -1,6 +1,7 @@
|
||||
import { createApi } from '@reduxjs/toolkit/query/react';
|
||||
import {
|
||||
StatusResp, Cookie, NewCookieParam, DelCookieParam,
|
||||
StatusResp, Cookie, NewCookieParam,
|
||||
DelCookieParam, CookieTarget, NewCookieTargetParam, DelCookieTargetParam,
|
||||
} from '../../utils/type';
|
||||
import { baseQueryWithAuth } from '../auth/authQuery';
|
||||
|
||||
@ -33,3 +34,35 @@ export const cookieApi = createApi({
|
||||
export const {
|
||||
useGetCookiesQuery, useNewCookieMutation, useDeleteCookieMutation,
|
||||
} = cookieApi;
|
||||
|
||||
export const cookieTargetApi = createApi({
|
||||
reducerPath: 'cookieTarget',
|
||||
baseQuery: baseQueryWithAuth,
|
||||
tagTypes: ['CookieTarget'],
|
||||
endpoints: (builder) => ({
|
||||
getCookieTargets: builder.query<CookieTarget, { site_name: string, cookie_id: number }>({
|
||||
query: () => '/cookie_target?site_name=site_name&cookie_id=cookie_id',
|
||||
providesTags: ['CookieTarget'],
|
||||
}),
|
||||
newCookieTarget: builder.mutation<StatusResp, NewCookieTargetParam>({
|
||||
query: ({ platformName, target, cookieId }) => ({
|
||||
method: 'POST',
|
||||
url: '/cookie_target',
|
||||
body: { platform_name: platformName, target, cookie_id: cookieId },
|
||||
}),
|
||||
invalidatesTags: ['CookieTarget'],
|
||||
}),
|
||||
deleteCookieTarget: builder.mutation<StatusResp, DelCookieTargetParam>({
|
||||
query: ({ platformName, target, cookieId }) => ({
|
||||
method: 'DELETE',
|
||||
url: '/cookie_target',
|
||||
body: { platform_name: platformName, target, cookie_id: cookieId },
|
||||
}),
|
||||
invalidatesTags: ['CookieTarget'],
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
export const {
|
||||
useGetCookieTargetsQuery, useNewCookieTargetMutation, useDeleteCookieTargetMutation,
|
||||
} = cookieTargetApi;
|
||||
|
@ -0,0 +1,7 @@
|
||||
import React from 'react';
|
||||
|
||||
export default function () {
|
||||
return (
|
||||
<h1>再等等</h1>
|
||||
);
|
||||
}
|
@ -26,6 +26,9 @@ export default function Home() {
|
||||
if (path === '/home/cookie') {
|
||||
navigate('/home/cookie');
|
||||
}
|
||||
if (path.startsWith('/home/cookie/')) {
|
||||
navigate(path);
|
||||
}
|
||||
}, [path]);
|
||||
|
||||
let currentKey = '';
|
||||
@ -33,6 +36,8 @@ export default function Home() {
|
||||
currentKey = 'groups';
|
||||
} else if (path.startsWith('/home/groups/')) {
|
||||
currentKey = 'subs';
|
||||
} else if (path.startsWith('/home/cookie/')) {
|
||||
currentKey = 'cookie';
|
||||
}
|
||||
|
||||
const [selectedTab, changeSelectTab] = useState(currentKey);
|
||||
@ -85,12 +90,14 @@ export default function Home() {
|
||||
</Breadcrumb.Item>
|
||||
</Breadcrumb>
|
||||
);
|
||||
} else if (path === '/home/cookie') {
|
||||
} else if (path.startsWith('/home/cookie')) {
|
||||
breadcrumbContent = (
|
||||
<Breadcrumb style={{ margin: '16px 0' }}>
|
||||
<Breadcrumb.Item>
|
||||
<IconUser />
|
||||
Cookie 管理
|
||||
<Link to="/home/cookie">
|
||||
<IconUser />
|
||||
Cookie 管理
|
||||
</Link>
|
||||
</Breadcrumb.Item>
|
||||
</Breadcrumb>
|
||||
);
|
||||
|
@ -4,6 +4,7 @@ export interface TokenResp {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface GlobalConf {
|
||||
platformConf: AllPlatformConf;
|
||||
siteConf: AllSiteConf;
|
||||
@ -111,3 +112,15 @@ export interface NewCookieParam {
|
||||
export interface DelCookieParam {
|
||||
cookieId: string
|
||||
}
|
||||
|
||||
export interface NewCookieTargetParam {
|
||||
platformName: string;
|
||||
target: string;
|
||||
cookieId: number;
|
||||
}
|
||||
|
||||
export interface DelCookieTargetParam {
|
||||
platformName: string;
|
||||
target: string;
|
||||
cookieId: number;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user