Commit 6704e629 authored by chenshouchao's avatar chenshouchao

feat: 路由调试

parent 69f74273
......@@ -56,7 +56,7 @@ const getActorenvList = (params: {
const deleteActorenv = (params: {id: string}) => {
return request({
url:`${Api.API_ACTORENV_DELETE}/${params.id}`,
method: "get",
method: "delete",
});
};
......
......@@ -42,12 +42,18 @@ const useMyRouter = () => {
}
});
}
for (let item of menuInfo.res.data) {
for (let route of item.routes) {
route.element = elements[route.element] || NotFound;
route.path = `/product/${item.id}${route.path}`;
if (Array.isArray(route.children)) {
route.children.forEach((childrenItem: any, index: number) => {
route.children[index].element = elements[childrenItem.element] || NotFound;
route.children[index].path = `${route.path}${childrenItem.path}`;
})
}
}
console.log(item.routes)
permissionStore.setAddRoutes(item.routes);
}
menuStore.initMenu(menuInfo.res.data);
......
......@@ -13,6 +13,7 @@ import MenuLayout from "@/views/MenuLayout";
import * as React from "react";
import NotFound from "@/views/404";
import Demo from "@/views/demo";
import SeeEnv from "@/views/ResourceCenter/UserResources/UserResourcesEnvironment/SeeEnv";
import ProjectSetting from "@/views/Project/ProjectSetting";
import ProjectData from "@/views/Project/ProjectData";
import ProjectWorkbench from "@/views/Project/ProjectWorkbench";
......@@ -54,6 +55,7 @@ export const elements: {
Demo: Demo,
SeeTemplate: Demo,
UserResources: UserResources,
SeeEnv: SeeEnv,
ProjectSetting: ProjectSetting,
ProjectData: ProjectData,
ProjectWorkbench: ProjectWorkbench,
......
......@@ -8,10 +8,9 @@ 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 useWindowSize from '@/hooks/useWindowSize'
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
import useWindowSize from "@/hooks/useWindowSize";
type LogViewProps = {
logs: any[];
......@@ -20,6 +19,7 @@ type LogViewProps = {
const LogView = (props: LogViewProps) => {
const { logs, setShowLogView } = props;
console.log(logs);
const { currentProjectStore } = useStores();
const { width, height } = useWindowSize();
const fileToken = toJS(currentProjectStore.currentProjectInfo.filetoken);
......@@ -27,95 +27,98 @@ const LogView = (props: LogViewProps) => {
// 当前选择的日志
const [logCurrent, setLogCurrent] = useState<number>(0);
// 当前日志的内容文本
const [logText, setLogText] = useState('')
const [logText, setLogText] = useState("");
// 当前日志路径
const [logPath, setLogPath] = useState('')
const [logPath, setLogPath] = useState("");
const [displacement, setDisplacement] = useState(0)
const [displacement, setDisplacement] = useState(0);
const [middleDynamicWidth, setMiddleDynamicWidth] = useState(0)
const [middleDynamicWidth, setMiddleDynamicWidth] = useState(0);
const [leftButtonColor, setLeftButtonColor] = useState('#585D62')
const [rightButtonColor, setRightButtonColor] = useState('#585D62')
const [leftButtonColor, setLeftButtonColor] = useState("#585D62");
const [rightButtonColor, setRightButtonColor] = useState("#585D62");
useEffect(() => {
setLogPath(logs[logCurrent]?.logPath)
setLogPath(logs[logCurrent]?.logPath);
}, [logs]);
// 请求日志文本
useEffect(() => {
if (logPath) {
const path = logPath.slice(12)
const path = logPath.slice(12);
CloudEController.JobFileDownloadText(
path,
fileToken as string,
projectId as string
)?.then((res) => {
setLogText(res.data)
})
setLogText(res.data);
});
} else {
setLogText("")
setLogText("");
}
}, [logPath]);
// 选择日志时改变日志路径
useEffect(() => {
setLogPath(logs[logCurrent]?.logPath)
setLogPath(logs[logCurrent]?.logPath);
}, [logCurrent]);
//获取盒子的总宽度,用于滑动效果判断
useEffect(() => {
const box = document.getElementById('middleDynamic')
setMiddleDynamicWidth(box ? box.offsetWidth : 0)
}, [])
const box = document.getElementById("middleDynamic");
setMiddleDynamicWidth(box ? box.offsetWidth : 0);
}, []);
useEffect(() => {
if (middleDynamicWidth < width - 97) {
setLeftButtonColor('#585D62')
setRightButtonColor('#585D62')
setLeftButtonColor("#585D62");
setRightButtonColor("#585D62");
}
if (displacement === 0) {
setLeftButtonColor('#585D62')
setLeftButtonColor("#585D62");
} else {
setLeftButtonColor('#C0C5CD')
setLeftButtonColor("#C0C5CD");
}
if (middleDynamicWidth > width - 97 && displacement !== -middleDynamicWidth + width - 97) {
setRightButtonColor('#C0C5CD')
if (
middleDynamicWidth > width - 97 &&
displacement !== -middleDynamicWidth + width - 97
) {
setRightButtonColor("#C0C5CD");
} else {
setRightButtonColor('#585D62')
setRightButtonColor("#585D62");
}
}, [width, middleDynamicWidth, displacement])
}, [width, middleDynamicWidth, displacement]);
// 下载当前日志
const handleDownLoad = () => {
const path = logPath.slice(12)
const path = logPath.slice(12);
CloudEController.JobFileDownload(
path,
fileToken as string,
projectId as string
);
}
};
const rightClick = () => {
if (middleDynamicWidth < width - 97) {
return
return;
}
if (-displacement > middleDynamicWidth - width * 1.8 + 97) {
setDisplacement(-middleDynamicWidth + width - 97)
return
setDisplacement(-middleDynamicWidth + width - 97);
return;
}
const newDisplacement = displacement - width * 0.8;
setDisplacement(newDisplacement)
}
setDisplacement(newDisplacement);
};
const leftClick = () => {
if (-displacement < width * 0.8) {
setDisplacement(0)
return
setDisplacement(0);
return;
}
const newDisplacement = displacement + width * 0.8;
setDisplacement(newDisplacement)
}
setDisplacement(newDisplacement);
};
return (
<FullScreenDrawer handleClose={setShowLogView} zIndex={1002}>
......@@ -125,14 +128,22 @@ const LogView = (props: LogViewProps) => {
<div
className={style.leftButton}
onClick={leftClick}
style={{ color: leftButtonColor, cursor: leftButtonColor === '#585D62' ? 'default' : 'pointer' }}
style={{
color: leftButtonColor,
cursor: leftButtonColor === "#585D62" ? "default" : "pointer",
}}
>
<ChevronLeftIcon />
</div>
<div className={style.middleFixed}>
<div className={style.middleDynamic} id='middleDynamic' style={{ left: `${displacement}px` }}>
<div
className={style.middleDynamic}
id="middleDynamic"
style={{ left: `${displacement}px` }}
>
{logs.map((item: any, index: number) => {
return <MyTooltip
return (
<MyTooltip
title={item.logName}
placement="bottom"
arrow={false}
......@@ -140,15 +151,19 @@ const LogView = (props: LogViewProps) => {
>
<div
key={index}
onClick={() => { setLogCurrent(index) }}
onClick={() => {
setLogCurrent(index);
}}
className={classnames({
[style.logTitle]: true,
[style.logTitleSelected]: index === logCurrent,
})}>
})}
>
<InsertDriveFileOutlinedIcon className={style.fileIcon} />
<span className={style.logName}>{item.logName}</span>
</div>
</MyTooltip>
);
})}
</div>
</div>
......@@ -156,20 +171,21 @@ const LogView = (props: LogViewProps) => {
<div
className={style.rightButton}
onClick={rightClick}
style={{ color: rightButtonColor, cursor: rightButtonColor === '#585D62' ? 'default' : 'pointer' }}
style={{
color: rightButtonColor,
cursor: rightButtonColor === "#585D62" ? "default" : "pointer",
}}
>
<ChevronRightIcon />
</div>
</div>
<div className={style.logViewContent}>
{logText}
</div>
<div className={style.logViewContent}>{logText}</div>
<div className={style.logViewBottom}>
<MyButton text='下载当前日志' onClick={handleDownLoad} />
<MyButton text="下载当前日志" onClick={handleDownLoad} />
</div>
</div>
</FullScreenDrawer>
)
}
);
};
export default LogView
\ No newline at end of file
export default LogView;
const EnvironmentDetails = () => {
const SeeEnv = () => {
return <div>EnvironmentDetails</div>;
};
export default EnvironmentDetails;
export default SeeEnv;
// 应用环境
import { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import style from "./index.module.css";
import SearchInput from "@/components/BusinessComponents/SearchInput";
import MySelect from "@/components/mui/MySelect";
......@@ -7,6 +8,7 @@ import MyButton from "@/components/mui/MyButton";
import MyTable from "@/components/mui/MyTableNew";
import useMyRequest from "@/hooks/useMyRequest";
import { getActorenvList } from "@/api/resourceCenter";
import Add from "@mui/icons-material/Add";
import moment from "moment";
import jobFail from "@/assets/project/jobFail.svg";
import jobRun from "@/assets/project/jobRun.svg";
......@@ -15,6 +17,7 @@ import AddEnvironment from "./AddEnvironment";
import DeleteEnvironment from "./DeleteEnvironment";
const UserResourcesEnvironment = () => {
const navigate = useNavigate();
const [addOpen, setAddopen] = useState(false);
const [title, setTitle] = useState("");
const [type, setType] = useState<"BATCH" | "FLOW" | "">("");
......@@ -126,6 +129,16 @@ const UserResourcesEnvironment = () => {
setDeleteOpen(true);
};
const hanleToSeeEnv = (item: any) => {
console.log("hanleToSeeEnv");
console.log(item.id);
// /product/userCenter/userInformation
// navigate("/product/resourceCenter/userResources/seeEnv", {
navigate("/product/userCenter/userInformation", {
state: { id: item.id },
});
};
const renderButtons = (item: any) => {
if (item.status === "FAILED") {
return (
......@@ -141,6 +154,7 @@ const UserResourcesEnvironment = () => {
}}
variant="text"
size="medium"
onClick={() => hanleToSeeEnv(item)}
/>
<MyButton
onClick={() => handleDelete(item)}
......@@ -171,7 +185,7 @@ const UserResourcesEnvironment = () => {
}}
variant="text"
size="medium"
// onClick={() => hanleDownloadFile(item)}
onClick={() => hanleToSeeEnv(item)}
/>
);
}
......@@ -212,13 +226,8 @@ const UserResourcesEnvironment = () => {
<div className={style.topRight}>
<MyButton
text="构建应用环境"
img={
<span
style={{ fontSize: "14px", marginRight: "8px" }}
className="iconfont icon-dianzan"
></span>
}
onClick={() => setAddopen(true)}
startIcon={<Add />}
></MyButton>
</div>
</div>
......
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