mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-09-19 17:52:27 +08:00
Compare commits
5 Commits
4517f6996b
...
996a3119bf
Author | SHA1 | Date | |
---|---|---|---|
996a3119bf | |||
59d42531a3 | |||
cc31ef88ef | |||
0083f0311a | |||
6990f04a74 |
13
admin-frontend/src/features/cookieManager/CookieManager.css
Normal file
13
admin-frontend/src/features/cookieManager/CookieManager.css
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
.list-actions-icon {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
border-radius: 50%;
|
||||||
|
transition: all 0.1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-actions-icon:hover {
|
||||||
|
background-color: var(--color-fill-3);
|
||||||
|
}
|
@ -4,11 +4,13 @@ import {
|
|||||||
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 { Link } from 'react-router-dom';
|
||||||
|
import { IconDelete, IconEdit } from '@arco-design/web-react/icon';
|
||||||
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';
|
||||||
import { useGetCookiesQuery, useDeleteCookieMutation } from './cookieConfigSlice';
|
import { useGetCookiesQuery, useDeleteCookieMutation } from './cookieConfigSlice';
|
||||||
import CookieModal from './CookieModal';
|
import CookieModal from './CookieModal';
|
||||||
|
import './CookieManager.css';
|
||||||
|
|
||||||
interface CookieSite {
|
interface CookieSite {
|
||||||
site: SiteConfig;
|
site: SiteConfig;
|
||||||
@ -59,9 +61,14 @@ export default function CookieManager() {
|
|||||||
>
|
>
|
||||||
|
|
||||||
{cookies.map((cookie) => (
|
{cookies.map((cookie) => (
|
||||||
<List>
|
<List
|
||||||
|
bordered={false}
|
||||||
|
>
|
||||||
|
|
||||||
<List.Item key={cookie.id}>
|
<List.Item
|
||||||
|
key={cookie.id}
|
||||||
|
style={{ padding: '20px 0', borderBottom: '1px solid var(--color-fill-3)' }}
|
||||||
|
>
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
||||||
|
|
||||||
<Popover
|
<Popover
|
||||||
@ -82,22 +89,20 @@ export default function CookieManager() {
|
|||||||
|
|
||||||
</Popover>
|
</Popover>
|
||||||
|
|
||||||
<div>
|
<div style={{ display: 'flex' }}>
|
||||||
|
|
||||||
<Link to={`/home/cookie/${cookie.id}`}>
|
<Link to={`/home/cookie/${cookie.id}`}>
|
||||||
<Button
|
<span className="list-actions-icon">
|
||||||
type="primary"
|
<IconEdit />
|
||||||
style={{ marginRight: '10px' }}
|
</span>
|
||||||
>
|
|
||||||
关联详情
|
|
||||||
</Button>
|
|
||||||
</Link>
|
</Link>
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title={`确定删除 Cookie ${cookie.friendly_name} ?`}
|
title={`确定删除 Cookie ${cookie.friendly_name} ?`}
|
||||||
onOk={handleDelCookie(cookie.id.toString())}
|
onOk={handleDelCookie(cookie.id.toString())}
|
||||||
>
|
>
|
||||||
|
<span className="list-actions-icon">
|
||||||
<Button type="primary" status="danger">删除</Button>
|
<IconDelete />
|
||||||
|
</span>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Button, Empty, Space, Table, Typography,
|
Button, Space, Table, Typography,
|
||||||
} from '@arco-design/web-react';
|
} from '@arco-design/web-react';
|
||||||
import { useDeleteCookieTargetMutation, useGetCookieTargetsQuery } from '../cookieManager/cookieConfigSlice';
|
import { useDeleteCookieTargetMutation, useGetCookieTargetsQuery } from '../cookieManager/cookieConfigSlice';
|
||||||
import { CookieTarget } from '../../utils/type';
|
import { CookieTarget } from '../../utils/type';
|
||||||
@ -11,15 +11,16 @@ export default function () {
|
|||||||
const { cookieId } = useParams();
|
const { cookieId } = useParams();
|
||||||
const { data: cookieTargets } = useGetCookieTargetsQuery(cookieId);
|
const { data: cookieTargets } = useGetCookieTargetsQuery(cookieId);
|
||||||
|
|
||||||
console.log(cookieTargets);
|
|
||||||
const [showModal, setShowModal] = useState(false);
|
const [showModal, setShowModal] = useState(false);
|
||||||
const [deleteCookieTarget] = useDeleteCookieTargetMutation();
|
const [deleteCookieTarget] = useDeleteCookieTargetMutation();
|
||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
|
console.log('before', showModal);
|
||||||
setShowModal(true);
|
setShowModal(true);
|
||||||
|
console.log('after', showModal);
|
||||||
};
|
};
|
||||||
const handleDelete = (record: CookieTarget) => () => {
|
const handleDelete = (record: CookieTarget) => () => {
|
||||||
deleteCookieTarget({
|
deleteCookieTarget({
|
||||||
cookieId,
|
cookieId: record.cookieId,
|
||||||
target: record.target.target,
|
target: record.target.target,
|
||||||
platformName: record.target.platform_name,
|
platformName: record.target.platform_name,
|
||||||
});
|
});
|
||||||
@ -49,7 +50,7 @@ export default function () {
|
|||||||
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
if (cookieId) {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<span>
|
<span>
|
||||||
@ -62,18 +63,12 @@ export default function () {
|
|||||||
rowKey={(record: CookieTarget) => `${record.target.platform_name}-${record.target.target}`}
|
rowKey={(record: CookieTarget) => `${record.target.platform_name}-${record.target.target}`}
|
||||||
scroll={{ x: true }}
|
scroll={{ x: true }}
|
||||||
/>
|
/>
|
||||||
{
|
|
||||||
cookieTargets && cookieTargets.length > 0
|
|
||||||
&& (
|
|
||||||
<CookieTargetModal
|
<CookieTargetModal
|
||||||
|
key={cookieId}
|
||||||
visible={showModal}
|
visible={showModal}
|
||||||
setVisible={setShowModal}
|
setVisible={setShowModal}
|
||||||
cookieId={cookieId}
|
cookieId={cookieId}
|
||||||
/>
|
/>
|
||||||
)
|
|
||||||
}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return <Empty />;
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,25 @@
|
|||||||
import React
|
import React
|
||||||
from 'react';
|
from 'react';
|
||||||
import { Modal, Select } from '@arco-design/web-react';
|
import { Modal, Select } from '@arco-design/web-react';
|
||||||
import { SubscribeGroupDetail } from '../../utils/type';
|
import { SubscribeConfig, SubscribeGroupDetail } from '../../utils/type';
|
||||||
import { useNewCookieTargetMutation } from '../cookieManager/cookieConfigSlice';
|
import { useNewCookieTargetMutation } from '../cookieManager/cookieConfigSlice';
|
||||||
import { useGetSubsQuery } from '../subsribeConfigManager/subscribeConfigSlice';
|
import { useGetSubsQuery } from '../subsribeConfigManager/subscribeConfigSlice';
|
||||||
|
|
||||||
interface SubscribeModalProp {
|
interface SubscribeModalProp {
|
||||||
|
cookieId: number;
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
setVisible: (arg0: boolean) => void;
|
setVisible: (arg0: boolean) => void;
|
||||||
cookieId: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ({ visible, setVisible, cookieId }: SubscribeModalProp) {
|
export default function ({ cookieId, visible, setVisible }: SubscribeModalProp) {
|
||||||
const [newCookieTarget] = useNewCookieTargetMutation();
|
const [newCookieTarget] = useNewCookieTargetMutation();
|
||||||
|
|
||||||
const { data: subs } = useGetSubsQuery();
|
const { data: subs } = useGetSubsQuery();
|
||||||
const pureSubs = subs ? Object.values(subs)
|
const pureSubs:SubscribeConfig[] = subs ? Object.values(subs)
|
||||||
.reduce((pv:Array, cv:SubscribeGroupDetail) => pv.concat(cv.subscribes), []) : [];
|
.reduce((
|
||||||
|
pv:Array<SubscribeConfig>,
|
||||||
|
cv:SubscribeGroupDetail,
|
||||||
|
) => pv.concat(cv.subscribes), []) : [];
|
||||||
const [index, setIndex] = React.useState(-1);
|
const [index, setIndex] = React.useState(-1);
|
||||||
const handleSubmit = (idx:number) => {
|
const handleSubmit = (idx:number) => {
|
||||||
const postPromise: ReturnType<typeof newCookieTarget> = newCookieTarget({
|
const postPromise: ReturnType<typeof newCookieTarget> = newCookieTarget({
|
||||||
@ -40,18 +43,16 @@ export default function ({ visible, setVisible, cookieId }: SubscribeModalProp)
|
|||||||
placeholder="选择要关联的 target"
|
placeholder="选择要关联的 target"
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
onChange={setIndex}
|
onChange={setIndex}
|
||||||
|
|
||||||
>
|
>
|
||||||
{
|
{pureSubs.length
|
||||||
pureSubs.map((sub, idx) => (
|
&& pureSubs.map((sub, idx) => (
|
||||||
<Option
|
<Option
|
||||||
key={JSON.stringify(sub)}
|
key={JSON.stringify(sub)}
|
||||||
value={idx}
|
value={idx}
|
||||||
>
|
>
|
||||||
{JSON.stringify(sub)}
|
{JSON.stringify(sub)}
|
||||||
</Option>
|
</Option>
|
||||||
))
|
))}
|
||||||
}
|
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
</Modal>
|
</Modal>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
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, IconIdcard,
|
||||||
|
} from '@arco-design/web-react/icon';
|
||||||
import './Home.css';
|
import './Home.css';
|
||||||
// import SubscribeManager from '../features/subsribeConfigManager/SubscribeManager';
|
|
||||||
import {
|
import {
|
||||||
Link, Navigate, Outlet, useLocation, useNavigate,
|
Link, Navigate, Outlet, useLocation, useNavigate,
|
||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
@ -95,7 +96,7 @@ export default function Home() {
|
|||||||
<Breadcrumb style={{ margin: '16px 0' }}>
|
<Breadcrumb style={{ margin: '16px 0' }}>
|
||||||
<Breadcrumb.Item>
|
<Breadcrumb.Item>
|
||||||
<Link to="/home/cookie">
|
<Link to="/home/cookie">
|
||||||
<IconUser />
|
<IconIdcard />
|
||||||
Cookie 管理
|
Cookie 管理
|
||||||
</Link>
|
</Link>
|
||||||
</Breadcrumb.Item>
|
</Breadcrumb.Item>
|
||||||
@ -116,20 +117,23 @@ export default function Home() {
|
|||||||
>
|
>
|
||||||
<Menu
|
<Menu
|
||||||
defaultSelectedKeys={[selectedTab]}
|
defaultSelectedKeys={[selectedTab]}
|
||||||
onClickMenuItem={(key) => { handleTabSelect(key); }}
|
onClickMenuItem={(key) => {
|
||||||
|
handleTabSelect(key);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Menu.Item key="groups">
|
<Menu.Item key="groups">
|
||||||
<IconRobot />
|
<IconRobot />
|
||||||
订阅管理
|
订阅管理
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
<Menu.Item key="cookie">
|
||||||
|
<IconIdcard />
|
||||||
|
Cookie 管理
|
||||||
|
</Menu.Item>
|
||||||
<Menu.Item key="weight">
|
<Menu.Item key="weight">
|
||||||
<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' }}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user