From f0eb7f0ab4ae98e5950635c4457484d77b7c24ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E4=BF=9D=E7=A5=A5?= Date: Sun, 22 Dec 2024 20:32:05 +0800 Subject: [PATCH] =?UTF-8?q?1.0.28=20=E6=97=A5=E5=BF=97=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E5=99=A8=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/main/domain/file/file.service.ts | 18 +++++----- .../component/file/component/LogViewer.tsx | 36 ++++++++++++++++--- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index fa01915..dcf291c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "filecat", - "version": "1.0.27", + "version": "1.0.28", "description": "filecat 文件管理器", "author": "xiaobaidadada", "scripts": { diff --git a/src/main/domain/file/file.service.ts b/src/main/domain/file/file.service.ts index 39316ee..4f6cef5 100644 --- a/src/main/domain/file/file.service.ts +++ b/src/main/domain/file/file.service.ts @@ -142,11 +142,11 @@ class FileService extends FileCompress { const sysPath = path.join(settingService.getFileRootPath(token), filePath ? decodeURIComponent(filePath) : ""); // if (!file) { // // 目录 - if ((req.query.dir === "1") && !fs.existsSync(sysPath)) { - // 目录不存在,创建目录 - fs.mkdirSync(sysPath, {recursive: true}); - return; - } + if ((req.query.dir === "1") && !fs.existsSync(sysPath)) { + // 目录不存在,创建目录 + fs.mkdirSync(sysPath, {recursive: true}); + return; + } // return; // } req['fileDir'] = path.dirname(sysPath); @@ -554,10 +554,10 @@ class FileService extends FileCompress { const buffer = Buffer.alloc(10240); // 返回实际读取的字节数 let bytesRead = fs.readSync(fd, buffer, - 0, // 相对于当前的偏移位置 - buffer.length, // 读取的长度 - pojo.position // 当前位置 - ); + 0, // 相对于当前的偏移位置 + buffer.length, // 读取的长度 + pojo.position // 当前位置 + ); // 遍历 buffer 中的每一个字节 let done = false; let last_h = -1; // 上一个/n 未开始的也算 /n 都是不包括 diff --git a/src/web/project/component/file/component/LogViewer.tsx b/src/web/project/component/file/component/LogViewer.tsx index 604dd8d..5a7d035 100644 --- a/src/web/project/component/file/component/LogViewer.tsx +++ b/src/web/project/component/file/component/LogViewer.tsx @@ -55,7 +55,7 @@ import {deleteList} from "../../../../../common/ListUtil"; const history_max_line = 300; // 最多创建多少个dom对象 - +let open_watch_timer; let open_watch = false; let last_position = 0; @@ -161,7 +161,7 @@ export default function LogViewer(props) { } if (shellRef.current.clientHeight === shellRef.current.scrollHeight) { - watch(0); + watch(req.max_size); } } @@ -170,6 +170,11 @@ export default function LogViewer(props) { if(open_watch)return; open_watch = true; set_progress(100); + if (open_watch_timer) { + clearTimeout(open_watch_timer); + open_watch_timer = null; + return; + } ws.addMsg(CmdType.log_viewer_watch,(wsData: WsData)=>{ const pojo = wsData.context as LogViewerPojo; if(!pojo) { @@ -190,8 +195,12 @@ export default function LogViewer(props) { const cancel_watch = ()=>{ if (!open_watch)return; open_watch = false; - ws.unConnect(); - set_tip(false) + open_watch_timer = setTimeout(()=>{ + ws.unConnect(); + set_tip(false) + open_watch_timer = null; + },5000) + // console.log('取消实时监听') } const initTerminal = async () => { @@ -279,6 +288,7 @@ export default function LogViewer(props) { // set_go_progress(0) set_tip(false); + open_watch_timer = null; open_watch = false; last_position = 0; dom_children_list = []; @@ -346,6 +356,23 @@ export default function LogViewer(props) { // console.log(v,req.position) await send(); } + const bottom = async ()=>{ + if(open_watch)return; + req.line = history_max_line; + req.context = ""; + req.context_list = []; + req.context_position_list = []; + req.context_start_position_list = []; + for (const item of dom_children_list) { + shellRef.current.removeChild(item); + } + dom_children_list = []; + req.back = true ; + req.position = req.max_size; + await send(); + shellRef.current.scrollTop = shellRef.current.scrollHeight; + watch(req.max_size); + } return
{ setShellShow({show: false}) @@ -358,6 +385,7 @@ export default function LogViewer(props) { set_go_progress(v); }}/> +