Skip to content

Commit

Permalink
1.0.28 日志查看器 优化
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaobaidadada committed Dec 22, 2024
1 parent 0da01dd commit f0eb7f0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "filecat",
"version": "1.0.27",
"version": "1.0.28",
"description": "filecat 文件管理器",
"author": "xiaobaidadada",
"scripts": {
Expand Down
18 changes: 9 additions & 9 deletions src/main/domain/file/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 都是不包括
Expand Down
36 changes: 32 additions & 4 deletions src/web/project/component/file/component/LogViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -161,7 +161,7 @@ export default function LogViewer(props) {

}
if (shellRef.current.clientHeight === shellRef.current.scrollHeight) {
watch(0);
watch(req.max_size);
}

}
Expand All @@ -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<LogViewerPojo>)=>{
const pojo = wsData.context as LogViewerPojo;
if(!pojo) {
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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 <div id={'editor-container'}>
<Header ignore_tags={true} left_children={[<ActionButton key={1} title={"取消"} icon={"close"} onClick={() => {
setShellShow({show: false})
Expand All @@ -358,6 +385,7 @@ export default function LogViewer(props) {
set_go_progress(v);
}}/>
<ActionButton icon={"play_arrow"} title={t("跳转进度")} onClick={go_to_progress}/>
<ActionButton icon={"text_rotate_vertical"} title={t("滑动到文件最底部,实时输出")} onClick={bottom}/>
</Header>
<div style={{height: `100%`}}>
<div ref={shellRef} style={{
Expand Down

0 comments on commit f0eb7f0

Please sign in to comment.