Commit 313c7924 authored by chenshouchao's avatar chenshouchao

Merge branch 'feat-20221012-environment' into 'release'

cn-feat: 优化code组件宽度

See merge request !148
parents 17581507 41b27713
import style from "./index.module.css";
const CardTable = () => {
return <div>CardTable</div>;
};
export default CardTable;
...@@ -4,14 +4,19 @@ type ICodeType = { ...@@ -4,14 +4,19 @@ type ICodeType = {
value: string; value: string;
onChange: any; onChange: any;
height?: string; height?: string;
width?: string;
maxWidth?: string;
theme?: "light" | "dark"; theme?: "light" | "dark";
}; };
const Code = (props: ICodeType) => { const Code = (props: ICodeType) => {
const { value, onChange, height, theme = "dark" } = props; const { value, onChange, height, theme = "dark", width, maxWidth } = props;
return ( return (
<CodeMirror <CodeMirror
height={height || "100%"} height={height || "100%"}
// maxWidth="200px"
width={width || "100%"}
maxWidth={maxWidth || "100%"}
value={value} value={value}
onChange={(e) => onChange(e)} onChange={(e) => onChange(e)}
theme={theme} theme={theme}
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
} }
.form { .form {
width: 368px; width: 368px;
min-width: 368px;
box-sizing: border-box; box-sizing: border-box;
padding: 16px 24px; padding: 16px 24px;
border: 1px solid #ebedf0; border: 1px solid #ebedf0;
......
...@@ -48,6 +48,7 @@ const AddEnvironment = (props: IAddEnvironmentProps) => { ...@@ -48,6 +48,7 @@ const AddEnvironment = (props: IAddEnvironmentProps) => {
const [envList, setEnvList] = useState<Array<any>>([]); // 基础环境列表 和taskType环境类型有关 const [envList, setEnvList] = useState<Array<any>>([]); // 基础环境列表 和taskType环境类型有关
const [progress, setProgress] = useState("0%"); // 上传压缩包进度 const [progress, setProgress] = useState("0%"); // 上传压缩包进度
const [code, setCode] = useState(""); // 脚本内容 const [code, setCode] = useState(""); // 脚本内容
const [codeWidth, setCodeWidth] = useState(0);
const [upload, setUpload] = useState<any>(() => {}); // 上传压缩包实例 用于暂停(取消上传)upload.abort(true); const [upload, setUpload] = useState<any>(() => {}); // 上传压缩包实例 用于暂停(取消上传)upload.abort(true);
const [nameHelper, setNameHelper] = useState({ const [nameHelper, setNameHelper] = useState({
error: false, error: false,
...@@ -297,6 +298,16 @@ const AddEnvironment = (props: IAddEnvironmentProps) => { ...@@ -297,6 +298,16 @@ const AddEnvironment = (props: IAddEnvironmentProps) => {
setFilePaths([]); setFilePaths([]);
}; };
const getCodeWidth = () => {
const addEnvironmentCodeElement =
document.getElementById("addEnvironmentCode");
setCodeWidth(addEnvironmentCodeElement?.offsetWidth || 0);
};
useEffect(() => {
getCodeWidth();
}, []);
return ( return (
<div className={style.addEnvironment}> <div className={style.addEnvironment}>
<div className={style.left}> <div className={style.left}>
...@@ -453,11 +464,12 @@ const AddEnvironment = (props: IAddEnvironmentProps) => { ...@@ -453,11 +464,12 @@ const AddEnvironment = (props: IAddEnvironmentProps) => {
<div className={style.codeTitle}> <div className={style.codeTitle}>
{taskType === "BATCH" ? "Shell脚本" : "Python脚本"} {taskType === "BATCH" ? "Shell脚本" : "Python脚本"}
</div> </div>
<div className={style.code}> <div className={style.code} id="addEnvironmentCode">
<Code <Code
value={code} value={code}
onChange={(e: string) => setCode(e)} onChange={(e: string) => setCode(e)}
height="535px" height="535px"
width={`${codeWidth}px`}
/> />
</div> </div>
</div> </div>
......
const CardTableDemo = () => {
return <div>CardTableDemo</div>;
};
export default CardTableDemo;
import MyTableDemo from "./MyTableDemo"; import MyTableDemo from "./MyTableDemo";
import QueueSelectDemo from "./QueueSelectDemo"; import QueueSelectDemo from "./QueueSelectDemo";
import IconfontDemo from "./IconfontDemo"; import IconfontDemo from "./IconfontDemo";
import CardTableDemo from "./CardTableDemo";
import RadioGroupOfButtonStyle from "@/components/CommonComponents/RadioGroupOfButtonStyle"; import RadioGroupOfButtonStyle from "@/components/CommonComponents/RadioGroupOfButtonStyle";
import { useState } from "react"; import { useState } from "react";
import styles from "./index.module.css"; import styles from "./index.module.css";
const Demo = () => { const Demo = () => {
const radioOptionsArr = [ const radioOptionsArr = [
{
value: "cardTable",
label: "cardTable",
},
{ {
value: "iconfont", value: "iconfont",
label: "iconfont", label: "iconfont",
...@@ -27,7 +32,7 @@ const Demo = () => { ...@@ -27,7 +32,7 @@ const Demo = () => {
const handleRadio = (e: string) => { const handleRadio = (e: string) => {
setSelectDemo(e); setSelectDemo(e);
}; };
const [selectDemo, setSelectDemo] = useState("iconfont"); const [selectDemo, setSelectDemo] = useState("cardTable");
return ( return (
<div className={styles.demoBox}> <div className={styles.demoBox}>
...@@ -37,6 +42,7 @@ const Demo = () => { ...@@ -37,6 +42,7 @@ const Demo = () => {
handleRadio={handleRadio} handleRadio={handleRadio}
/> />
<div className={styles.demoContentBox}> <div className={styles.demoContentBox}>
{selectDemo === "cardTable" && <CardTableDemo></CardTableDemo>}
{selectDemo === "iconfont" && <IconfontDemo></IconfontDemo>} {selectDemo === "iconfont" && <IconfontDemo></IconfontDemo>}
{selectDemo === "队列选择器" && <QueueSelectDemo></QueueSelectDemo>} {selectDemo === "队列选择器" && <QueueSelectDemo></QueueSelectDemo>}
{selectDemo === "表格" && <MyTableDemo></MyTableDemo>} {selectDemo === "表格" && <MyTableDemo></MyTableDemo>}
......
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