mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-04 02:26:11 +08:00
✨ (admin) 支持查看cookie详情
This commit is contained in:
parent
10bb6179ae
commit
8174ec895d
@ -2,13 +2,13 @@ import React, { useState } from 'react';
|
|||||||
import { Form, Input, Modal } from '@arco-design/web-react';
|
import { Form, Input, Modal } from '@arco-design/web-react';
|
||||||
import { useNewCookieMutation } from './cookieConfigSlice';
|
import { useNewCookieMutation } from './cookieConfigSlice';
|
||||||
|
|
||||||
interface CookieModalProps {
|
interface CookieAddModalProps {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
setVisible: (arg0: boolean) => void;
|
setVisible: (arg0: boolean) => void;
|
||||||
siteName: string;
|
siteName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function CookieAddModal({ visible, setVisible, siteName }: CookieModalProps) {
|
function CookieAddModal({ visible, setVisible, siteName }: CookieAddModalProps) {
|
||||||
const FormItem = Form.Item;
|
const FormItem = Form.Item;
|
||||||
const [content, setContent] = useState<string>('');
|
const [content, setContent] = useState<string>('');
|
||||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
const [confirmLoading, setConfirmLoading] = useState(false);
|
||||||
|
@ -1,28 +1,17 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Form, Input, Modal } from '@arco-design/web-react';
|
import { Form, Input, Modal } from '@arco-design/web-react';
|
||||||
import { useNewCookieMutation } from './cookieConfigSlice';
|
import { useNewCookieMutation } from './cookieConfigSlice';
|
||||||
|
import { Cookie } from '../../utils/type';
|
||||||
|
|
||||||
interface CookieModalProps {
|
interface CookieEditModalProps {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
setVisible: (arg0: boolean) => void;
|
setVisible: (arg0: boolean) => void;
|
||||||
siteName: string;
|
cookie: Cookie | null
|
||||||
}
|
}
|
||||||
|
|
||||||
function CookieEditModal({ visible, setVisible, siteName }: CookieModalProps) {
|
function CookieEditModal({ visible, setVisible, cookie }: CookieEditModalProps) {
|
||||||
const FormItem = Form.Item;
|
const FormItem = Form.Item;
|
||||||
const [content, setContent] = useState<string>('');
|
|
||||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
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 (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
@ -30,23 +19,41 @@ function CookieEditModal({ visible, setVisible, siteName }: CookieModalProps) {
|
|||||||
visible={visible}
|
visible={visible}
|
||||||
onCancel={() => setVisible(false)}
|
onCancel={() => setVisible(false)}
|
||||||
confirmLoading={confirmLoading}
|
confirmLoading={confirmLoading}
|
||||||
onOk={onSubmit}
|
// onOk={onSubmit}
|
||||||
style={{ maxWidth: '90vw' }}
|
style={{ maxWidth: '90vw', minWidth: '50vw' }}
|
||||||
>
|
>
|
||||||
|
{cookie
|
||||||
|
&& (
|
||||||
<Form autoComplete="off">
|
<Form autoComplete="off">
|
||||||
<FormItem label="Site Name" required>
|
<FormItem label="Cookie ID">
|
||||||
<Input placeholder="Please enter site name" value={siteName} disabled />
|
<Input disabled value={cookie.id.toString()} />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem label="Content" required>
|
<FormItem label="Cookie 名称">
|
||||||
|
<Input value={cookie.friendly_name} disabled />
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="所属站点">
|
||||||
|
<Input value={cookie.site_name} disabled />
|
||||||
|
</FormItem>
|
||||||
|
|
||||||
|
<FormItem label="标签">
|
||||||
<Input.TextArea
|
<Input.TextArea
|
||||||
placeholder="Please enter content"
|
value={JSON.stringify(cookie.tags)}
|
||||||
value={content}
|
disabled
|
||||||
onChange={setContent}
|
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
||||||
|
<FormItem label="最后使用时间">
|
||||||
|
<Input value={cookie.last_usage.toString()} disabled />
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="状态">
|
||||||
|
<Input value={cookie.status} disabled />
|
||||||
|
</FormItem>
|
||||||
|
<FormItem label="冷却时间(毫秒)">
|
||||||
|
<Input value={cookie.cd_milliseconds.toString()} disabled />
|
||||||
|
</FormItem>
|
||||||
|
|
||||||
</Form>
|
</Form>
|
||||||
|
)}
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import { selectPlatformConf, selectSiteConf } from '../globalConf/globalConfSlic
|
|||||||
import { Cookie, PlatformConfig } from '../../utils/type';
|
import { Cookie, PlatformConfig } from '../../utils/type';
|
||||||
import CookieTargetModal from '../cookieTargetManager/CookieTargetModal';
|
import CookieTargetModal from '../cookieTargetManager/CookieTargetModal';
|
||||||
import CookieAddModal from './CookieAddModal';
|
import CookieAddModal from './CookieAddModal';
|
||||||
|
import CookieEditModal from './CookieEditModal';
|
||||||
|
|
||||||
export default function CookieManager() {
|
export default function CookieManager() {
|
||||||
const { siteName } = useParams();
|
const { siteName } = useParams();
|
||||||
@ -21,9 +22,9 @@ export default function CookieManager() {
|
|||||||
const cookiesList = cookieDict ? Object.values(cookieDict) : [];
|
const cookiesList = cookieDict ? Object.values(cookieDict) : [];
|
||||||
|
|
||||||
// 添加cookie
|
// 添加cookie
|
||||||
const [showModal, setShowModal] = React.useState(false);
|
const [showAddModal, setShowAddModal] = React.useState(false);
|
||||||
const handleAddCookie = () => () => {
|
const handleAddCookie = () => () => {
|
||||||
setShowModal(true);
|
setShowAddModal(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 删除cookie
|
// 删除cookie
|
||||||
@ -34,6 +35,14 @@ export default function CookieManager() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 编辑cookie
|
||||||
|
const [showEditModal, setShowEditModal] = React.useState(false);
|
||||||
|
const [editCookie, setEditCookie] = React.useState<Cookie | null>(null);
|
||||||
|
const handleEditCookie = (cookie: Cookie) => () => {
|
||||||
|
setEditCookie(cookie);
|
||||||
|
setShowEditModal(true);
|
||||||
|
};
|
||||||
|
|
||||||
let data = [
|
let data = [
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
@ -50,7 +59,6 @@ export default function CookieManager() {
|
|||||||
if (siteName) {
|
if (siteName) {
|
||||||
data = cookiesList.filter((tSite) => tSite.site_name === siteName);
|
data = cookiesList.filter((tSite) => tSite.site_name === siteName);
|
||||||
}
|
}
|
||||||
console.log(Object.values(platformConf));
|
|
||||||
const platformThatSiteSupport: Record<string, string> = Object.values(platformConf).reduce((p, c) => {
|
const platformThatSiteSupport: Record<string, string> = Object.values(platformConf).reduce((p, c) => {
|
||||||
p[c.siteName] = c.platformName;
|
p[c.siteName] = c.platformName;
|
||||||
return p;
|
return p;
|
||||||
@ -93,6 +101,7 @@ export default function CookieManager() {
|
|||||||
<Button type="text" status="danger">删除</Button>
|
<Button type="text" status="danger">删除</Button>
|
||||||
</span>
|
</span>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
|
<Button type="text" onClick={handleEditCookie(record)}>编辑</Button>
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
|
|
||||||
@ -116,7 +125,8 @@ export default function CookieManager() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Table columns={columns} data={data} />
|
<Table columns={columns} data={data} />
|
||||||
<CookieAddModal visible={showModal} setVisible={setShowModal} siteName={siteName || ''} />
|
<CookieAddModal visible={showAddModal} setVisible={setShowAddModal} siteName={siteName || ''} />
|
||||||
|
<CookieEditModal visible={showEditModal} setVisible={setShowEditModal} cookie={editCookie} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user