修复 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
+8
View File
@@ -1 +1,9 @@
export const LOG_END_SYMBOL = '     ';
export const LANG_MAP = {
'.py': 'python',
'.js': 'javascript',
'.mjs': 'javascript',
'.sh': 'shell',
'.ts': 'typescript',
};
+16 -5
View File
@@ -1,5 +1,5 @@
import intl from 'react-intl-universal';
import { LOG_END_SYMBOL } from './const';
import { LANG_MAP, LOG_END_SYMBOL } from './const';
import cron_parser from 'cron-parser';
export default function browserType() {
@@ -154,9 +154,9 @@ export default function browserType() {
shell === 'none'
? {}
: {
shell, // wechat qq uc 360 2345 sougou liebao maxthon
shellVs,
},
shell, // wechat qq uc 360 2345 sougou liebao maxthon
shellVs,
},
);
console.log(
@@ -335,7 +335,18 @@ export function parseCrontab(schedule: string): Date {
if (time) {
return time.next().toDate();
}
} catch (error) {}
} catch (error) { }
return new Date('1970');
}
export function getExtension(filename: string) {
if (!filename) return '';
const arr = filename.split('.');
return `.${arr[arr.length - 1]}`;
}
export function getEditorMode(filename: string) {
const extension = getExtension(filename) as keyof typeof LANG_MAP;
return LANG_MAP[extension];
}