diff --git a/component/ComputeCommandNew.js b/component/ComputeCommandNew.js new file mode 100644 index 0000000..f87a3f2 --- /dev/null +++ b/component/ComputeCommandNew.js @@ -0,0 +1,49 @@ +import React, {useState, useRef, useEffect} from 'react'; + +function ComputeCommand() { + const [value, setValue] = useState('/www/wwwroot/demo.zfile.vip'); + const [result, setResult] = useState(''); + + const inputRef = useRef(null); + + useEffect(() => { + handleCalculate(); + }, []); + + const handleCalculate = () => { + // 如果 value 尾缀包含 /zfile-launch 则去除 + let path = value.trim(); + if (value.endsWith('/zfile-launch')) { + path = value.substring(0, value.length - 13); + } + path = path || '/www/wwwroot/demo.zfile.vip'; // 如果输入框为空,则使用默认值 + const command = `${path}/zfile/zfile-pro --spring.config.location=${path}/application.properties`; // 根据路径计算命令 + setResult(command); // 将计算出的命令设置为计算结果 + }; + + + const handleCopy = () => { + inputRef.current.select(); + document.execCommand('copy'); + }; + + return ( +
+
+ setValue(e.target.value)} + className={'z-input'} + placeholder="请输入解压路径"/> + +
+
+