refactor: 优化终端交互.

This commit is contained in:
lijiahang
2024-01-10 19:30:25 +08:00
parent f9069d08d3
commit b5cdd0b362
17 changed files with 490 additions and 83 deletions

View File

@@ -43,6 +43,10 @@
type: Boolean,
default: false
},
autoFocus: {
type: Boolean,
default: false
},
language: {
type: String,
default: 'json',
@@ -76,6 +80,10 @@
};
// 创建编辑器
editor = monaco.editor.create(editorContainer.value, options);
// 自动聚焦
if (props.autoFocus) {
editor.focus();
}
// 监听值的变化
editor.onDidChangeModelContent(() => {
const value = editor.getValue();

View File

@@ -14,6 +14,7 @@
<div :style="{ width: '100%', 'height': height }">
<editor v-model="value"
language="shell"
:auto-focus="true"
:theme="dark ? 'vs-dark' : 'vs'" />
</div>
</a-modal>