mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-16 17:09:20 +08:00
添加log查询api
This commit is contained in:
@@ -39,7 +39,6 @@ const Crontab = () => {
|
||||
<PageContainer
|
||||
className="code-mirror-wrapper"
|
||||
title="互助码"
|
||||
loading={loading}
|
||||
header={{
|
||||
style: {
|
||||
padding: '4px 16px 4px 15px',
|
||||
|
||||
@@ -35,63 +35,6 @@ const Config = () => {
|
||||
});
|
||||
};
|
||||
|
||||
function sleep(time: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, time));
|
||||
}
|
||||
|
||||
const showQrCode = () => {
|
||||
request.get(`${config.apiPrefix}qrcode`).then(async (data) => {
|
||||
const modal = Modal.info({
|
||||
title: '二维码',
|
||||
content: (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
marginLeft: -38,
|
||||
}}
|
||||
>
|
||||
<QRCode
|
||||
style={{
|
||||
width: 200,
|
||||
height: 200,
|
||||
marginBottom: 10,
|
||||
marginTop: 20,
|
||||
}}
|
||||
value={data.qrcode}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
});
|
||||
getCookie(modal);
|
||||
});
|
||||
};
|
||||
|
||||
const getCookie = async (modal: { destroy: () => void }) => {
|
||||
for (let i = 0; i < 50; i++) {
|
||||
const {
|
||||
data: { cookie, errcode, message },
|
||||
} = await request.get(`${config.apiPrefix}cookie`);
|
||||
if (cookie) {
|
||||
notification.success({
|
||||
message: 'Cookie获取成功',
|
||||
});
|
||||
modal.destroy();
|
||||
Modal.success({
|
||||
title: '获取Cookie成功',
|
||||
content: <div>{cookie}</div>,
|
||||
});
|
||||
break;
|
||||
}
|
||||
if (errcode !== 176) {
|
||||
notification.error({ message });
|
||||
break;
|
||||
}
|
||||
await sleep(2000);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (document.body.clientWidth < 768) {
|
||||
setWdith('auto');
|
||||
@@ -109,7 +52,6 @@ const Config = () => {
|
||||
<PageContainer
|
||||
className="code-mirror-wrapper"
|
||||
title="config.sh"
|
||||
loading={loading}
|
||||
extra={[
|
||||
<Button key="1" type="primary" onClick={updateConfig}>
|
||||
保存
|
||||
|
||||
@@ -51,7 +51,6 @@ const Crontab = () => {
|
||||
<PageContainer
|
||||
className="code-mirror-wrapper"
|
||||
title="crontab.list"
|
||||
loading={loading}
|
||||
extra={[
|
||||
<Button key="1" type="primary" onClick={updateConfig}>
|
||||
保存
|
||||
|
||||
@@ -51,7 +51,6 @@ const Crontab = () => {
|
||||
<PageContainer
|
||||
className="code-mirror-wrapper"
|
||||
title="diy.sh"
|
||||
loading={loading}
|
||||
extra={[
|
||||
<Button key="1" type="primary" onClick={updateConfig}>
|
||||
保存
|
||||
|
||||
+23
-12
@@ -21,20 +21,32 @@ const Log = () => {
|
||||
};
|
||||
|
||||
const formatData = (tree: any[]) => {
|
||||
return tree.map(x => {
|
||||
x.title = x.dirName;
|
||||
x.value = x.dirName;
|
||||
x.disabled = true;
|
||||
x.children = x.files.map((y: string) => ({ title: y, key: y, value: y, parent: x.dirName }));
|
||||
return tree.map((x) => {
|
||||
x.title = x.name;
|
||||
x.value = x.name;
|
||||
x.disabled = x.isDir;
|
||||
x.children = x.files.map((y: string) => ({
|
||||
title: y,
|
||||
key: y,
|
||||
value: y,
|
||||
parent: x.name,
|
||||
}));
|
||||
return x;
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const getLog = (node: any) => {
|
||||
setLoading(true);
|
||||
request.get(`${config.apiPrefix}logs/${node.parent}/${node.value}`).then((data) => {
|
||||
setValue(data);
|
||||
}).finally(() => setLoading(false));
|
||||
let url = `${node.parent}/${node.value}`;
|
||||
if (!node.isDir) {
|
||||
url = node.value;
|
||||
}
|
||||
request
|
||||
.get(`${config.apiPrefix}logs/${url}`)
|
||||
.then((data) => {
|
||||
setValue(data.data);
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
};
|
||||
|
||||
const onSelect = (value: any, node: any) => {
|
||||
@@ -60,7 +72,6 @@ const Log = () => {
|
||||
<PageContainer
|
||||
className="code-mirror-wrapper"
|
||||
title={title}
|
||||
loading={loading}
|
||||
extra={[
|
||||
<TreeSelect
|
||||
style={{ width: 280 }}
|
||||
@@ -71,7 +82,7 @@ const Log = () => {
|
||||
showSearch
|
||||
key="title"
|
||||
onSelect={onSelect}
|
||||
/>
|
||||
/>,
|
||||
]}
|
||||
header={{
|
||||
style: {
|
||||
|
||||
Reference in New Issue
Block a user