refactor: 结构调整

This commit is contained in:
fofolee 2021-01-16 10:55:22 +08:00
parent 128e974b22
commit db9330f8fa
4 changed files with 89 additions and 84 deletions

View File

@ -1,3 +1,5 @@
import { programs } from "./programs.js"
!function () {
// 禁用危险函数
let utoolsFull = utools
@ -70,6 +72,7 @@
// 配置页面
if (code == 'options') {
utools.setExpendHeight(600);
$("#quickpanel").hide()
// $("#options").show();
showOptions();
} else if (code == 'code') {
@ -409,87 +412,7 @@
})
}
// 环境
const programs = {
shell: {
bin: 'bash',
argv: '',
ext: 'sh',
color: '#89e051'
},
applescript: {
bin: 'osascript',
argv: '',
ext: 'scpt',
color: '#101F1F'
},
cmd: {
bin: '',
argv: '',
ext: 'bat',
color: '#C1F12E'
},
powershell: {
bin: 'powershell',
argv: '-NoProfile -File',
ext: 'ps1',
color: '#012456'
},
python: {
bin: 'python',
argv: '-u',
ext: 'py',
color: '#3572A5'
},
javascript: {
bin: 'node',
argv: '',
ext: 'js',
color: '#f1e05a'
},
ruby: {
bin: 'ruby',
argv: '',
ext: 'rb',
color: '#701516'
},
php: {
bin: 'php',
argv: '',
ext: 'php',
color: '#4F5D95'
},
c: {
bin: 'gcc',
argv: '-o',
ext: 'c',
color: '#555555'
},
csharp: {
bin: 'C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\csc.exe',
argv: '/Nologo',
ext: 'cs',
color: '#178600'
},
lua: {
bin: 'lua',
argv: '',
ext: 'lua',
color: '#000080'
},
perl: {
bin: 'perl',
argv: '',
ext: 'pl',
color: '#0298c3'
},
custom: {
bin: '',
argv: '',
ext: '',
color: '#438eff'
}
}
// 自动设置编码
let autoCharset = program => {
@ -900,7 +823,7 @@
window.editor.setOption("mode", 'javascript');
}
showHint = () => {
window.showHint = () => {
editor.showHint({ completeSingle: false });
}

81
src/assets/js/programs.js Normal file
View File

@ -0,0 +1,81 @@
// 环境
export const programs = {
shell: {
bin: 'bash',
argv: '',
ext: 'sh',
color: '#89e051'
},
applescript: {
bin: 'osascript',
argv: '',
ext: 'scpt',
color: '#101F1F'
},
cmd: {
bin: '',
argv: '',
ext: 'bat',
color: '#C1F12E'
},
powershell: {
bin: 'powershell',
argv: '-NoProfile -File',
ext: 'ps1',
color: '#012456'
},
python: {
bin: 'python',
argv: '-u',
ext: 'py',
color: '#3572A5'
},
javascript: {
bin: 'node',
argv: '',
ext: 'js',
color: '#f1e05a'
},
ruby: {
bin: 'ruby',
argv: '',
ext: 'rb',
color: '#701516'
},
php: {
bin: 'php',
argv: '',
ext: 'php',
color: '#4F5D95'
},
c: {
bin: 'gcc',
argv: '-o',
ext: 'c',
color: '#555555'
},
csharp: {
bin: 'C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\csc.exe',
argv: '/Nologo',
ext: 'cs',
color: '#178600'
},
lua: {
bin: 'lua',
argv: '',
ext: 'lua',
color: '#000080'
},
perl: {
bin: 'perl',
argv: '',
ext: 'pl',
color: '#0298c3'
},
custom: {
bin: '',
argv: '',
ext: '',
color: '#438eff'
}
}

View File

@ -63,6 +63,7 @@ mainScriptTag.onload = mainScriptTag.onreadystatechange = function () {
modes.concat(addons).forEach(s => {
var scriptTag = document.createElement('script');
scriptTag.setAttribute('src', s);
scriptTag.setAttribute('type', 'module');
document.head.appendChild(scriptTag);
})
}

View File

@ -24,7 +24,7 @@
<div id="options"></div>
<div id="quickpanel"></div>
<pre id="out" class="output"></pre>
<script src="assets/index.js"></script>
<script type="module" src="assets/js/index.js"></script>
</div>
</body>