Browse Source

ide bug fix

pull/3374/head
linlu 2 years ago
parent
commit
d44f6eebdc
1 changed files with 17 additions and 11 deletions
  1. +17
    -11
      web_src/js/components/monacoeditor.vue

+ 17
- 11
web_src/js/components/monacoeditor.vue View File

@@ -57,8 +57,9 @@ export default {
scrollBeyondLastLine: false, scrollBeyondLastLine: false,
quickSuggestions: false, //智能提示 quickSuggestions: false, //智能提示
renderLineHighlight: false, //选中行外部边框 renderLineHighlight: false, //选中行外部边框
lineHeight: 22
lineHeight: 22,


renderWhitespace: 'boundary',
}, },


// 编辑器对象 // 编辑器对象
@@ -107,8 +108,9 @@ export default {
methods: { methods: {
init() { init() {


// 初始化container的内容,销毁之前生成的编辑器
this.$refs.container.innerHTML = "";
try {
// 初始化container的内容,销毁之前生成的编辑器
this.$refs.container.innerHTML = "";
// 生成编辑器配置 // 生成编辑器配置
const editorOptions = Object.assign(this.defaultOpts, this.opts); const editorOptions = Object.assign(this.defaultOpts, this.opts);
if (!this.isDiff) { if (!this.isDiff) {
@@ -123,6 +125,13 @@ export default {
}, },
); );


if (this.monacaValue) {
const output = isBase64(this.monacaValue)
? Buffer.from(this.monacaValue, "base64").toString("utf8")
: this.monacaValue;
this.monacoEditor.setValue(output);
}

// 编辑器内容发生改变时触发 // 编辑器内容发生改变时触发
} else { } else {
editorOptions.readOnly = true; editorOptions.readOnly = true;
@@ -144,13 +153,10 @@ export default {
), ),
}); });
} }

if (this.monacaValue) {
const output = isBase64(this.monacaValue)
? Buffer.from(value, "base64").toString("utf8")
: this.monacaValue;
this.monacoEditor.setValue(output);
}
} catch (error) {
console.log("error-init:",error)
}
}, },
upDateDiff(val) { upDateDiff(val) {
this.monacoDiffInstance.updateOptions({ this.monacoDiffInstance.updateOptions({
@@ -189,7 +195,7 @@ export default {
}, },
setDiff(oldContent, newContent) { setDiff(oldContent, newContent) {
this.oldValue = isBase64(oldContent) ? Buffer.from(oldContent, "base64").toString("utf8") : oldContent; this.oldValue = isBase64(oldContent) ? Buffer.from(oldContent, "base64").toString("utf8") : oldContent;
this.newValue = newContent;
this.newValue = isBase64(newContent) ? Buffer.from(newContent, "base64").toString("utf8") : newContent;
this.isDiff = true; this.isDiff = true;
this.init(); this.init();
}, },


Loading…
Cancel
Save