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
bb63529fe8
commit
bc44e40f56
@ -1,11 +1,10 @@
|
|||||||
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, Table, Typography,
|
Button, Empty, Space, Table, Typography,
|
||||||
} from '@arco-design/web-react';
|
} from '@arco-design/web-react';
|
||||||
import { useGetCookieTargetsQuery } from '../cookieManager/cookieConfigSlice';
|
import { useDeleteCookieTargetMutation, useGetCookieTargetsQuery } from '../cookieManager/cookieConfigSlice';
|
||||||
import { SubscribeConfig } from '../../utils/type';
|
import { CookieTarget } from '../../utils/type';
|
||||||
import { useDeleteSubMutation } from '../subsribeConfigManager/subscribeConfigSlice';
|
|
||||||
import CookieTargetModal from './CookieTargetModal';
|
import CookieTargetModal from './CookieTargetModal';
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
@ -13,12 +12,18 @@ export default function () {
|
|||||||
const { data: cookieTargets } = useGetCookieTargetsQuery(cookieId);
|
const { data: cookieTargets } = useGetCookieTargetsQuery(cookieId);
|
||||||
|
|
||||||
console.log(cookieTargets);
|
console.log(cookieTargets);
|
||||||
const [{ isLoading: deleteIsLoading }] = useDeleteSubMutation();
|
|
||||||
const isLoading = deleteIsLoading;
|
|
||||||
const [showModal, setShowModal] = useState(false);
|
const [showModal, setShowModal] = useState(false);
|
||||||
|
const [deleteCookieTarget] = useDeleteCookieTargetMutation();
|
||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
setShowModal(true);
|
setShowModal(true);
|
||||||
};
|
};
|
||||||
|
const handleDelete = (record: CookieTarget) => () => {
|
||||||
|
deleteCookieTarget({
|
||||||
|
cookieId,
|
||||||
|
target: record.target.target,
|
||||||
|
platformName: record.target.platform_name,
|
||||||
|
});
|
||||||
|
};
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: '平台名称',
|
title: '平台名称',
|
||||||
@ -33,6 +38,16 @@ export default function () {
|
|||||||
title: 'Cookie ID',
|
title: 'Cookie ID',
|
||||||
dataIndex: '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) {
|
if (cookieId) {
|
||||||
return (
|
return (
|
||||||
@ -44,8 +59,7 @@ export default function () {
|
|||||||
<Table
|
<Table
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={cookieTargets}
|
data={cookieTargets}
|
||||||
rowKey={(record: SubscribeConfig) => `${record.platformName}-${record.target}`}
|
rowKey={(record: CookieTarget) => `${record.target.platform_name}-${record.target.target}`}
|
||||||
loading={isLoading}
|
|
||||||
scroll={{ x: true }}
|
scroll={{ x: true }}
|
||||||
/>
|
/>
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user