Commit f168fa03 authored by wuyongsheng's avatar wuyongsheng

feat: 查看日志优化

parent 9f898958
import { useState, useCallback, useEffect, useMemo } from "react";
/*
* @Author: 吴永生 15770852798@163.com
* @Date: 2022-09-09 14:41:47
* @LastEditors: 吴永生 15770852798@163.com
* @LastEditTime: 2022-09-09 16:48:28
* @FilePath: /bkunyun/src/views/Project/ProjectJobDetail/LogView/index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { useState, useEffect } from "react";
import InsertDriveFileOutlinedIcon from "@mui/icons-material/InsertDriveFileOutlined";
import { toJS } from "mobx";
import classnames from "classnames";
import style from "./index.module.css";
import CloseIcon from "@mui/icons-material/Close";
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
import MyButton from "@/components/mui/MyButton";
import InsertDriveFileOutlinedIcon from "@mui/icons-material/InsertDriveFileOutlined";
import CloudEController from "@/api/fileserver/CloudEController";
import { useStores } from "@/store";
import { toJS } from "mobx";
import FullScreenDrawer from "@/components/CommonComponents/FullScreenDrawer";
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
import style from "./index.module.css";
type LogViewProps = {
logs: any[];
......@@ -29,10 +37,6 @@ const LogView = (props: LogViewProps) => {
// 当前日志路径
const [logPath, setLogPath] = useState('')
useEffect(() => {
setLogPath(logs[logCurrent]?.logPath)
}, [logs]);
// 请求日志文本
useEffect(() => {
if (logPath) {
......@@ -47,12 +51,12 @@ const LogView = (props: LogViewProps) => {
} else {
setLogText("")
}
}, [logPath]);
}, [fileToken, logPath, projectId]);
// 选择日志时改变日志路径
useEffect(() => {
setLogPath(logs[logCurrent]?.logPath)
}, [logCurrent]);
}, [logCurrent, logs]);
// 下载当前日志
const handleDownLoad = () => {
......@@ -64,6 +68,11 @@ const LogView = (props: LogViewProps) => {
);
}
const handleLogTab = (index: number)=>{
setLogText("");
setLogCurrent(index)
}
return (
<FullScreenDrawer handleClose={setShowLogView} zIndex={1002}>
<div className={style.logViewBox}>
......@@ -75,7 +84,7 @@ const LogView = (props: LogViewProps) => {
{logs.map((item: any, index: number) => {
return <div
key={index}
onClick={() => { setLogCurrent(index) }}
onClick={() => { handleLogTab(index) }}
className={classnames({
[style.logTitle]: true,
[style.logTitleSelected]: index === logCurrent,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment