mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-21 20:44:31 +08:00
修复 editor 判断语言
This commit is contained in:
@@ -8,22 +8,9 @@ import Editor from '@monaco-editor/react';
|
||||
import SaveModal from './saveModal';
|
||||
import SettingModal from './setting';
|
||||
import { useTheme } from '@/utils/hooks';
|
||||
import { logEnded } from '@/utils';
|
||||
import { getEditorMode, logEnded } from '@/utils';
|
||||
|
||||
const { Option } = Select;
|
||||
const LangMap: any = {
|
||||
'.py': 'python',
|
||||
'.js': 'javascript',
|
||||
'.mjs': 'typescript',
|
||||
'.sh': 'shell',
|
||||
'.ts': 'typescript',
|
||||
};
|
||||
const prefixMap: any = {
|
||||
python: '.py',
|
||||
javascript: '.js',
|
||||
shell: '.sh',
|
||||
typescript: '.ts',
|
||||
};
|
||||
|
||||
const EditModal = ({
|
||||
treeData,
|
||||
@@ -66,7 +53,7 @@ const EditModal = ({
|
||||
return;
|
||||
}
|
||||
|
||||
const newMode = LangMap[value.slice(-3)] || '';
|
||||
const newMode = getEditorMode(value);
|
||||
setCNode(node);
|
||||
setLanguage(newMode);
|
||||
getDetail(node);
|
||||
@@ -146,7 +133,7 @@ const EditModal = ({
|
||||
setCNode(currentNode);
|
||||
setValue(content as string);
|
||||
setSelectedKey(currentNode.key);
|
||||
const newMode = LangMap[currentNode.title.slice(-3)] || '';
|
||||
const newMode = getEditorMode(currentNode.title);
|
||||
setLanguage(newMode);
|
||||
}
|
||||
}, [content, currentNode]);
|
||||
|
||||
@@ -37,7 +37,7 @@ import EditScriptNameModal from './editNameModal';
|
||||
import debounce from 'lodash/debounce';
|
||||
import { history, useOutletContext, useLocation } from '@umijs/max';
|
||||
import { parse } from 'query-string';
|
||||
import { depthFirstSearch, findNode } from '@/utils';
|
||||
import { depthFirstSearch, findNode, getEditorMode } from '@/utils';
|
||||
import { SharedContext } from '@/layouts';
|
||||
import useFilterTreeData from '@/hooks/useFilterTreeData';
|
||||
import uniq from 'lodash/uniq';
|
||||
@@ -46,14 +46,6 @@ import RenameModal from './renameModal';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const LangMap: any = {
|
||||
'.py': 'python',
|
||||
'.js': 'javascript',
|
||||
'.mjs': 'typescript',
|
||||
'.sh': 'shell',
|
||||
'.ts': 'typescript',
|
||||
};
|
||||
|
||||
const Script = () => {
|
||||
const { headerStyle, isPhone, theme, socketMessage } =
|
||||
useOutletContext<SharedContext>();
|
||||
@@ -134,7 +126,7 @@ const Script = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const newMode = value ? LangMap[value.slice(-3)] : '';
|
||||
const newMode = getEditorMode(value);
|
||||
setMode(isPhone && newMode === 'typescript' ? 'javascript' : newMode);
|
||||
setValue(intl.get('加载中...'));
|
||||
getDetail(node);
|
||||
|
||||
Reference in New Issue
Block a user