diff --git a/src/components/code-editor.vue b/src/components/code-editor.vue index 84209bf..06f3985 100644 --- a/src/components/code-editor.vue +++ b/src/components/code-editor.vue @@ -36,6 +36,8 @@ export default { mounted() { let lang = this.lang + let firstLoad = true + this.$last = this.code this.$view = new EditorView({ @@ -52,8 +54,9 @@ export default { // 监听代码变化 EditorView.updateListener.of(v => { let value = v.state.doc.toString() - if (!this.$last || value.trim() === this.$last) { + if (firstLoad || value.trim() === this.$last) { this.$last = value.trim() + firstLoad = false return } this.$last = value.trim() diff --git a/src/pages/playground/views/preview.vue b/src/pages/playground/views/preview.vue index 67f107b..6b63a24 100644 --- a/src/pages/playground/views/preview.vue +++ b/src/pages/playground/views/preview.vue @@ -66,7 +66,7 @@ export default { // _time / 2000 * 100 % this.progress = ~~(_time / 10) - if (pending && _time > 1000) { + if (pending && _time >= 1000) { this.progress = 0 let doc = this.$refs.view.contentDocument