添加重置ql reset命令,支持批量操作ck

This commit is contained in:
hanhh 2021-06-07 21:54:49 +08:00
parent 64aadb7eb8
commit 9e666f4348
11 changed files with 166 additions and 39 deletions

16
shell/reset.sh Normal file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
# 导入通用变量与函数
dir_shell=/ql/shell
. $dir_shell/share.sh
echo -e "1. 开始安装青龙依赖\n"
npm_install_2 $dir_root
echo -e "青龙依赖安装完成\n"
echo -e "2. 开始安装脚本依赖\n"
cp -f $dir_sample/package.json $dir_scripts/package.json
npm_install_2 $dir_scripts
echo -e "脚本依赖安装完成\n"
exit 0

View File

@ -56,7 +56,7 @@ import_config() {
user_sum=0 user_sum=0
for line in $(cat $file_cookie); do for line in $(cat $file_cookie); do
let user_sum+=1 let user_sum+=1
eval Cookie${user_sum}="\"$line\"" eval Cookie${user_sum}="\"${line}\""
done done
command_timeout_time=${CommandTimeoutTime:-"1h"} command_timeout_time=${CommandTimeoutTime:-"1h"}
@ -247,8 +247,10 @@ diff_and_copy() {
update_depend() { update_depend() {
local dir_current=$(pwd) local dir_current=$(pwd)
cp -f $dir_sample/package.json $dir_scripts/package.json if [ ! -s $dir_scripts/package.json ] || [[ $(diff $dir_sample/package.json $dir_scripts/package.json) ]]; then
npm_install_2 $dir_scripts cp -f $dir_sample/package.json $dir_scripts/package.json
npm_install_2 $dir_scripts
fi
if [ ! -s $dir_scripts/requirements.txt ] || [[ $(diff $dir_sample/requirements.txt $dir_scripts/requirements.txt) ]]; then if [ ! -s $dir_scripts/requirements.txt ] || [[ $(diff $dir_sample/requirements.txt $dir_scripts/requirements.txt) ]]; then
cp -f $dir_sample/requirements.txt $dir_scripts/requirements.txt cp -f $dir_sample/requirements.txt $dir_scripts/requirements.txt

View File

@ -242,11 +242,13 @@ usage() {
echo -e "5. $cmd_update rmlog <days> # 删除旧日志" echo -e "5. $cmd_update rmlog <days> # 删除旧日志"
echo -e "6. $cmd_update code # 获取互助码" echo -e "6. $cmd_update code # 获取互助码"
echo -e "6. $cmd_update bot # 启动tg-bot" echo -e "6. $cmd_update bot # 启动tg-bot"
echo -e "7. $cmd_update reset # 重置青龙基础环境"
} }
## 更新qinglong ## 更新qinglong
update_qinglong() { update_qinglong() {
echo -e "--------------------------------------------------------------\n" echo -e "--------------------------------------------------------------\n"
[ -f $dir_root/package.json ] && ql_depend_old=$(cat $dir_root/package.json)
reset_romote_url ${dir_root} "${github_proxy_url}https://github.com/whyour/qinglong.git" reset_romote_url ${dir_root} "${github_proxy_url}https://github.com/whyour/qinglong.git"
git_pull_scripts $dir_root git_pull_scripts $dir_root
@ -256,7 +258,8 @@ update_qinglong() {
detect_config_version detect_config_version
update_depend update_depend
npm_install_2 $dir_root [ -f $dir_root/package.json ] && ql_depend_new=$(cat $dir_root/package.json)
[[ "$ql_depend_old" != "$ql_depend_new" ]] && npm_install_2 $dir_root
else else
echo -e "\n更新$dir_root失败,请检查原因...\n" echo -e "\n更新$dir_root失败,请检查原因...\n"
fi fi
@ -417,6 +420,9 @@ main() {
bot) bot)
. $dir_shell/bot.sh . $dir_shell/bot.sh
;; ;;
reset)
. $dir_shell/reset.sh
;;
*) *)
echo -e "命令输入错误...\n" echo -e "命令输入错误...\n"
usage usage

View File

@ -6,7 +6,7 @@ import { Controlled as CodeMirror } from 'react-codemirror2';
import { request } from '@/utils/http'; import { request } from '@/utils/http';
const Config = () => { const Config = () => {
const [width, setWdith] = useState('100%'); const [width, setWidth] = useState('100%');
const [marginLeft, setMarginLeft] = useState(0); const [marginLeft, setMarginLeft] = useState(0);
const [marginTop, setMarginTop] = useState(-72); const [marginTop, setMarginTop] = useState(-72);
const [value, setValue] = useState(''); const [value, setValue] = useState('');
@ -34,11 +34,11 @@ const Config = () => {
useEffect(() => { useEffect(() => {
if (document.body.clientWidth < 768) { if (document.body.clientWidth < 768) {
setWdith('auto'); setWidth('auto');
setMarginLeft(0); setMarginLeft(0);
setMarginTop(0); setMarginTop(0);
} else { } else {
setWdith('100%'); setWidth('100%');
setMarginLeft(0); setMarginLeft(0);
setMarginTop(-72); setMarginTop(-72);
} }

View File

@ -42,6 +42,16 @@ enum StatusColor {
'error', 'error',
} }
enum OperationName {
'启用',
'禁用',
}
enum OperationPath {
'enable',
'disable',
}
const type = 'DragableBodyRow'; const type = 'DragableBodyRow';
const DragableBodyRow = ({ const DragableBodyRow = ({
@ -105,17 +115,6 @@ const Config = () => {
return <span style={{ cursor: 'text' }}>{index + 1} </span>; return <span style={{ cursor: 'text' }}>{index + 1} </span>;
}, },
}, },
// {
// title: '用户名',
// dataIndex: 'pin',
// key: 'pin',
// align: 'center' as const,
// render: (text: string, record: any) => {
// const match = record.value.match(/pt_pin=([^; ]+)(?=;?)/);
// const val = (match && match[1]) || '未匹配用户名';
// return <span style={{ cursor: 'text' }}>{decodeUrl(val)}</span>;
// },
// },
{ {
title: '昵称', title: '昵称',
dataIndex: 'nickname', dataIndex: 'nickname',
@ -123,8 +122,10 @@ const Config = () => {
align: 'center' as const, align: 'center' as const,
width: '15%', width: '15%',
render: (text: string, record: any, index: number) => { render: (text: string, record: any, index: number) => {
const match = record.value.match(/pt_pin=([^; ]+)(?=;?)/);
const val = (match && match[1]) || '未匹配用户名';
return ( return (
<span style={{ cursor: 'text' }}>{record.nickname || '-'} </span> <span style={{ cursor: 'text' }}>{record.nickname || val} </span>
); );
}, },
}, },
@ -204,13 +205,14 @@ const Config = () => {
), ),
}, },
]; ];
const [width, setWdith] = useState('100%'); const [width, setWidth] = useState('100%');
const [marginLeft, setMarginLeft] = useState(0); const [marginLeft, setMarginLeft] = useState(0);
const [marginTop, setMarginTop] = useState(-72); const [marginTop, setMarginTop] = useState(-72);
const [value, setValue] = useState<any[]>([]); const [value, setValue] = useState<any[]>([]);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [isModalVisible, setIsModalVisible] = useState(false); const [isModalVisible, setIsModalVisible] = useState(false);
const [editedCookie, setEditedCookie] = useState(); const [editedCookie, setEditedCookie] = useState();
const [selectedRowIds, setSelectedRowIds] = useState<string[]>([]);
const getCookies = () => { const getCookies = () => {
setLoading(true); setLoading(true);
@ -376,13 +378,68 @@ const Config = () => {
[value], [value],
); );
const onSelectChange = (selectedIds: any[]) => {
setSelectedRowIds(selectedIds);
};
const rowSelection = {
selectedRowIds,
onChange: onSelectChange,
};
const delCookies = () => {
Modal.confirm({
title: '确认删除',
content: <>Cookie吗</>,
onOk() {
request
.delete(`${config.apiPrefix}cookies`, { data: selectedRowIds })
.then((data: any) => {
if (data.code === 200) {
message.success('批量删除成功');
setSelectedRowIds([]);
getCookies();
} else {
message.error(data);
}
});
},
onCancel() {
console.log('Cancel');
},
});
};
const operateCookies = (operationStatus: number) => {
Modal.confirm({
title: `确认${OperationName[operationStatus]}`,
content: <>{OperationName[operationStatus]}Cookie吗</>,
onOk() {
request
.put(`${config.apiPrefix}cookies/${OperationPath[operationStatus]}`, {
data: selectedRowIds,
})
.then((data: any) => {
if (data.code === 200) {
getCookies();
} else {
message.error(data);
}
});
},
onCancel() {
console.log('Cancel');
},
});
};
useEffect(() => { useEffect(() => {
if (document.body.clientWidth < 768) { if (document.body.clientWidth < 768) {
setWdith('auto'); setWidth('auto');
setMarginLeft(0); setMarginLeft(0);
setMarginTop(0); setMarginTop(0);
} else { } else {
setWdith('100%'); setWidth('100%');
setMarginLeft(0); setMarginLeft(0);
setMarginTop(-72); setMarginTop(-72);
} }
@ -411,12 +468,42 @@ const Config = () => {
}, },
}} }}
> >
{selectedRowIds.length > 0 && (
<div style={{ marginBottom: 16 }}>
<Button
type="primary"
style={{ marginBottom: 5 }}
onClick={delCookies}
>
</Button>
<Button
type="primary"
onClick={() => operateCookies(0)}
style={{ marginLeft: 8, marginBottom: 5 }}
>
</Button>
<Button
type="primary"
onClick={() => operateCookies(1)}
style={{ marginLeft: 8, marginRight: 8 }}
>
</Button>
<span style={{ marginLeft: 8 }}>
<a>{selectedRowIds?.length}</a>
</span>
</div>
)}
<DndProvider backend={HTML5Backend}> <DndProvider backend={HTML5Backend}>
<Table <Table
columns={columns} columns={columns}
rowSelection={rowSelection}
pagination={false} pagination={false}
dataSource={value} dataSource={value}
rowKey="value" rowKey="_id"
size="middle" size="middle"
scroll={{ x: 768 }} scroll={{ x: 768 }}
components={components} components={components}

View File

@ -176,7 +176,7 @@ const Crontab = () => {
}, },
]; ];
const [width, setWdith] = useState('100%'); const [width, setWidth] = useState('100%');
const [marginLeft, setMarginLeft] = useState(0); const [marginLeft, setMarginLeft] = useState(0);
const [marginTop, setMarginTop] = useState(-72); const [marginTop, setMarginTop] = useState(-72);
const [value, setValue] = useState<any[]>([]); const [value, setValue] = useState<any[]>([]);
@ -524,11 +524,11 @@ const Crontab = () => {
useEffect(() => { useEffect(() => {
if (document.body.clientWidth < 768) { if (document.body.clientWidth < 768) {
setWdith('auto'); setWidth('auto');
setMarginLeft(0); setMarginLeft(0);
setMarginTop(0); setMarginTop(0);
} else { } else {
setWdith('100%'); setWidth('100%');
setMarginLeft(0); setMarginLeft(0);
setMarginTop(-72); setMarginTop(-72);
} }

View File

@ -27,6 +27,7 @@ const CronLogModal = ({
const [value, setValue] = useState<string>('启动中...'); const [value, setValue] = useState<string>('启动中...');
const [loading, setLoading] = useState<any>(true); const [loading, setLoading] = useState<any>(true);
const [excuting, setExcuting] = useState<any>(true); const [excuting, setExcuting] = useState<any>(true);
const [isPhone, setIsPhone] = useState(false);
const getCronLog = (isFirst?: boolean) => { const getCronLog = (isFirst?: boolean) => {
if (isFirst) { if (isFirst) {
@ -86,6 +87,10 @@ const CronLogModal = ({
} }
}, [cron]); }, [cron]);
useEffect(() => {
setIsPhone(document.body.clientWidth < 768);
}, []);
return ( return (
<Modal <Modal
title={titleElement()} title={titleElement()}
@ -100,7 +105,18 @@ const CronLogModal = ({
onCancel={() => cancel()} onCancel={() => cancel()}
> >
{!loading && value && ( {!loading && value && (
<pre style={{ whiteSpace: 'break-spaces', lineHeight: '17px' }}> <pre
style={
!isPhone
? { whiteSpace: 'break-spaces', lineHeight: '17px' }
: {
whiteSpace: 'break-spaces',
lineHeight: '17px',
width: 375,
zoom: 0.88,
}
}
>
{value} {value}
</pre> </pre>
)} )}

View File

@ -7,7 +7,7 @@ import ReactDiffViewer from 'react-diff-viewer';
import './index.less'; import './index.less';
const Crontab = () => { const Crontab = () => {
const [width, setWdith] = useState('100%'); const [width, setWidth] = useState('100%');
const [marginLeft, setMarginLeft] = useState(0); const [marginLeft, setMarginLeft] = useState(0);
const [marginTop, setMarginTop] = useState(-72); const [marginTop, setMarginTop] = useState(-72);
const [value, setValue] = useState(''); const [value, setValue] = useState('');
@ -32,11 +32,11 @@ const Crontab = () => {
useEffect(() => { useEffect(() => {
if (document.body.clientWidth < 768) { if (document.body.clientWidth < 768) {
setWdith('auto'); setWidth('auto');
setMarginLeft(0); setMarginLeft(0);
setMarginTop(0); setMarginTop(0);
} else { } else {
setWdith('100%'); setWidth('100%');
setMarginLeft(0); setMarginLeft(0);
setMarginTop(-72); setMarginTop(-72);
} }

View File

@ -6,7 +6,7 @@ import { Controlled as CodeMirror } from 'react-codemirror2';
import { request } from '@/utils/http'; import { request } from '@/utils/http';
const Crontab = () => { const Crontab = () => {
const [width, setWdith] = useState('100%'); const [width, setWidth] = useState('100%');
const [marginLeft, setMarginLeft] = useState(0); const [marginLeft, setMarginLeft] = useState(0);
const [marginTop, setMarginTop] = useState(-72); const [marginTop, setMarginTop] = useState(-72);
const [value, setValue] = useState(''); const [value, setValue] = useState('');
@ -34,11 +34,11 @@ const Crontab = () => {
useEffect(() => { useEffect(() => {
if (document.body.clientWidth < 768) { if (document.body.clientWidth < 768) {
setWdith('auto'); setWidth('auto');
setMarginLeft(0); setMarginLeft(0);
setMarginTop(0); setMarginTop(0);
} else { } else {
setWdith('100%'); setWidth('100%');
setMarginLeft(0); setMarginLeft(0);
setMarginTop(-72); setMarginTop(-72);
} }

View File

@ -36,7 +36,7 @@ function getFilterData(keyword: string, data: any) {
} }
const Log = () => { const Log = () => {
const [width, setWdith] = useState('100%'); const [width, setWidth] = useState('100%');
const [marginLeft, setMarginLeft] = useState(0); const [marginLeft, setMarginLeft] = useState(0);
const [marginTop, setMarginTop] = useState(-72); const [marginTop, setMarginTop] = useState(-72);
const [title, setTitle] = useState('请选择日志文件'); const [title, setTitle] = useState('请选择日志文件');
@ -103,12 +103,12 @@ const Log = () => {
useEffect(() => { useEffect(() => {
if (document.body.clientWidth < 768) { if (document.body.clientWidth < 768) {
setWdith('auto'); setWidth('auto');
setMarginLeft(0); setMarginLeft(0);
setMarginTop(0); setMarginTop(0);
setIsPhone(true); setIsPhone(true);
} else { } else {
setWdith('100%'); setWidth('100%');
setMarginLeft(0); setMarginLeft(0);
setMarginTop(-72); setMarginTop(-72);
setIsPhone(false); setIsPhone(false);

View File

@ -18,7 +18,7 @@ const optionsWithDisabled = [
]; ];
const Password = () => { const Password = () => {
const [width, setWdith] = useState('100%'); const [width, setWidth] = useState('100%');
const [marginLeft, setMarginLeft] = useState(0); const [marginLeft, setMarginLeft] = useState(0);
const [marginTop, setMarginTop] = useState(-72); const [marginTop, setMarginTop] = useState(-72);
const [value, setValue] = useState(''); const [value, setValue] = useState('');
@ -56,11 +56,11 @@ const Password = () => {
useEffect(() => { useEffect(() => {
if (document.body.clientWidth < 768) { if (document.body.clientWidth < 768) {
setWdith('auto'); setWidth('auto');
setMarginLeft(0); setMarginLeft(0);
setMarginTop(0); setMarginTop(0);
} else { } else {
setWdith('100%'); setWidth('100%');
setMarginLeft(0); setMarginLeft(0);
setMarginTop(-72); setMarginTop(-72);
} }