1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
| <template>
| <el-container>
| <el-header style="background-color: #F7F7F7; padding: 0; height: 50px;">
| <div style="display: flex; padding-top: 10px; margin-left: 10px">
| <el-button
| round
| type="primary"
| size="small"
| icon="el-icon-check"
| @click="handleConfirm"
| >点击保存</el-button
| >
| <el-button
| round
| icon="el-icon-caret-right"
| type="info"
| size="small"
| @click="handleRunCode"
| >在线运行</el-button
| >
| </div>
| </el-header>
|
| <el-main style="padding: 0; margin-left: 10px; overflow: hidden;">
| <MonacoEditor
| ref="editor"
| :height="codeHeight"
| language="python"
| :code="code.code"
| :options="options"
| @mounted="onMounted"
| @codeChange="onCodeChange"
| :key="timeStamp"
| ></MonacoEditor>
| </el-main>
| <el-drawer
| style="margin-top: 100px;"
| :height="codeHeight"
| :destroy-on-close="true"
| :with-header="false"
| :modal="false"
| :visible.sync="isShowDebug"
| size="40%"
| >
| <RunCodeResult :msg="resp.msg"></RunCodeResult>
| </el-drawer>
| </el-container>
| </template>
|
| <script>
| import MonacoEditor from "vue-monaco-editor";
| import RunCodeResult from "./components/RunCodeResult";
| // Python代码补全功能-BaseMonacoEditor
| import BaseMonacoEditor from "../monaco-editor/BaseMonacoEditor";
| export default {
| name: "DebugTalk",
| components: {
| MonacoEditor,
| RunCodeResult,
| BaseMonacoEditor
| },
| data() {
| return {
| editor: null,
| timeStamp: "",
| isShowDebug: false,
| options: {
| selectOnLineNumbers: false,
| scrollbar: {
| vertical: "hidden",
| verticalHasArrows: false
| }
| },
| code: {
| code: "",
| id: ""
| },
| resp: {
| msg: ""
| }
| };
| },
| methods: {
| onMounted(editor) {
| this.editor = editor;
| },
| onCodeChange(editor) {
| this.code.code = editor.getValue();
| },
| handleRunCode() {
| this.resp.msg = "";
| this.$api.runDebugtalk(this.code).then(resp => {
| this.resp = resp;
| });
| },
| handleConfirm() {
| this.$api.updateDebugtalk(this.code).then(resp => {
| this.getDebugTalk();
| this.$message.success("代码保存成功");
| });
| },
| getDebugTalk() {
| this.$api.getDebugtalk(this.$route.params.id).then(resp => {
| this.code = resp;
| });
| }
| },
| watch: {
| code() {
| this.timeStamp = new Date().getTime();
| },
| resp() {
| this.isShowDebug = true;
| }
| },
| computed: {
| codeHeight() {
| return window.screen.height - 230;
| }
| },
| mounted() {
| this.getDebugTalk();
| }
| };
| </script>
|
| <style>
| .el-drawer__body {
| overflow: hidden;
| }
| </style>
|
|