修复调试功能

This commit is contained in:
whyour
2021-11-20 00:58:23 +08:00
parent 5e94be21aa
commit 40b0e90c0d
6 changed files with 113 additions and 9 deletions
+1
View File
@@ -235,6 +235,7 @@
box-shadow: none;
transition: background-color 5000s ease-in-out 0s;
-webkit-text-fill-color: @text-color;
caret-color: #e8e6f3 !important;
}
::placeholder {
+36 -3
View File
@@ -28,16 +28,19 @@ const EditModal = ({
content,
handleCancel,
visible,
socketMessage,
}: {
treeData?: any;
currentFile?: string;
content?: string;
visible: boolean;
socketMessage: any;
handleCancel: () => void;
}) => {
const [value, setValue] = useState('');
const [language, setLanguage] = useState<string>('javascript');
const [fileName, setFileName] = useState<string>('');
const [selectedKey, setSelectedKey] = useState<string>('');
const [saveModalVisible, setSaveModalVisible] = useState<boolean>(false);
const [settingModalVisible, setSettingModalVisible] =
useState<boolean>(false);
@@ -50,10 +53,14 @@ const EditModal = ({
};
const onSelect = (value: any, node: any) => {
if (node.value === fileName || !value) {
return;
}
const newMode = LangMap[value.slice(-3)] || '';
setFileName(value);
setLanguage(newMode);
getDetail(node);
setSelectedKey(node.key);
};
const getDetail = (node: any) => {
@@ -62,12 +69,39 @@ const EditModal = ({
});
};
const run = () => {};
const run = () => {
request
.put(`${config.apiPrefix}scripts/run`, {
data: {
filename: fileName,
path: '',
},
})
.then((data) => {});
};
useEffect(() => {
if (!socketMessage) {
return;
}
let { type, message: _message, references } = socketMessage;
if (type !== 'manuallyRunScript') {
return;
}
if (log) {
_message = `\n${_message}`;
}
setLog(`${log}${_message}`);
}, [socketMessage]);
useEffect(() => {
if (currentFile) {
setFileName(currentFile);
setValue(content as string);
setSelectedKey(currentFile);
}
}, [currentFile, content]);
@@ -79,12 +113,11 @@ const EditModal = ({
<span style={{ marginRight: 8 }}>{fileName}</span>
<TreeSelect
style={{ marginRight: 8, width: 120 }}
value={currentFile}
value={selectedKey}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
treeData={treeData}
placeholder="请选择脚本文件"
showSearch
key="value"
onSelect={onSelect}
/>
<Select
+4 -5
View File
@@ -71,7 +71,7 @@ const LangMap: any = {
'.ts': 'typescript',
};
const Script = ({ headerStyle, isPhone, theme }: any) => {
const Script = ({ headerStyle, isPhone, theme, socketMessage }: any) => {
const [title, setTitle] = useState('请选择脚本文件');
const [value, setValue] = useState('请选择脚本文件');
const [select, setSelect] = useState<any>();
@@ -96,11 +96,9 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
.then((data) => {
setData(data.data);
setFilterData(data.data);
})
.finally(() => {
setLoading(false);
initGetScript();
});
})
.finally(() => setLoading(false));
};
const getDetail = (node: any) => {
@@ -529,6 +527,7 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
treeData={data}
currentFile={select}
content={value}
socketMessage={socketMessage}
handleCancel={() => {
setIsLogModalVisible(false);
}}