mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-09-20 02:23:38 +08:00
Compare commits
No commits in common. "bc44e40f5650b2336c36eecb95d21c540c68a3ba" and "43fb5231b8c727b83da51f2350f85fc7c4e1e7d9" have entirely different histories.
bc44e40f56
...
43fb5231b8
@ -9,8 +9,6 @@ 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 CookieTargetManager from './features/cookieTargetManager/CookieTargetManager';
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
@ -48,14 +46,6 @@ function App() {
|
|||||||
path: 'weight',
|
path: 'weight',
|
||||||
element: <WeightConfig />,
|
element: <WeightConfig />,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: 'cookie',
|
|
||||||
element: <CookieManager />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'cookie/:cookieId',
|
|
||||||
element: <CookieTargetManager />,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
], { basename: '/bison' });
|
], { basename: '/bison' });
|
||||||
|
@ -17,7 +17,6 @@ import globalConfReducer from '../features/globalConf/globalConfSlice';
|
|||||||
import { subscribeApi } from '../features/subsribeConfigManager/subscribeConfigSlice';
|
import { subscribeApi } from '../features/subsribeConfigManager/subscribeConfigSlice';
|
||||||
import { targetNameApi } from '../features/targetName/targetNameSlice';
|
import { targetNameApi } from '../features/targetName/targetNameSlice';
|
||||||
import { weightApi } from '../features/weightConfig/weightConfigSlice';
|
import { weightApi } from '../features/weightConfig/weightConfigSlice';
|
||||||
import { cookieApi, cookieTargetApi } from '../features/cookieManager/cookieConfigSlice';
|
|
||||||
|
|
||||||
const rootReducer = combineReducers({
|
const rootReducer = combineReducers({
|
||||||
auth: authReducer,
|
auth: authReducer,
|
||||||
@ -25,8 +24,6 @@ const rootReducer = combineReducers({
|
|||||||
[subscribeApi.reducerPath]: subscribeApi.reducer,
|
[subscribeApi.reducerPath]: subscribeApi.reducer,
|
||||||
[weightApi.reducerPath]: weightApi.reducer,
|
[weightApi.reducerPath]: weightApi.reducer,
|
||||||
[targetNameApi.reducerPath]: targetNameApi.reducer,
|
[targetNameApi.reducerPath]: targetNameApi.reducer,
|
||||||
[cookieApi.reducerPath]: cookieApi.reducer,
|
|
||||||
[cookieTargetApi.reducerPath]: cookieTargetApi.reducer,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const persistConfig = {
|
const persistConfig = {
|
||||||
@ -46,10 +43,7 @@ export const store = configureStore({
|
|||||||
})
|
})
|
||||||
.concat(subscribeApi.middleware)
|
.concat(subscribeApi.middleware)
|
||||||
.concat(weightApi.middleware)
|
.concat(weightApi.middleware)
|
||||||
.concat(targetNameApi.middleware)
|
.concat(targetNameApi.middleware),
|
||||||
.concat(cookieApi.middleware)
|
|
||||||
.concat(cookieTargetApi.middleware),
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const persistor = persistStore(store);
|
export const persistor = persistStore(store);
|
||||||
|
@ -1,115 +0,0 @@
|
|||||||
import React, { useState } from 'react';
|
|
||||||
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';
|
|
||||||
import { useGetCookiesQuery, useDeleteCookieMutation } from './cookieConfigSlice';
|
|
||||||
import CookieModal from './CookieModal';
|
|
||||||
|
|
||||||
interface CookieSite {
|
|
||||||
site: SiteConfig;
|
|
||||||
cookies: Cookie[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function CookieManager() {
|
|
||||||
const siteConf = useAppSelector(selectSiteConf);
|
|
||||||
const { data: cookieDict } = useGetCookiesQuery();
|
|
||||||
const cookiesList = cookieDict ? Object.values(cookieDict) : [];
|
|
||||||
const cookieSite = Object.values(siteConf).filter((site) => site.enable_cookie);
|
|
||||||
const cookieSiteList: CookieSite[] = cookieSite.map((site) => ({
|
|
||||||
site,
|
|
||||||
cookies: cookiesList.filter((cookie) => cookie.site_name === site.name),
|
|
||||||
}));
|
|
||||||
const [showModal, setShowModal] = useState(false);
|
|
||||||
const [siteName, setSiteName] = useState('');
|
|
||||||
const [deleteCookie] = useDeleteCookieMutation();
|
|
||||||
|
|
||||||
const handleAddCookie = (newSiteName: string) => () => {
|
|
||||||
console.log(newSiteName);
|
|
||||||
setSiteName(newSiteName);
|
|
||||||
setShowModal(true);
|
|
||||||
};
|
|
||||||
const handleDelCookie = (cookieId: string) => () => {
|
|
||||||
console.log(cookieId);
|
|
||||||
deleteCookie({
|
|
||||||
cookieId,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Typography.Title heading={4} style={{ margin: '15px' }}>Cookie 管理</Typography.Title>
|
|
||||||
|
|
||||||
<Grid.Row gutter={20}>
|
|
||||||
{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>
|
|
||||||
|
|
||||||
<List.Item key={cookie.id}>
|
|
||||||
<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>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
))}
|
|
||||||
</Card>
|
|
||||||
</Grid.Col>
|
|
||||||
))}
|
|
||||||
</Grid.Row>
|
|
||||||
<CookieModal visible={showModal} setVisible={setShowModal} siteName={siteName} />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
import React, { useState } from 'react';
|
|
||||||
import { Form, Input, Modal } from '@arco-design/web-react';
|
|
||||||
import { useNewCookieMutation } from './cookieConfigSlice';
|
|
||||||
|
|
||||||
interface CookieModalProps {
|
|
||||||
visible: boolean;
|
|
||||||
setVisible: (arg0: boolean) => void;
|
|
||||||
siteName: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
function CookieModal({ visible, setVisible, siteName }: CookieModalProps) {
|
|
||||||
const FormItem = Form.Item;
|
|
||||||
const [content, setContent] = useState<string>('');
|
|
||||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
|
||||||
const [newCoookie] = useNewCookieMutation();
|
|
||||||
|
|
||||||
const onSubmit = () => {
|
|
||||||
const postPromise: ReturnType<typeof newCoookie> = newCoookie({ siteName, content });
|
|
||||||
setConfirmLoading(true);
|
|
||||||
postPromise.then(() => {
|
|
||||||
setConfirmLoading(false);
|
|
||||||
setVisible(false);
|
|
||||||
setContent('');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
title="添加 Cookie"
|
|
||||||
visible={visible}
|
|
||||||
onCancel={() => setVisible(false)}
|
|
||||||
confirmLoading={confirmLoading}
|
|
||||||
onOk={onSubmit}
|
|
||||||
style={{ maxWidth: '90vw' }}
|
|
||||||
>
|
|
||||||
|
|
||||||
<Form autoComplete="off">
|
|
||||||
<FormItem label="Site Name" required>
|
|
||||||
<Input placeholder="Please enter site name" value={siteName} disabled />
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="Content" required>
|
|
||||||
<Input.TextArea
|
|
||||||
placeholder="Please enter content"
|
|
||||||
value={content}
|
|
||||||
onChange={setContent}
|
|
||||||
/>
|
|
||||||
</FormItem>
|
|
||||||
|
|
||||||
</Form>
|
|
||||||
</Modal>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default CookieModal;
|
|
@ -1,66 +0,0 @@
|
|||||||
import { createApi } from '@reduxjs/toolkit/query/react';
|
|
||||||
import {
|
|
||||||
StatusResp, Cookie, NewCookieParam,
|
|
||||||
DelCookieParam, CookieTarget, NewCookieTargetParam, DelCookieTargetParam,
|
|
||||||
} from '../../utils/type';
|
|
||||||
import { baseQueryWithAuth } from '../auth/authQuery';
|
|
||||||
|
|
||||||
export const cookieApi = createApi({
|
|
||||||
reducerPath: 'cookie',
|
|
||||||
baseQuery: baseQueryWithAuth,
|
|
||||||
tagTypes: ['Cookie'],
|
|
||||||
endpoints: (builder) => ({
|
|
||||||
getCookies: builder.query<Cookie, void>({
|
|
||||||
query: () => '/cookie',
|
|
||||||
providesTags: ['Cookie'],
|
|
||||||
}),
|
|
||||||
newCookie: builder.mutation<StatusResp, NewCookieParam>({
|
|
||||||
query: ({ siteName, content }) => ({
|
|
||||||
method: 'POST',
|
|
||||||
url: `/cookie?site_name=${siteName}&content=${content}`,
|
|
||||||
}),
|
|
||||||
invalidatesTags: ['Cookie'],
|
|
||||||
}),
|
|
||||||
deleteCookie: builder.mutation<StatusResp, DelCookieParam>({
|
|
||||||
query: ({ cookieId }) => ({
|
|
||||||
method: 'DELETE',
|
|
||||||
url: `/cookie/${cookieId}`,
|
|
||||||
}),
|
|
||||||
invalidatesTags: ['Cookie'],
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const {
|
|
||||||
useGetCookiesQuery, useNewCookieMutation, useDeleteCookieMutation,
|
|
||||||
} = cookieApi;
|
|
||||||
|
|
||||||
export const cookieTargetApi = createApi({
|
|
||||||
reducerPath: 'cookieTarget',
|
|
||||||
baseQuery: baseQueryWithAuth,
|
|
||||||
tagTypes: ['CookieTarget'],
|
|
||||||
endpoints: (builder) => ({
|
|
||||||
getCookieTargets: builder.query<CookieTarget[], {cookieId: number }>({
|
|
||||||
query: (cookieId) => `/cookie_target?cookie_id=${cookieId}`,
|
|
||||||
providesTags: ['CookieTarget'],
|
|
||||||
}),
|
|
||||||
newCookieTarget: builder.mutation<StatusResp, NewCookieTargetParam>({
|
|
||||||
query: ({ platformName, target, cookieId }) => ({
|
|
||||||
method: 'POST',
|
|
||||||
url: `/cookie_target?platform_name=${platformName}&target=${encodeURIComponent(target)}&cookie_id=${cookieId}`,
|
|
||||||
}),
|
|
||||||
invalidatesTags: ['CookieTarget'],
|
|
||||||
}),
|
|
||||||
deleteCookieTarget: builder.mutation<StatusResp, DelCookieTargetParam>({
|
|
||||||
query: ({ platformName, target, cookieId }) => ({
|
|
||||||
method: 'DELETE',
|
|
||||||
url: `/cookie_target?platform_name=${platformName}&target=${encodeURIComponent(target)}&cookie_id=${cookieId}`,
|
|
||||||
}),
|
|
||||||
invalidatesTags: ['CookieTarget'],
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const {
|
|
||||||
useGetCookieTargetsQuery, useNewCookieTargetMutation, useDeleteCookieTargetMutation,
|
|
||||||
} = cookieTargetApi;
|
|
@ -1,79 +0,0 @@
|
|||||||
import React, { useState } from 'react';
|
|
||||||
import { useParams } from 'react-router-dom';
|
|
||||||
import {
|
|
||||||
Button, Empty, Space, Table, Typography,
|
|
||||||
} from '@arco-design/web-react';
|
|
||||||
import { useDeleteCookieTargetMutation, useGetCookieTargetsQuery } from '../cookieManager/cookieConfigSlice';
|
|
||||||
import { CookieTarget } from '../../utils/type';
|
|
||||||
import CookieTargetModal from './CookieTargetModal';
|
|
||||||
|
|
||||||
export default function () {
|
|
||||||
const { cookieId } = useParams();
|
|
||||||
const { data: cookieTargets } = useGetCookieTargetsQuery(cookieId);
|
|
||||||
|
|
||||||
console.log(cookieTargets);
|
|
||||||
const [showModal, setShowModal] = useState(false);
|
|
||||||
const [deleteCookieTarget] = useDeleteCookieTargetMutation();
|
|
||||||
const handleAdd = () => {
|
|
||||||
setShowModal(true);
|
|
||||||
};
|
|
||||||
const handleDelete = (record: CookieTarget) => () => {
|
|
||||||
deleteCookieTarget({
|
|
||||||
cookieId,
|
|
||||||
target: record.target.target,
|
|
||||||
platformName: record.target.platform_name,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const columns = [
|
|
||||||
{
|
|
||||||
title: '平台名称',
|
|
||||||
dataIndex: 'target.platform_name',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '订阅名称',
|
|
||||||
dataIndex: 'target.target_name',
|
|
||||||
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Cookie ID',
|
|
||||||
dataIndex: 'cookie_id',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '操作',
|
|
||||||
dataIndex: 'op',
|
|
||||||
render: (_: null, record: CookieTarget) => (
|
|
||||||
<Space size="small">
|
|
||||||
<Button type="text" status="danger" onClick={handleDelete(record)}>删除</Button>
|
|
||||||
</Space>
|
|
||||||
),
|
|
||||||
|
|
||||||
},
|
|
||||||
];
|
|
||||||
if (cookieId) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<span>
|
|
||||||
<Typography.Title heading={3}>{`Cookie ${cookieId}`}</Typography.Title>
|
|
||||||
</span>
|
|
||||||
<Button style={{ width: '90px', margin: '20px 10px' }} type="primary" onClick={handleAdd}>添加</Button>
|
|
||||||
<Table
|
|
||||||
columns={columns}
|
|
||||||
data={cookieTargets}
|
|
||||||
rowKey={(record: CookieTarget) => `${record.target.platform_name}-${record.target.target}`}
|
|
||||||
scroll={{ x: true }}
|
|
||||||
/>
|
|
||||||
{
|
|
||||||
cookieTargets && cookieTargets.length > 0
|
|
||||||
&& (
|
|
||||||
<CookieTargetModal
|
|
||||||
visible={showModal}
|
|
||||||
setVisible={setShowModal}
|
|
||||||
cookieId={cookieId}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return <Empty />;
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
import React
|
|
||||||
from 'react';
|
|
||||||
import { Modal, Select } from '@arco-design/web-react';
|
|
||||||
import { SubscribeGroupDetail } from '../../utils/type';
|
|
||||||
import { useNewCookieTargetMutation } from '../cookieManager/cookieConfigSlice';
|
|
||||||
import { useGetSubsQuery } from '../subsribeConfigManager/subscribeConfigSlice';
|
|
||||||
|
|
||||||
interface SubscribeModalProp {
|
|
||||||
visible: boolean;
|
|
||||||
setVisible: (arg0: boolean) => void;
|
|
||||||
cookieId: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ({ visible, setVisible, cookieId }: SubscribeModalProp) {
|
|
||||||
const [newCookieTarget] = useNewCookieTargetMutation();
|
|
||||||
|
|
||||||
const { data: subs } = useGetSubsQuery();
|
|
||||||
const pureSubs = subs ? Object.values(subs)
|
|
||||||
.reduce((pv:Array, cv:SubscribeGroupDetail) => pv.concat(cv.subscribes), []) : [];
|
|
||||||
const [index, setIndex] = React.useState(-1);
|
|
||||||
const handleSubmit = (idx:number) => {
|
|
||||||
const postPromise: ReturnType<typeof newCookieTarget> = newCookieTarget({
|
|
||||||
cookieId,
|
|
||||||
platformName: pureSubs[idx].platformName,
|
|
||||||
target: pureSubs[idx].target,
|
|
||||||
});
|
|
||||||
postPromise.then(() => {
|
|
||||||
setVisible(false);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const { Option } = Select;
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
title="关联 Cookie"
|
|
||||||
visible={visible}
|
|
||||||
onCancel={() => setVisible(false)}
|
|
||||||
onOk={() => handleSubmit(index)}
|
|
||||||
>
|
|
||||||
<Select
|
|
||||||
placeholder="选择要关联的 target"
|
|
||||||
style={{ width: '100%' }}
|
|
||||||
onChange={setIndex}
|
|
||||||
|
|
||||||
>
|
|
||||||
{
|
|
||||||
pureSubs.map((sub, idx) => (
|
|
||||||
<Option
|
|
||||||
key={JSON.stringify(sub)}
|
|
||||||
value={idx}
|
|
||||||
>
|
|
||||||
{JSON.stringify(sub)}
|
|
||||||
</Option>
|
|
||||||
))
|
|
||||||
}
|
|
||||||
</Select>
|
|
||||||
|
|
||||||
</Modal>
|
|
||||||
);
|
|
||||||
}
|
|
@ -6,7 +6,6 @@ import { globalConfUrl } from '../../utils/urls';
|
|||||||
const initialState = {
|
const initialState = {
|
||||||
loaded: false,
|
loaded: false,
|
||||||
platformConf: {},
|
platformConf: {},
|
||||||
siteConf: {},
|
|
||||||
} as GlobalConf;
|
} as GlobalConf;
|
||||||
|
|
||||||
export const loadGlobalConf = createAsyncThunk(
|
export const loadGlobalConf = createAsyncThunk(
|
||||||
@ -25,7 +24,6 @@ export const globalConfSlice = createSlice({
|
|||||||
builder
|
builder
|
||||||
.addCase(loadGlobalConf.fulfilled, (state, payload) => {
|
.addCase(loadGlobalConf.fulfilled, (state, payload) => {
|
||||||
state.platformConf = payload.payload.platformConf;
|
state.platformConf = payload.payload.platformConf;
|
||||||
state.siteConf = payload.payload.siteConf;
|
|
||||||
state.loaded = true;
|
state.loaded = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -35,4 +33,3 @@ export default globalConfSlice.reducer;
|
|||||||
|
|
||||||
export const selectGlobalConfLoaded = (state: RootState) => state.globalConf.loaded;
|
export const selectGlobalConfLoaded = (state: RootState) => state.globalConf.loaded;
|
||||||
export const selectPlatformConf = (state: RootState) => state.globalConf.platformConf;
|
export const selectPlatformConf = (state: RootState) => state.globalConf.platformConf;
|
||||||
export const selectSiteConf = (state: RootState) => state.globalConf.siteConf;
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React, { ReactNode, useEffect, useState } from 'react';
|
import React, { ReactNode, useEffect, useState } from 'react';
|
||||||
import { Breadcrumb, Layout, Menu } from '@arco-design/web-react';
|
import { Breadcrumb, Layout, Menu } from '@arco-design/web-react';
|
||||||
import { IconRobot, IconDashboard, IconUser } from '@arco-design/web-react/icon';
|
import { IconRobot, IconDashboard } from '@arco-design/web-react/icon';
|
||||||
import './Home.css';
|
import './Home.css';
|
||||||
// import SubscribeManager from '../features/subsribeConfigManager/SubscribeManager';
|
// import SubscribeManager from '../features/subsribeConfigManager/SubscribeManager';
|
||||||
import {
|
import {
|
||||||
@ -23,12 +23,6 @@ export default function Home() {
|
|||||||
if (path !== '/home/groups' && !path.startsWith('/home/groups/') && path !== '/home/weight') {
|
if (path !== '/home/groups' && !path.startsWith('/home/groups/') && path !== '/home/weight') {
|
||||||
navigate('/home/groups');
|
navigate('/home/groups');
|
||||||
}
|
}
|
||||||
if (path === '/home/cookie') {
|
|
||||||
navigate('/home/cookie');
|
|
||||||
}
|
|
||||||
if (path.startsWith('/home/cookie/')) {
|
|
||||||
navigate(path);
|
|
||||||
}
|
|
||||||
}, [path]);
|
}, [path]);
|
||||||
|
|
||||||
let currentKey = '';
|
let currentKey = '';
|
||||||
@ -36,8 +30,6 @@ 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);
|
||||||
@ -48,8 +40,6 @@ export default function Home() {
|
|||||||
navigate('/home/groups');
|
navigate('/home/groups');
|
||||||
} else if (tab === 'weight') {
|
} else if (tab === 'weight') {
|
||||||
navigate('/home/weight');
|
navigate('/home/weight');
|
||||||
} else if (tab === 'cookie') {
|
|
||||||
navigate('/home/cookie');
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -90,17 +80,6 @@ export default function Home() {
|
|||||||
</Breadcrumb.Item>
|
</Breadcrumb.Item>
|
||||||
</Breadcrumb>
|
</Breadcrumb>
|
||||||
);
|
);
|
||||||
} else if (path.startsWith('/home/cookie')) {
|
|
||||||
breadcrumbContent = (
|
|
||||||
<Breadcrumb style={{ margin: '16px 0' }}>
|
|
||||||
<Breadcrumb.Item>
|
|
||||||
<Link to="/home/cookie">
|
|
||||||
<IconUser />
|
|
||||||
Cookie 管理
|
|
||||||
</Link>
|
|
||||||
</Breadcrumb.Item>
|
|
||||||
</Breadcrumb>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Layout className="layout-collapse-demo">
|
<Layout className="layout-collapse-demo">
|
||||||
@ -126,10 +105,6 @@ export default function Home() {
|
|||||||
<IconDashboard />
|
<IconDashboard />
|
||||||
调度权重
|
调度权重
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
<Menu.Item key="cookie">
|
|
||||||
<IconUser />
|
|
||||||
Cookie 管理
|
|
||||||
</Menu.Item>
|
|
||||||
</Menu>
|
</Menu>
|
||||||
</Layout.Sider>
|
</Layout.Sider>
|
||||||
<Layout.Content style={{ padding: '0 1em' }}>
|
<Layout.Content style={{ padding: '0 1em' }}>
|
||||||
|
@ -4,10 +4,8 @@ export interface TokenResp {
|
|||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GlobalConf {
|
export interface GlobalConf {
|
||||||
platformConf: AllPlatformConf;
|
platformConf: AllPlatformConf;
|
||||||
siteConf: AllSiteConf;
|
|
||||||
loaded: boolean;
|
loaded: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,10 +13,6 @@ export interface AllPlatformConf {
|
|||||||
[idx: string]: PlatformConfig;
|
[idx: string]: PlatformConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AllSiteConf {
|
|
||||||
[idx: string]: SiteConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CategoryConfig {
|
export interface CategoryConfig {
|
||||||
[idx: number]: string;
|
[idx: number]: string;
|
||||||
}
|
}
|
||||||
@ -31,11 +25,6 @@ export interface PlatformConfig {
|
|||||||
hasTarget: boolean;
|
hasTarget: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SiteConfig {
|
|
||||||
name: string
|
|
||||||
enable_cookie: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SubscribeConfig {
|
export interface SubscribeConfig {
|
||||||
platformName: string;
|
platformName: string;
|
||||||
target: string;
|
target: string;
|
||||||
@ -80,47 +69,3 @@ export interface PlatformWeightConfigResp {
|
|||||||
platform_name: string;
|
platform_name: string;
|
||||||
weight: WeightConfig;
|
weight: WeightConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Target {
|
|
||||||
platform_name: string;
|
|
||||||
target_name: string;
|
|
||||||
target: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Cookie {
|
|
||||||
id: number;
|
|
||||||
site_name: string;
|
|
||||||
friendly_name: string;
|
|
||||||
last_usage: Date;
|
|
||||||
status: string;
|
|
||||||
cd_milliseconds: number;
|
|
||||||
is_universal: boolean;
|
|
||||||
is_anonymous: boolean;
|
|
||||||
tags: { [key: string]: string };
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CookieTarget {
|
|
||||||
target: Target;
|
|
||||||
cookieId: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NewCookieParam {
|
|
||||||
siteName: string
|
|
||||||
content: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DelCookieParam {
|
|
||||||
cookieId: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NewCookieTargetParam {
|
|
||||||
platformName: string;
|
|
||||||
target: string;
|
|
||||||
cookieId: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DelCookieTargetParam {
|
|
||||||
platformName: string;
|
|
||||||
target: string;
|
|
||||||
cookieId: number;
|
|
||||||
}
|
|
||||||
|
@ -210,11 +210,10 @@ async def update_weigth_config(platformName: str, target: str, weight_config: We
|
|||||||
|
|
||||||
|
|
||||||
@router.get("/cookie", dependencies=[Depends(check_is_superuser)])
|
@router.get("/cookie", dependencies=[Depends(check_is_superuser)])
|
||||||
async def get_cookie(site_name: str | None = None, target: str | None = None) -> list[Cookie]:
|
async def get_cookie(site_name: str = None, target: str = None) -> list[Cookie]:
|
||||||
cookies_in_db = await config.get_cookie(site_name, is_anonymous=False)
|
cookies_in_db = await config.get_cookie(site_name, is_anonymous=False)
|
||||||
# client_mgr = cast(CookieClientManager, site_manager[site_name].client_mgr)
|
client_mgr = cast(CookieClientManager, site_manager[site_name].client_mgr)
|
||||||
# friendly_names = [await client_mgr.get_cookie_friendly_name(x) for x in cookies_in_db]
|
friendly_names = [await client_mgr.get_cookie_friendly_name(x) for x in cookies_in_db]
|
||||||
friendly_names = [x.content[:10] for x in cookies_in_db]
|
|
||||||
return [
|
return [
|
||||||
Cookie(
|
Cookie(
|
||||||
id=cookies_in_db[i].id,
|
id=cookies_in_db[i].id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user