mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-04 02:26:11 +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 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();
|
||||||
@ -51,6 +52,10 @@ function App() {
|
|||||||
path: 'cookie',
|
path: 'cookie',
|
||||||
element: <CookieManager />,
|
element: <CookieManager />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'cookie/:cookieId',
|
||||||
|
element: <CookieTargetManager />,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
], { basename: '/bison' });
|
], { basename: '/bison' });
|
||||||
|
@ -3,6 +3,7 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
Card, Descriptions, Grid, List, Popconfirm, Popover, 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 { selectSiteConf } from '../globalConf/globalConfSlice';
|
import { selectSiteConf } from '../globalConf/globalConfSlice';
|
||||||
import { useAppSelector } from '../../app/hooks';
|
import { useAppSelector } from '../../app/hooks';
|
||||||
import { Cookie, SiteConfig } from '../../utils/type';
|
import { Cookie, SiteConfig } from '../../utils/type';
|
||||||
@ -10,8 +11,8 @@ import { useGetCookiesQuery, useDeleteCookieMutation } from './cookieConfigSlice
|
|||||||
import CookieModal from './CookieModal';
|
import CookieModal from './CookieModal';
|
||||||
|
|
||||||
interface CookieSite {
|
interface CookieSite {
|
||||||
site: SiteConfig;
|
site: SiteConfig;
|
||||||
cookies: Cookie[];
|
cookies: Cookie[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function CookieManager() {
|
export default function CookieManager() {
|
||||||
@ -54,7 +55,7 @@ export default function CookieManager() {
|
|||||||
>
|
>
|
||||||
添加
|
添加
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|
||||||
{cookies.map((cookie) => (
|
{cookies.map((cookie) => (
|
||||||
@ -75,17 +76,31 @@ export default function CookieManager() {
|
|||||||
value: typeof (entry[1]) === 'object' ? JSON.stringify(entry[1]) : entry[1].toString(),
|
value: typeof (entry[1]) === 'object' ? JSON.stringify(entry[1]) : entry[1].toString(),
|
||||||
}))}
|
}))}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{cookie.friendly_name}
|
{cookie.friendly_name}
|
||||||
</Popover>
|
|
||||||
<Popconfirm
|
|
||||||
title={`确定删除 Cookie ${cookie.friendly_name} ?`}
|
|
||||||
onOk={handleDelCookie(cookie.id.toString())}
|
|
||||||
>
|
|
||||||
|
|
||||||
<Button type="primary" status="danger">删除</Button>
|
</Popover>
|
||||||
</Popconfirm>
|
|
||||||
|
<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>
|
</div>
|
||||||
</List.Item>
|
</List.Item>
|
||||||
</List>
|
</List>
|
@ -1,6 +1,7 @@
|
|||||||
import { createApi } from '@reduxjs/toolkit/query/react';
|
import { createApi } from '@reduxjs/toolkit/query/react';
|
||||||
import {
|
import {
|
||||||
StatusResp, Cookie, NewCookieParam, DelCookieParam,
|
StatusResp, Cookie, NewCookieParam,
|
||||||
|
DelCookieParam, CookieTarget, NewCookieTargetParam, DelCookieTargetParam,
|
||||||
} from '../../utils/type';
|
} from '../../utils/type';
|
||||||
import { baseQueryWithAuth } from '../auth/authQuery';
|
import { baseQueryWithAuth } from '../auth/authQuery';
|
||||||
|
|
||||||
@ -33,3 +34,35 @@ export const cookieApi = createApi({
|
|||||||
export const {
|
export const {
|
||||||
useGetCookiesQuery, useNewCookieMutation, useDeleteCookieMutation,
|
useGetCookiesQuery, useNewCookieMutation, useDeleteCookieMutation,
|
||||||
} = cookieApi;
|
} = 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') {
|
if (path === '/home/cookie') {
|
||||||
navigate('/home/cookie');
|
navigate('/home/cookie');
|
||||||
}
|
}
|
||||||
|
if (path.startsWith('/home/cookie/')) {
|
||||||
|
navigate(path);
|
||||||
|
}
|
||||||
}, [path]);
|
}, [path]);
|
||||||
|
|
||||||
let currentKey = '';
|
let currentKey = '';
|
||||||
@ -33,6 +36,8 @@ export default function Home() {
|
|||||||
currentKey = 'groups';
|
currentKey = 'groups';
|
||||||
} else if (path.startsWith('/home/groups/')) {
|
} else if (path.startsWith('/home/groups/')) {
|
||||||
currentKey = 'subs';
|
currentKey = 'subs';
|
||||||
|
} else if (path.startsWith('/home/cookie/')) {
|
||||||
|
currentKey = 'cookie';
|
||||||
}
|
}
|
||||||
|
|
||||||
const [selectedTab, changeSelectTab] = useState(currentKey);
|
const [selectedTab, changeSelectTab] = useState(currentKey);
|
||||||
@ -85,12 +90,14 @@ export default function Home() {
|
|||||||
</Breadcrumb.Item>
|
</Breadcrumb.Item>
|
||||||
</Breadcrumb>
|
</Breadcrumb>
|
||||||
);
|
);
|
||||||
} else if (path === '/home/cookie') {
|
} else if (path.startsWith('/home/cookie')) {
|
||||||
breadcrumbContent = (
|
breadcrumbContent = (
|
||||||
<Breadcrumb style={{ margin: '16px 0' }}>
|
<Breadcrumb style={{ margin: '16px 0' }}>
|
||||||
<Breadcrumb.Item>
|
<Breadcrumb.Item>
|
||||||
<IconUser />
|
<Link to="/home/cookie">
|
||||||
Cookie 管理
|
<IconUser />
|
||||||
|
Cookie 管理
|
||||||
|
</Link>
|
||||||
</Breadcrumb.Item>
|
</Breadcrumb.Item>
|
||||||
</Breadcrumb>
|
</Breadcrumb>
|
||||||
);
|
);
|
||||||
|
@ -4,6 +4,7 @@ export interface TokenResp {
|
|||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GlobalConf {
|
export interface GlobalConf {
|
||||||
platformConf: AllPlatformConf;
|
platformConf: AllPlatformConf;
|
||||||
siteConf: AllSiteConf;
|
siteConf: AllSiteConf;
|
||||||
@ -111,3 +112,15 @@ export interface NewCookieParam {
|
|||||||
export interface DelCookieParam {
|
export interface DelCookieParam {
|
||||||
cookieId: string
|
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