修复 editor 判断语言

This commit is contained in:
whyour
2023-08-05 13:18:28 +08:00
parent b1a242c8ee
commit a2e33d1ed4
6 changed files with 35 additions and 44 deletions
+2 -9
View File
@@ -30,7 +30,7 @@ import config from '@/utils/config';
import CronLogModal from './logModal';
import Editor from '@monaco-editor/react';
import IconFont from '@/components/iconfont';
import { getCommandScript } from '@/utils';
import { getCommandScript, getEditorMode } from '@/utils';
import VirtualList from 'rc-virtual-list';
import useScrollHeight from '@/hooks/useScrollHeight';
@@ -46,13 +46,6 @@ const tabList = [
tab: intl.get('脚本'),
},
];
const LangMap: any = {
'.py': 'python',
'.js': 'javascript',
'.mjs': 'typescript',
'.sh': 'shell',
'.ts': 'typescript',
};
interface LogItem {
directory: string;
@@ -110,7 +103,7 @@ const CronDetailModal = ({
),
script: scriptInfo.filename && (
<Editor
language={LangMap[scriptInfo.filename.slice(-3)] || ''}
language={getEditorMode(scriptInfo.filename)}
theme={theme}
value={value}
options={{