调整环境变量参数,支持项目切换
This commit is contained in:
@@ -19,14 +19,29 @@ import { useState } from "react";
|
||||
|
||||
interface ProjectSelectorProps {
|
||||
open: boolean;
|
||||
onSelect: (workspace: string, networkName: string) => void;
|
||||
onSelect: (workspace: string, networkName: string, extent?: number[]) => void;
|
||||
onClose?: () => void;
|
||||
}
|
||||
|
||||
const PROJECTS = [
|
||||
{ label: "TJWater (默认)", workspace: "TJWater", networkName: "tjwater" },
|
||||
{ label: "苏州河", workspace: "szh", networkName: "szh" },
|
||||
{ label: "测试项目", workspace: "test", networkName: "test" },
|
||||
{
|
||||
label: "默认",
|
||||
workspace: "tjwater",
|
||||
networkName: "tjwater",
|
||||
extent: [13508802, 3608164, 13555651, 3633686],
|
||||
},
|
||||
{
|
||||
label: "苏州河",
|
||||
workspace: "szh",
|
||||
networkName: "szh",
|
||||
extent: [13490131, 3630016, 13525879, 3666969],
|
||||
},
|
||||
{
|
||||
label: "测试项目",
|
||||
workspace: "test",
|
||||
networkName: "test",
|
||||
extent: [13508849, 3608036, 13555781, 3633813],
|
||||
},
|
||||
];
|
||||
|
||||
export const ProjectSelector: React.FC<ProjectSelectorProps> = ({
|
||||
@@ -36,10 +51,13 @@ export const ProjectSelector: React.FC<ProjectSelectorProps> = ({
|
||||
}) => {
|
||||
const [workspace, setWorkspace] = useState(PROJECTS[0].workspace);
|
||||
const [networkName, setNetworkName] = useState(PROJECTS[0].networkName);
|
||||
const [extent, setExtent] = useState<number[] | undefined>(
|
||||
PROJECTS[0].extent,
|
||||
);
|
||||
const [customMode, setCustomMode] = useState(false);
|
||||
|
||||
const handleConfirm = () => {
|
||||
onSelect(workspace, networkName);
|
||||
onSelect(workspace, networkName, extent);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -56,8 +74,8 @@ export const ProjectSelector: React.FC<ProjectSelectorProps> = ({
|
||||
background: "rgba(255, 255, 255, 0.95)",
|
||||
backdropFilter: "blur(10px)",
|
||||
position: "relative",
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}}
|
||||
slots={{ transition: Fade }}
|
||||
transitionDuration={500}
|
||||
@@ -76,7 +94,14 @@ export const ProjectSelector: React.FC<ProjectSelectorProps> = ({
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
)}
|
||||
<Box sx={{ display: "flex", flexDirection: "column", alignItems: "center", mb: 2 }}>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
mb: 2,
|
||||
}}
|
||||
>
|
||||
<Box sx={{ transform: "scale(1.5)", mb: 2, mt: 1 }}>
|
||||
<Title />
|
||||
</Box>
|
||||
@@ -85,7 +110,9 @@ export const ProjectSelector: React.FC<ProjectSelectorProps> = ({
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
<DialogContent sx={{ display: "flex", flexDirection: "column", gap: 3, pt: 1 }}>
|
||||
<DialogContent
|
||||
sx={{ display: "flex", flexDirection: "column", gap: 3, pt: 1 }}
|
||||
>
|
||||
{!customMode ? (
|
||||
<FormControl fullWidth variant="outlined">
|
||||
<InputLabel>项目</InputLabel>
|
||||
@@ -101,6 +128,7 @@ export const ProjectSelector: React.FC<ProjectSelectorProps> = ({
|
||||
if (p) {
|
||||
setWorkspace(p.workspace);
|
||||
setNetworkName(p.networkName);
|
||||
setExtent(p.extent);
|
||||
}
|
||||
}
|
||||
}}
|
||||
@@ -155,7 +183,7 @@ export const ProjectSelector: React.FC<ProjectSelectorProps> = ({
|
||||
sx={{
|
||||
textTransform: "none",
|
||||
borderRadius: 2,
|
||||
fontWeight: "bold"
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
进入系统
|
||||
|
||||
Reference in New Issue
Block a user