|
|
|
@ -6,7 +6,7 @@ |
|
|
|
|
:options="cmOption" |
|
|
|
|
class="code-mirror" |
|
|
|
|
@ready="ready" |
|
|
|
|
ref="myCmGenerate" |
|
|
|
|
ref="codemirror" |
|
|
|
|
></codemirror> |
|
|
|
|
<div v-if="isSubmit" class="code-mask"></div> |
|
|
|
|
<el-button |
|
|
|
@ -49,6 +49,7 @@ import newmain from "../util/newMain"; |
|
|
|
|
import { codemirror } from "vue-codemirror"; |
|
|
|
|
import "codemirror/theme/ambiance.css"; // 这里引入的是主题样式 |
|
|
|
|
import "codemirror/mode/javascript/javascript.js"; |
|
|
|
|
import "codemirror/mode/python/python.js"; |
|
|
|
|
import "codemirror/lib/codemirror.css"; |
|
|
|
|
// require active-line.js |
|
|
|
|
import "codemirror/addon/selection/active-line.js"; |
|
|
|
@ -119,12 +120,10 @@ export default { |
|
|
|
|
foldGutter: true, // 块槽 |
|
|
|
|
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], |
|
|
|
|
highlightSelectionMatches: { showToken: /\w/, annotateScrollbar: true }, // 可以启用该选项来突出显示当前选中的内容的所有实例 |
|
|
|
|
mode: { |
|
|
|
|
// 模式, 可查看 codemirror/mode 中的所有模式 |
|
|
|
|
name: "javascript", |
|
|
|
|
json: true |
|
|
|
|
}, |
|
|
|
|
mode: 'python', |
|
|
|
|
lineWrapping: true, //代码折叠 |
|
|
|
|
autoCloseTags: true,// 自动闭合标签 |
|
|
|
|
autoCloseBrackets: true,// 自动闭合括号 |
|
|
|
|
// hint.js options |
|
|
|
|
hintOptions: { |
|
|
|
|
// 当匹配只有一项的时候是否自动补全 |
|
|
|
@ -134,8 +133,7 @@ export default { |
|
|
|
|
keyMap: "sublime", |
|
|
|
|
matchBrackets: true, |
|
|
|
|
showCursorWhenSelecting: true, |
|
|
|
|
theme: "monokai", // 主题 |
|
|
|
|
extraKeys: { Ctrl: "autocomplete" } // 可以用于为编辑器指定额外的键绑定,以及keyMap定义的键绑定 |
|
|
|
|
theme: "monokai" // 主题 |
|
|
|
|
}, |
|
|
|
|
inputTextReg: /^((?!#).*?(,|\(|\[|\{|\s)+)?input(?!\w)\(['|"]([\s\S]+?)['|"]\)/m, // 匹配input() |
|
|
|
|
requestList: [], // 有input的情况下,保存每个axios的对象,用于中断请求 |
|
|
|
@ -162,7 +160,12 @@ export default { |
|
|
|
|
methods: { |
|
|
|
|
// 页面加载完后重置编辑框大小 |
|
|
|
|
ready() { |
|
|
|
|
this.$refs.myCmGenerate.codemirror.setSize("auto", "calc(100vh - 167px)"); |
|
|
|
|
const code = this.$refs.codemirror.codemirror |
|
|
|
|
code.setSize("auto", "calc(100vh - 167px)"); |
|
|
|
|
code.on('keypress', function() { |
|
|
|
|
// 显示智能提示 |
|
|
|
|
code.showHint() |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
/** |
|
|
|
|
* python代码里如果有input函数的话,是做了单独的处理的,原理是先把所有input函数都替换成exit函数,再在exit函数里加上特定标识,再通过接口传给后端去执行 |
|
|
|
|