diff --git a/shell/reset.sh b/shell/reset.sh new file mode 100644 index 00000000..af7ffd73 --- /dev/null +++ b/shell/reset.sh @@ -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 diff --git a/shell/share.sh b/shell/share.sh index 6d78e9c5..4f3f7621 100755 --- a/shell/share.sh +++ b/shell/share.sh @@ -56,7 +56,7 @@ import_config() { user_sum=0 for line in $(cat $file_cookie); do let user_sum+=1 - eval Cookie${user_sum}="\"$line\"" + eval Cookie${user_sum}="\"${line}\"" done command_timeout_time=${CommandTimeoutTime:-"1h"} @@ -247,8 +247,10 @@ diff_and_copy() { update_depend() { local dir_current=$(pwd) - cp -f $dir_sample/package.json $dir_scripts/package.json - npm_install_2 $dir_scripts + if [ ! -s $dir_scripts/package.json ] || [[ $(diff $dir_sample/package.json $dir_scripts/package.json) ]]; then + 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 cp -f $dir_sample/requirements.txt $dir_scripts/requirements.txt diff --git a/shell/update.sh b/shell/update.sh index 3b0c890d..ac938540 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -242,11 +242,13 @@ usage() { echo -e "5. $cmd_update rmlog # 删除旧日志" echo -e "6. $cmd_update code # 获取互助码" echo -e "6. $cmd_update bot # 启动tg-bot" + echo -e "7. $cmd_update reset # 重置青龙基础环境" } ## 更新qinglong update_qinglong() { 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" git_pull_scripts $dir_root @@ -256,7 +258,8 @@ update_qinglong() { detect_config_version 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 echo -e "\n更新$dir_root失败,请检查原因...\n" fi @@ -417,6 +420,9 @@ main() { bot) . $dir_shell/bot.sh ;; + reset) + . $dir_shell/reset.sh + ;; *) echo -e "命令输入错误...\n" usage diff --git a/src/pages/config/index.tsx b/src/pages/config/index.tsx index 0b2ad1c9..5118c6bd 100644 --- a/src/pages/config/index.tsx +++ b/src/pages/config/index.tsx @@ -6,7 +6,7 @@ import { Controlled as CodeMirror } from 'react-codemirror2'; import { request } from '@/utils/http'; const Config = () => { - const [width, setWdith] = useState('100%'); + const [width, setWidth] = useState('100%'); const [marginLeft, setMarginLeft] = useState(0); const [marginTop, setMarginTop] = useState(-72); const [value, setValue] = useState(''); @@ -34,11 +34,11 @@ const Config = () => { useEffect(() => { if (document.body.clientWidth < 768) { - setWdith('auto'); + setWidth('auto'); setMarginLeft(0); setMarginTop(0); } else { - setWdith('100%'); + setWidth('100%'); setMarginLeft(0); setMarginTop(-72); } diff --git a/src/pages/cookie/index.tsx b/src/pages/cookie/index.tsx index 0624aae8..11c59458 100644 --- a/src/pages/cookie/index.tsx +++ b/src/pages/cookie/index.tsx @@ -42,6 +42,16 @@ enum StatusColor { 'error', } +enum OperationName { + '启用', + '禁用', +} + +enum OperationPath { + 'enable', + 'disable', +} + const type = 'DragableBodyRow'; const DragableBodyRow = ({ @@ -105,17 +115,6 @@ const Config = () => { return {index + 1} ; }, }, - // { - // 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 {decodeUrl(val)}; - // }, - // }, { title: '昵称', dataIndex: 'nickname', @@ -123,8 +122,10 @@ const Config = () => { align: 'center' as const, width: '15%', render: (text: string, record: any, index: number) => { + const match = record.value.match(/pt_pin=([^; ]+)(?=;?)/); + const val = (match && match[1]) || '未匹配用户名'; return ( - {record.nickname || '-'} + {record.nickname || val} ); }, }, @@ -204,13 +205,14 @@ const Config = () => { ), }, ]; - const [width, setWdith] = useState('100%'); + const [width, setWidth] = useState('100%'); const [marginLeft, setMarginLeft] = useState(0); const [marginTop, setMarginTop] = useState(-72); const [value, setValue] = useState([]); const [loading, setLoading] = useState(true); const [isModalVisible, setIsModalVisible] = useState(false); const [editedCookie, setEditedCookie] = useState(); + const [selectedRowIds, setSelectedRowIds] = useState([]); const getCookies = () => { setLoading(true); @@ -376,13 +378,68 @@ const Config = () => { [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(() => { if (document.body.clientWidth < 768) { - setWdith('auto'); + setWidth('auto'); setMarginLeft(0); setMarginTop(0); } else { - setWdith('100%'); + setWidth('100%'); setMarginLeft(0); setMarginTop(-72); } @@ -411,12 +468,42 @@ const Config = () => { }, }} > + {selectedRowIds.length > 0 && ( +
+ + + + + 已选择 + {selectedRowIds?.length}项 + +
+ )} { }, ]; - const [width, setWdith] = useState('100%'); + const [width, setWidth] = useState('100%'); const [marginLeft, setMarginLeft] = useState(0); const [marginTop, setMarginTop] = useState(-72); const [value, setValue] = useState([]); @@ -524,11 +524,11 @@ const Crontab = () => { useEffect(() => { if (document.body.clientWidth < 768) { - setWdith('auto'); + setWidth('auto'); setMarginLeft(0); setMarginTop(0); } else { - setWdith('100%'); + setWidth('100%'); setMarginLeft(0); setMarginTop(-72); } diff --git a/src/pages/crontab/logModal.tsx b/src/pages/crontab/logModal.tsx index a6fa3117..deb47297 100644 --- a/src/pages/crontab/logModal.tsx +++ b/src/pages/crontab/logModal.tsx @@ -27,6 +27,7 @@ const CronLogModal = ({ const [value, setValue] = useState('启动中...'); const [loading, setLoading] = useState(true); const [excuting, setExcuting] = useState(true); + const [isPhone, setIsPhone] = useState(false); const getCronLog = (isFirst?: boolean) => { if (isFirst) { @@ -86,6 +87,10 @@ const CronLogModal = ({ } }, [cron]); + useEffect(() => { + setIsPhone(document.body.clientWidth < 768); + }, []); + return ( cancel()} > {!loading && value && ( -
+        
           {value}
         
)} diff --git a/src/pages/diff/index.tsx b/src/pages/diff/index.tsx index e5d79a0c..6012a695 100644 --- a/src/pages/diff/index.tsx +++ b/src/pages/diff/index.tsx @@ -7,7 +7,7 @@ import ReactDiffViewer from 'react-diff-viewer'; import './index.less'; const Crontab = () => { - const [width, setWdith] = useState('100%'); + const [width, setWidth] = useState('100%'); const [marginLeft, setMarginLeft] = useState(0); const [marginTop, setMarginTop] = useState(-72); const [value, setValue] = useState(''); @@ -32,11 +32,11 @@ const Crontab = () => { useEffect(() => { if (document.body.clientWidth < 768) { - setWdith('auto'); + setWidth('auto'); setMarginLeft(0); setMarginTop(0); } else { - setWdith('100%'); + setWidth('100%'); setMarginLeft(0); setMarginTop(-72); } diff --git a/src/pages/diy/index.tsx b/src/pages/diy/index.tsx index 92440e79..a110a01e 100644 --- a/src/pages/diy/index.tsx +++ b/src/pages/diy/index.tsx @@ -6,7 +6,7 @@ import { Controlled as CodeMirror } from 'react-codemirror2'; import { request } from '@/utils/http'; const Crontab = () => { - const [width, setWdith] = useState('100%'); + const [width, setWidth] = useState('100%'); const [marginLeft, setMarginLeft] = useState(0); const [marginTop, setMarginTop] = useState(-72); const [value, setValue] = useState(''); @@ -34,11 +34,11 @@ const Crontab = () => { useEffect(() => { if (document.body.clientWidth < 768) { - setWdith('auto'); + setWidth('auto'); setMarginLeft(0); setMarginTop(0); } else { - setWdith('100%'); + setWidth('100%'); setMarginLeft(0); setMarginTop(-72); } diff --git a/src/pages/log/index.tsx b/src/pages/log/index.tsx index a18840d8..5281cc97 100644 --- a/src/pages/log/index.tsx +++ b/src/pages/log/index.tsx @@ -36,7 +36,7 @@ function getFilterData(keyword: string, data: any) { } const Log = () => { - const [width, setWdith] = useState('100%'); + const [width, setWidth] = useState('100%'); const [marginLeft, setMarginLeft] = useState(0); const [marginTop, setMarginTop] = useState(-72); const [title, setTitle] = useState('请选择日志文件'); @@ -103,12 +103,12 @@ const Log = () => { useEffect(() => { if (document.body.clientWidth < 768) { - setWdith('auto'); + setWidth('auto'); setMarginLeft(0); setMarginTop(0); setIsPhone(true); } else { - setWdith('100%'); + setWidth('100%'); setMarginLeft(0); setMarginTop(-72); setIsPhone(false); diff --git a/src/pages/setting/index.tsx b/src/pages/setting/index.tsx index a65314c6..08827385 100644 --- a/src/pages/setting/index.tsx +++ b/src/pages/setting/index.tsx @@ -18,7 +18,7 @@ const optionsWithDisabled = [ ]; const Password = () => { - const [width, setWdith] = useState('100%'); + const [width, setWidth] = useState('100%'); const [marginLeft, setMarginLeft] = useState(0); const [marginTop, setMarginTop] = useState(-72); const [value, setValue] = useState(''); @@ -56,11 +56,11 @@ const Password = () => { useEffect(() => { if (document.body.clientWidth < 768) { - setWdith('auto'); + setWidth('auto'); setMarginLeft(0); setMarginTop(0); } else { - setWdith('100%'); + setWidth('100%'); setMarginLeft(0); setMarginTop(-72); }