修复脚本管理编辑交互,修复ico无法加载

This commit is contained in:
hanhh
2021-08-19 23:46:26 +08:00
parent f86892cef0
commit d9a9d2ee4f
20 changed files with 50 additions and 35 deletions
+1
View File
@@ -14,6 +14,7 @@
flex: 1;
overflow: auto;
border-right: 1px dashed #f0f0f0;
padding-top: 6px;
}
}
+14 -5
View File
@@ -40,7 +40,7 @@ const LangMap: any = {
'.ts': 'typescript',
};
const Script = () => {
const Script = ({ headerStyle, isPhone, theme }: any) => {
const [title, setTitle] = useState('请选择脚本文件');
const [value, setValue] = useState('请选择脚本文件');
const [select, setSelect] = useState<string>();
@@ -51,8 +51,6 @@ const Script = () => {
const [height, setHeight] = useState<number>();
const treeDom = useRef<any>();
const [isLogModalVisible, setIsLogModalVisible] = useState(false);
const { headerStyle, isPhone } = useCtx();
const { theme } = useTheme();
const [searchValue, setSearchValue] = useState('');
const [isEditing, setIsEditing] = useState(false);
const editorRef = useRef<any>(null);
@@ -64,6 +62,7 @@ const Script = () => {
.then((data) => {
setData(data.data);
setFilterData(data.data);
onSelect(data.data[0].value, data.data[0]);
})
.finally(() => setLoading(false));
};
@@ -75,6 +74,7 @@ const Script = () => {
};
const onSelect = (value: any, node: any) => {
setValue('加载中...');
const newMode = LangMap[value.slice(-3)] || '';
setMode(isPhone && newMode === 'typescript' ? 'javascript' : newMode);
setSelect(value);
@@ -100,6 +100,12 @@ const Script = () => {
setIsEditing(true);
};
const cancelEdit = () => {
setIsEditing(false);
setValue('加载中...');
getDetail({ value: select });
};
const saveFile = () => {
Modal.confirm({
title: `确认保存`,
@@ -126,6 +132,7 @@ const Script = () => {
.then((_data: any) => {
if (_data.code === 200) {
message.success(`保存成功`);
setIsEditing(false);
} else {
message.error(_data);
}
@@ -177,8 +184,6 @@ const Script = () => {
useEffect(() => {
const word = searchValue || '';
const { tree } = getFilterData(word.toLocaleLowerCase(), data);
console.log(word);
console.log(tree);
setFilterData(tree);
setSelect('');
setTitle('请选择脚本文件');
@@ -217,6 +222,9 @@ const Script = () => {
<Button type="primary" onClick={saveFile}>
</Button>,
<Button type="primary" onClick={cancelEdit}>
退
</Button>,
]
: [
<Button type="primary" onClick={editFile}>
@@ -255,6 +263,7 @@ const Script = () => {
height={height}
showLine={{ showLeafIcon: true }}
onSelect={onTreeSelect}
defaultSelectedKeys={[data[0] && data[0].key]}
></Tree>
</div>
</div>
-1
View File
@@ -18,7 +18,6 @@ const SaveModal = ({
const [loading, setLoading] = useState(false);
const handleOk = async (values: any) => {
console.log(file.filename);
setLoading(true);
const payload = { ...file, ...values };
request
-1
View File
@@ -16,7 +16,6 @@ const SettingModal = ({
const [loading, setLoading] = useState(false);
const handleOk = async (values: any) => {
console.log(file.filename);
setLoading(true);
const payload = { ...file, ...values };
request