Commit 795dd8e5 authored by jiangzijing's avatar jiangzijing

Merge branch 'feat-20220801' into 'release'

Feat 20220801

See merge request !104
parents 4827d395 e1902451
...@@ -19,6 +19,7 @@ const theme = createTheme({ ...@@ -19,6 +19,7 @@ const theme = createTheme({
styleOverrides: { styleOverrides: {
tooltip: { tooltip: {
backgroundColor: "rgba(7, 19, 38, .8)", backgroundColor: "rgba(7, 19, 38, .8)",
padding:'8px 16px',
color: "#fff", color: "#fff",
}, },
arrow: { arrow: {
......
import {useEffect,useState} from 'react'
interface WindowSize{
width:number
height:number
}
function useWindowSize():WindowSize{
const [windowSize,setWindowSize]=useState<WindowSize>({
width:0,
height:0,
})
useEffect(()=>{
const handler=()=>{
setWindowSize({
width:window.innerWidth,
height:window.innerHeight
})
}
handler()
window.addEventListener('resize',handler)
return ()=>{
window.removeEventListener('resize',handler)
}
},[])
return windowSize
}
export default useWindowSize
\ No newline at end of file
...@@ -58,10 +58,11 @@ ...@@ -58,10 +58,11 @@
overflow: hidden; overflow: hidden;
} }
.middleDynamic{ .middleDynamic {
display: flex; display: flex;
position: absolute; position: absolute;
left: 0; left: 0;
transition: left .4s ease-in-out;
} }
.logTitle { .logTitle {
...@@ -78,6 +79,10 @@ ...@@ -78,6 +79,10 @@
border-right: 1px solid #10141A; border-right: 1px solid #10141A;
} }
.logTitle:hover {
background-color: #23272E;
}
.logName { .logName {
max-width: 90px; max-width: 90px;
overflow: hidden; overflow: hidden;
...@@ -128,4 +133,12 @@ ...@@ -128,4 +133,12 @@
justify-content: end; justify-content: end;
height: 76px; height: 76px;
padding-right: 24px; padding-right: 24px;
}
.gradientBox {
position: absolute;
right: 49px;
width: 28px;
height: 32px;
background: linear-gradient(90deg, rgba(29, 33, 38, 0) 0%, #1D2126 100%);
} }
\ No newline at end of file
import { useState, useCallback, useEffect, useMemo } from "react"; import { useState, useCallback, useEffect, useMemo } from "react";
import classnames from "classnames"; import classnames from "classnames";
import style from "./index.module.css"; import style from "./index.module.css";
import CloseIcon from "@mui/icons-material/Close";
import MyButton from "@/components/mui/MyButton"; import MyButton from "@/components/mui/MyButton";
import MyTooltip from "@/components/mui/MyTooltip";
import InsertDriveFileOutlinedIcon from "@mui/icons-material/InsertDriveFileOutlined"; 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";
...@@ -10,6 +10,7 @@ import { toJS } from "mobx"; ...@@ -10,6 +10,7 @@ import { toJS } from "mobx";
import FullScreenDrawer from "@/components/CommonComponents/FullScreenDrawer"; import FullScreenDrawer from "@/components/CommonComponents/FullScreenDrawer";
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft'; import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import ChevronRightIcon from '@mui/icons-material/ChevronRight'; import ChevronRightIcon from '@mui/icons-material/ChevronRight';
import useWindowSize from '@/hooks/useWindowSize'
type LogViewProps = { type LogViewProps = {
...@@ -20,6 +21,7 @@ type LogViewProps = { ...@@ -20,6 +21,7 @@ type LogViewProps = {
const LogView = (props: LogViewProps) => { const LogView = (props: LogViewProps) => {
const { logs, setShowLogView } = props; const { logs, setShowLogView } = props;
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
const { width, height } = useWindowSize();
const fileToken = toJS(currentProjectStore.currentProjectInfo.filetoken); const fileToken = toJS(currentProjectStore.currentProjectInfo.filetoken);
const projectId = toJS(currentProjectStore.currentProjectInfo.id); const projectId = toJS(currentProjectStore.currentProjectInfo.id);
// 当前选择的日志 // 当前选择的日志
...@@ -29,6 +31,13 @@ const LogView = (props: LogViewProps) => { ...@@ -29,6 +31,13 @@ const LogView = (props: LogViewProps) => {
// 当前日志路径 // 当前日志路径
const [logPath, setLogPath] = useState('') const [logPath, setLogPath] = useState('')
const [displacement, setDisplacement] = useState(0)
const [middleDynamicWidth, setMiddleDynamicWidth] = useState(0)
const [leftButtonColor, setLeftButtonColor] = useState('#585D62')
const [rightButtonColor, setRightButtonColor] = useState('#585D62')
useEffect(() => { useEffect(() => {
setLogPath(logs[logCurrent]?.logPath) setLogPath(logs[logCurrent]?.logPath)
}, [logs]); }, [logs]);
...@@ -54,6 +63,29 @@ const LogView = (props: LogViewProps) => { ...@@ -54,6 +63,29 @@ const LogView = (props: LogViewProps) => {
setLogPath(logs[logCurrent]?.logPath) setLogPath(logs[logCurrent]?.logPath)
}, [logCurrent]); }, [logCurrent]);
//获取盒子的总宽度,用于滑动效果判断
useEffect(() => {
const box = document.getElementById('middleDynamic')
setMiddleDynamicWidth(box ? box.offsetWidth : 0)
}, [])
useEffect(() => {
if (middleDynamicWidth < width - 97) {
setLeftButtonColor('#585D62')
setRightButtonColor('#585D62')
}
if (displacement === 0) {
setLeftButtonColor('#585D62')
} else {
setLeftButtonColor('#C0C5CD')
}
if (middleDynamicWidth > width - 97 && displacement !== -middleDynamicWidth + width - 97) {
setRightButtonColor('#C0C5CD')
} else {
setRightButtonColor('#585D62')
}
}, [width, middleDynamicWidth, displacement])
// 下载当前日志 // 下载当前日志
const handleDownLoad = () => { const handleDownLoad = () => {
const path = logPath.slice(12) const path = logPath.slice(12)
...@@ -64,29 +96,70 @@ const LogView = (props: LogViewProps) => { ...@@ -64,29 +96,70 @@ const LogView = (props: LogViewProps) => {
); );
} }
const rightClick = () => {
if (middleDynamicWidth < width - 97) {
return
}
if (-displacement > middleDynamicWidth - width * 1.8 + 97) {
setDisplacement(-middleDynamicWidth + width - 97)
return
}
const newDisplacement = displacement - width * 0.8;
setDisplacement(newDisplacement)
}
const leftClick = () => {
if (-displacement < width * 0.8) {
setDisplacement(0)
return
}
const newDisplacement = displacement + width * 0.8;
setDisplacement(newDisplacement)
}
return ( return (
<FullScreenDrawer handleClose={setShowLogView} zIndex={1002}> <FullScreenDrawer handleClose={setShowLogView} zIndex={1002}>
<div className={style.logViewBox}> <div className={style.logViewBox}>
<div className={style.logViewContentMask}></div> <div className={style.logViewContentMask}></div>
<div className={style.logViewTop}> <div className={style.logViewTop}>
<div className={style.leftButton}><ChevronLeftIcon /></div> <div
className={style.leftButton}
onClick={leftClick}
style={{ color: leftButtonColor, cursor: leftButtonColor === '#585D62' ? 'default' : 'pointer' }}
>
<ChevronLeftIcon />
</div>
<div className={style.middleFixed}> <div className={style.middleFixed}>
<div className={style.middleDynamic}> <div className={style.middleDynamic} id='middleDynamic' style={{ left: `${displacement}px` }}>
{logs.map((item: any, index: number) => { {logs.map((item: any, index: number) => {
return <div return <MyTooltip
key={index} title={item.logName}
onClick={() => { setLogCurrent(index) }} placement="bottom"
className={classnames({ arrow={false}
[style.logTitle]: true, enterDelay={1000}
[style.logTitleSelected]: index === logCurrent, >
})}> <div
<InsertDriveFileOutlinedIcon className={style.fileIcon} /> key={index}
<span className={style.logName}>{item.logName}</span> onClick={() => { setLogCurrent(index) }}
</div> className={classnames({
[style.logTitle]: true,
[style.logTitleSelected]: index === logCurrent,
})}>
<InsertDriveFileOutlinedIcon className={style.fileIcon} />
<span className={style.logName}>{item.logName}</span>
</div>
</MyTooltip>
})} })}
</div> </div>
</div> </div>
<div className={style.rightButton}><ChevronRightIcon /></div> <div className={style.gradientBox}></div>
<div
className={style.rightButton}
onClick={rightClick}
style={{ color: rightButtonColor, cursor: rightButtonColor === '#585D62' ? 'default' : 'pointer' }}
>
<ChevronRightIcon />
</div>
</div> </div>
<div className={style.logViewContent}> <div className={style.logViewContent}>
{logText} {logText}
......
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