From 43da00557d003b21c8064ee09e4186e994a72df0 Mon Sep 17 00:00:00 2001 From: hanhh Date: Sat, 5 Jun 2021 11:27:51 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=BA=8C=E7=BB=B4=E7=A0=81=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=EF=BC=8Cpushplus=E4=BD=BF=E7=94=A8https?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sample/notify.js | 2 +- src/pages/crontab/logModal.tsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sample/notify.js b/sample/notify.js index b16cb60f..1f5adcb1 100644 --- a/sample/notify.js +++ b/sample/notify.js @@ -689,7 +689,7 @@ function pushPlusNotify(text, desp) { topic: `${PUSH_PLUS_USER}`, }; const options = { - url: `http://www.pushplus.plus/send`, + url: `https://www.pushplus.plus/send`, body: JSON.stringify(body), headers: { 'Content-Type': ' application/json', diff --git a/src/pages/crontab/logModal.tsx b/src/pages/crontab/logModal.tsx index 3632a148..f7e4904a 100644 --- a/src/pages/crontab/logModal.tsx +++ b/src/pages/crontab/logModal.tsx @@ -100,7 +100,9 @@ const CronLogModal = ({ onCancel={() => cancel()} > {!loading && value && ( -
{value}
+
+          {value}
+        
)} ); From da2581119d8888073e9bff2d87d6e485ff57817e Mon Sep 17 00:00:00 2001 From: hanhh Date: Sat, 5 Jun 2021 12:33:29 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/crontab/logModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/crontab/logModal.tsx b/src/pages/crontab/logModal.tsx index f7e4904a..a6fa3117 100644 --- a/src/pages/crontab/logModal.tsx +++ b/src/pages/crontab/logModal.tsx @@ -100,7 +100,7 @@ const CronLogModal = ({ onCancel={() => cancel()} > {!loading && value && ( -
+        
           {value}
         
)} From 43e3b80c0cfe7cefced0c3de45d1db3599e7fc2f Mon Sep 17 00:00:00 2001 From: hanhh Date: Sat, 5 Jun 2021 17:08:08 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dql=20repo=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/update.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/update.sh b/shell/update.sh index 5eba4e96..abbc8907 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -173,7 +173,7 @@ update_repo() { fi if [[ $exit_status -eq 0 ]]; then echo -e "\n更新${repo_path}成功...\n" - diff_scripts $repo_path $author $path $blackword $dependence + diff_scripts "$repo_path" "$author" "$path" "$blackword" "$dependence" else echo -e "\n更新${repo_path}失败,请检查原因...\n" fi @@ -314,7 +314,7 @@ diff_scripts() { local blackword="$4" local dependence="$5" - gen_list_repo $repo_path $author $path $blackword $dependence + gen_list_repo "$repo_path" "$author" "$path" "$blackword" "$dependence" local repo="${repo_path##*/}" local list_add="$dir_list_tmp/${repo}_add.list" @@ -351,10 +351,10 @@ gen_list_repo() { cd ${repo_path} files=$(find . -name "*.js" | sed 's/^..//') if [[ $path ]]; then - files=$(find . -name "*.js" | sed 's/^..//' | egrep $path) + files=$(echo "$files" | egrep $path) fi if [[ $blackword ]]; then - files=$(find . -name "*.js" | sed 's/^..//' | egrep -v $blackword | egrep $path) + files=$(echo "$files" | egrep -v $blackword) fi if [[ $dependence ]]; then find . -name "*.js" | sed 's/^..//' | egrep $dependence | xargs -i cp {} $dir_scripts From efebbd4d3393f865ac35695ad5db1a29793e6cdb Mon Sep 17 00:00:00 2001 From: zt8989 <251027705@qq.com> Date: Sun, 6 Jun 2021 15:28:03 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B7=A6=E4=BE=A7?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E7=AD=9B=E9=80=89=20(#241)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 增加左侧日志筛选 Co-authored-by: 周腾 --- src/layouts/index.less | 4 + src/pages/log/index.less | 0 src/pages/log/index.module.less | 38 +++++++++ src/pages/log/index.tsx | 134 ++++++++++++++++++++++++-------- src/styles/variable.less | 1 + 5 files changed, 146 insertions(+), 31 deletions(-) delete mode 100644 src/pages/log/index.less create mode 100644 src/pages/log/index.module.less create mode 100644 src/styles/variable.less diff --git a/src/layouts/index.less b/src/layouts/index.less index 01730bfa..1fd3fb67 100644 --- a/src/layouts/index.less +++ b/src/layouts/index.less @@ -1,3 +1,4 @@ +@import '~@/styles/variable.less'; body { height: 100%; overflow-y: hidden; @@ -55,10 +56,13 @@ body { .ant-pro-grid-content.wide .ant-pro-page-container-children-content { height: calc(100vh - 184px); height: calc(100vh - var(--vh-offset, 0px) - 184px); + margin-left: 0; + margin-right: 0; } .CodeMirror { height: calc(100vh - 216px); height: calc(100vh - var(--vh-offset, 0px) - 216px); + width: calc(100vw - 32px); } } .CodeMirror { diff --git a/src/pages/log/index.less b/src/pages/log/index.less deleted file mode 100644 index e69de29b..00000000 diff --git a/src/pages/log/index.module.less b/src/pages/log/index.module.less new file mode 100644 index 00000000..6eed1ad4 --- /dev/null +++ b/src/pages/log/index.module.less @@ -0,0 +1,38 @@ +@import '~@/styles/variable.less'; + +.left-tree { + &-container { + overflow: hidden; + position: relative; + background-color: #fff; + height: calc(100vh - 128px); + height: calc(100vh - var(--vh-offset, 0px) - 128px); + width: @tree-width; + display: flex; + flex-direction: column; + } + &-scroller { + flex: 1; + overflow: auto; + } + &-search { + margin-bottom: 16px; + } +} + +.log-container { + display: flex; +} + +:global { + .log-wrapper { + .ant-pro-grid-content.wide .ant-pro-page-container-children-content { + padding: 0; + background-color: #f8f8f8; + } + + .CodeMirror { + width: calc(100% - 32px - @tree-width); + } + } +} diff --git a/src/pages/log/index.tsx b/src/pages/log/index.tsx index efa2f9da..a18840d8 100644 --- a/src/pages/log/index.tsx +++ b/src/pages/log/index.tsx @@ -1,9 +1,40 @@ -import React, { PureComponent, Fragment, useState, useEffect } from 'react'; -import { Button, message, Modal, TreeSelect } from 'antd'; +import { useState, useEffect, useCallback, Key } from 'react'; +import { TreeSelect, Tree, Input } from 'antd'; import config from '@/utils/config'; import { PageContainer } from '@ant-design/pro-layout'; import { Controlled as CodeMirror } from 'react-codemirror2'; import { request } from '@/utils/http'; +import styles from './index.module.less'; + +function getFilterData(keyword: string, data: any) { + const expandedKeys: string[] = []; + if (keyword) { + const tree: any = []; + data.forEach((item: any) => { + if (item.title.includes(keyword)) { + tree.push(item); + expandedKeys.push(...item.children.map((x: any) => x.key)); + } else { + const children: any[] = []; + (item.children || []).forEach((subItem: any) => { + if (subItem.title.includes(keyword)) { + children.push(subItem); + } + }); + if (children.length > 0) { + tree.push({ + ...item, + children, + }); + expandedKeys.push(...children.map((x) => x.key)); + } + } + }); + return { tree, expandedKeys }; + } + return { tree: data, expandedKeys }; +} + const Log = () => { const [width, setWdith] = useState('100%'); const [marginLeft, setMarginLeft] = useState(0); @@ -11,12 +42,16 @@ const Log = () => { const [title, setTitle] = useState('请选择日志文件'); const [value, setValue] = useState('请选择日志文件'); const [select, setSelect] = useState(); - const [data, setData] = useState(); + const [data, setData] = useState([]); + const [filterData, setFilterData] = useState([]); const [loading, setLoading] = useState(false); + const [isPhone, setIsPhone] = useState(false); const getConfig = () => { request.get(`${config.apiPrefix}logs`).then((data) => { - setData(formatData(data.dirs) as any); + const result = formatData(data.dirs) as any; + setData(result); + setFilterData(result); }); }; @@ -25,10 +60,13 @@ const Log = () => { x.title = x.name; x.value = x.name; x.disabled = x.isDir; + x.key = x.name; x.children = x.files.map((y: string) => ({ title: y, value: `${x.name}/${y}`, + key: `${x.name}/${y}`, parent: x.name, + isLeaf: true, })); return x; }); @@ -50,15 +88,30 @@ const Log = () => { getLog(node); }; + const onTreeSelect = useCallback((keys: Key[], e: any) => { + onSelect(keys[0], e.node); + }, []); + + const onSearch = useCallback( + (e) => { + const keyword = e.target.value; + const { tree } = getFilterData(keyword, data); + setFilterData(tree); + }, + [data, setFilterData], + ); + useEffect(() => { if (document.body.clientWidth < 768) { setWdith('auto'); setMarginLeft(0); setMarginTop(0); + setIsPhone(true); } else { setWdith('100%'); setMarginLeft(0); setMarginTop(-72); + setIsPhone(false); } getConfig(); }, []); @@ -67,18 +120,20 @@ const Log = () => { , - ]} + extra={ + isPhone && [ + , + ] + } header={{ style: { padding: '4px 16px 4px 15px', @@ -92,21 +147,38 @@ const Log = () => { }, }} > - { - setValue(value); - }} - onChange={(editor, data, value) => {}} - /> +
+ {!isPhone && ( +
+ +
+ +
+
+ )} + { + setValue(value); + }} + onChange={(editor, data, value) => {}} + /> +
); }; diff --git a/src/styles/variable.less b/src/styles/variable.less new file mode 100644 index 00000000..4362a4ae --- /dev/null +++ b/src/styles/variable.less @@ -0,0 +1 @@ +@tree-width: 300px; From 6b1d7b17d408f4ec945c264e60d26d134379e233 Mon Sep 17 00:00:00 2001 From: hanhh Date: Sun, 6 Jun 2021 15:30:14 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/update.sh | 1 + src/layouts/index.tsx | 12 +++++++++++- src/version.ts | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/version.ts diff --git a/shell/update.sh b/shell/update.sh index abbc8907..64301d4c 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -205,6 +205,7 @@ update_raw() { ) cron_name=$(grep "new Env" $raw_file_name | awk -F "\(" '{print $2}' | awk -F "\)" '{print $1}' | sed 's:^.\(.*\).$:\1:' | head -1) [[ -z $cron_name ]] && cron_name="$raw_file_name" + [[ -z $cron_line ]] && cron_line=$(grep "cron:" $raw_file_name | awk -F ":" '{print $2}' | xargs) [[ -z $cron_line ]] && cron_line="0 6 * * *" if [[ -z $cron_id ]]; then result=$(add_cron_api "$cron_line:$cmd_task $filename:$cron_name") diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx index c855ba92..a8853dd1 100644 --- a/src/layouts/index.tsx +++ b/src/layouts/index.tsx @@ -14,6 +14,7 @@ import 'codemirror/mode/shell/shell.js'; import { request } from '@/utils/http'; import './index.less'; import vhCheck from 'vh-check'; +import { version, changeLog } from '../version'; export default function (props: any) { const logout = () => { @@ -63,7 +64,16 @@ export default function (props: any) { return ( + 控制面板 + + + {version} + + + + } menuItemRender={(menuItemProps: any, defaultDom: any) => { if ( menuItemProps.isUrl || diff --git a/src/version.ts b/src/version.ts new file mode 100644 index 00000000..6c551271 --- /dev/null +++ b/src/version.ts @@ -0,0 +1,2 @@ +export const version = 'v2.0.0-111'; +export const changeLog = 'https://t.me/jiaolongwang/101';