From 3bddeebab4cf1f2ee4f9a6f43bbe76748733eb48 Mon Sep 17 00:00:00 2001 From: jmal Date: Mon, 25 May 2020 15:30:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=9C=AC=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 + package.json | 2 +- .../VueCodemirror/VueCodeMirror.vue | 55 ++++++------------- src/components/preview/SimTextPreview.vue | 16 +++--- 4 files changed, 29 insertions(+), 47 deletions(-) diff --git a/.gitignore b/.gitignore index 9ad28d2..8b78316 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +push.sh +update.sh +dist.tar .DS_Store node_modules/ dist/ diff --git a/package.json b/package.json index 1f9c69e..0cd6acb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jmal-cloud-view", - "version": "1.0.0", + "version": "1.0.1", "description": "jmal cloud", "author": "Jmal ", "license": "MIT", diff --git a/src/components/VueCodemirror/VueCodeMirror.vue b/src/components/VueCodemirror/VueCodeMirror.vue index 2fda52d..651fdb9 100644 --- a/src/components/VueCodemirror/VueCodeMirror.vue +++ b/src/components/VueCodemirror/VueCodeMirror.vue @@ -80,12 +80,15 @@ require('codemirror/addon/hint/xml-hint.js') // Crtl-F 搜索 - import 'codemirror/addon/dialog/dialog'; - import 'codemirror/addon/scroll/annotatescrollbar'; - import 'codemirror/addon/search/matchesonscrollbar'; - import 'codemirror/addon/search/jump-to-line'; - import 'codemirror/addon/search/search'; - import 'codemirror/addon/search/searchcursor'; + + import 'codemirror/addon/scroll/annotatescrollbar.js' + import 'codemirror/addon/search/matchesonscrollbar.js' + import 'codemirror/addon/search/match-highlighter.js' + import 'codemirror/addon/search/jump-to-line.js' + import 'codemirror/addon/dialog/dialog.js' + import 'codemirror/addon/dialog/dialog.css' + import 'codemirror/addon/search/searchcursor.js' + import 'codemirror/addon/search/search.js' let CodeMirror = require('codemirror/lib/codemirror.js') require('codemirror/lib/codemirror.css') @@ -102,7 +105,11 @@ return { mode: 'text/javascript', lineNumbers: true, - lineWrapping: true + lineWrapping: true, + // foldGutter: true, // 启用行槽中的代码折叠 + // // 在行槽中添加行号显示器、折叠器、语法检测器 + // gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter", "CodeMirror-lint-markers"], + // lint: true, } } }, @@ -113,26 +120,6 @@ nowValue: '' } }, - // ready: function () { - // let that = this - // this.editor = CodeMirror.fromTextArea(this.$el.querySelector('textarea'), this.options) - // this.editor.setValue(this.value) - // this.editor.on('change', function(cm) { - // console.log('change') - // if (that.skipNextChangeEvent) { - // that.skipNextChangeEvent = false - // return - // } - // that.nowValue = cm.getValue() - // if (!!that.$emit) { - // that.$emit('change', cm.getValue()) - // } - // }) - // this.editor.on("cursorActivity", () => { - // console.log('cursorActivity') - // this.editor.showHint(); - // }); - // }, beforeMount(){ this.onKeyDown = this.onKeyDown.bind(this); document.addEventListener('keydown', this.onKeyDown); @@ -153,13 +140,10 @@ } }) - this.editor.on("cursorActivity", () => { - console.log('cursorActivity') - // this.editor.showHint(); - }); + console.log(this.editor) this.$nextTick(()=>{ - this.editor.clearHistory(); + this.editor.clearHistory() }) }, watch: { @@ -173,7 +157,7 @@ this.editor.scrollTo(0, 0) // this.editor.scrollTo(scrollInfo.left, scrollInfo.top) } - this.editor.clearHistory(); + this.editor.clearHistory() }, 'options': function (newOptions, oldVal) { if (typeof newOptions === 'object') { @@ -201,11 +185,6 @@ event.stopPropagation(); event.preventDefault(); } - const isF = key === 'f' || code === 'KeyF' || keyCode === 70; - if (isF && this.editor) { - this.editor.execCommand('find'); - event.preventDefault(); - } }, }, beforeDestroy: function () { diff --git a/src/components/preview/SimTextPreview.vue b/src/components/preview/SimTextPreview.vue index 8ccd879..a7fd966 100644 --- a/src/components/preview/SimTextPreview.vue +++ b/src/components/preview/SimTextPreview.vue @@ -58,25 +58,25 @@ computed: { options: function () { return { - mode: this.codeMode,//代码高亮 + mode: this.codeMode,// 代码高亮 smartIndent: true, // 智能缩进 indentUnit: 4, // 智能缩进单位为4个空格长度 indentWithTabs: true, // 使用制表符进行智能缩进 styleActiveLine: true, // 显示选中行的样式 lineNumbers: true, //显示行号 - lineWrapping: this.lineWrapping,//代码折叠 - foldGutter: true, // 启用行槽中的代码折叠 - // 在行槽中添加行号显示器、折叠器、语法检测器 - gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter", "CodeMirror-lint-markers"], + lineWrapping: this.lineWrapping, //代码换行显示 + // foldGutter: true, // 启用行槽中的代码折叠 + // // 在行槽中添加行号显示器、折叠器、语法检测器 + // gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter", "CodeMirror-lint-markers"], + lint: true, readOnly: this.readOnly, theme: 'darcula', // theme: 'default', fullScreen: false, // 全屏 - matchBrackets: true, //括号匹配 + matchBrackets: true, // 括号匹配 hintOptions: { completeSingle: false }, - lint: true, extraKeys: {'ctrl-space': 'autocomplete'}, //智能提示 } } @@ -91,7 +91,7 @@ codeMode: 'javascript', previewMode: true, lineWrapping: false, - readOnly: this.$store.state.user.token ? false : true, + readOnly: !this.$store.state.user.token, isShowUpdateBtn: false, updating: false, loading: {},