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 classnames from "classnames";
import style from "./index.module.css"; import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import CloseIcon from "@mui/icons-material/Close"; import ChevronRightIcon from '@mui/icons-material/ChevronRight';
import MyButton from "@/components/mui/MyButton"; import MyButton from "@/components/mui/MyButton";
import InsertDriveFileOutlinedIcon from "@mui/icons-material/InsertDriveFileOutlined";
import CloudEController from "@/api/fileserver/CloudEController"; import CloudEController from "@/api/fileserver/CloudEController";
import { useStores } from "@/store"; import { useStores } from "@/store";
import { toJS } from "mobx";
import FullScreenDrawer from "@/components/CommonComponents/FullScreenDrawer"; 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 = { type LogViewProps = {
logs: any[]; logs: any[];
...@@ -29,10 +37,6 @@ const LogView = (props: LogViewProps) => { ...@@ -29,10 +37,6 @@ const LogView = (props: LogViewProps) => {
// 当前日志路径 // 当前日志路径
const [logPath, setLogPath] = useState('') const [logPath, setLogPath] = useState('')
useEffect(() => {
setLogPath(logs[logCurrent]?.logPath)
}, [logs]);
// 请求日志文本 // 请求日志文本
useEffect(() => { useEffect(() => {
if (logPath) { if (logPath) {
...@@ -47,12 +51,12 @@ const LogView = (props: LogViewProps) => { ...@@ -47,12 +51,12 @@ const LogView = (props: LogViewProps) => {
} else { } else {
setLogText("") setLogText("")
} }
}, [logPath]); }, [fileToken, logPath, projectId]);
// 选择日志时改变日志路径 // 选择日志时改变日志路径
useEffect(() => { useEffect(() => {
setLogPath(logs[logCurrent]?.logPath) setLogPath(logs[logCurrent]?.logPath)
}, [logCurrent]); }, [logCurrent, logs]);
// 下载当前日志 // 下载当前日志
const handleDownLoad = () => { const handleDownLoad = () => {
...@@ -64,6 +68,11 @@ const LogView = (props: LogViewProps) => { ...@@ -64,6 +68,11 @@ const LogView = (props: LogViewProps) => {
); );
} }
const handleLogTab = (index: number)=>{
setLogText("");
setLogCurrent(index)
}
return ( return (
<FullScreenDrawer handleClose={setShowLogView} zIndex={1002}> <FullScreenDrawer handleClose={setShowLogView} zIndex={1002}>
<div className={style.logViewBox}> <div className={style.logViewBox}>
...@@ -75,7 +84,7 @@ const LogView = (props: LogViewProps) => { ...@@ -75,7 +84,7 @@ const LogView = (props: LogViewProps) => {
{logs.map((item: any, index: number) => { {logs.map((item: any, index: number) => {
return <div return <div
key={index} key={index}
onClick={() => { setLogCurrent(index) }} onClick={() => { handleLogTab(index) }}
className={classnames({ className={classnames({
[style.logTitle]: true, [style.logTitle]: true,
[style.logTitleSelected]: index === logCurrent, [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