diff --git a/src/components/CodemirrorEditor/EditorHeader/index.vue b/src/components/CodemirrorEditor/EditorHeader/index.vue index 4dfd95d..937792f 100644 --- a/src/components/CodemirrorEditor/EditorHeader/index.vue +++ b/src/components/CodemirrorEditor/EditorHeader/index.vue @@ -26,6 +26,13 @@ > 暗黑模式 + + + 左侧编辑 + @@ -188,6 +195,7 @@ export default { config, citeStatus: false, isMacCodeBlock: true, + isEditOnLeft: true, showResetConfirm: false, selectFont: ``, selectSize: ``, @@ -249,6 +257,7 @@ export default { nightMode: (state) => state.nightMode, currentCiteStatus: (state) => state.citeStatus, currentIsMacCodeBlock: (state) => state.isMacCodeBlock, + currentIsEditOnLeft: (state) => state.isEditOnLeft, }), }, methods: { @@ -333,6 +342,10 @@ export default { this.setIsMacCodeBlock(this.isMacCodeBlock) this.$emit(`refresh`) }, + isEditOnLeftChanged() { + this.isEditOnLeft = !this.isEditOnLeft + this.setIsEditOnLeft(this.isEditOnLeft) + }, // 复制到微信公众号 copy() { this.$emit(`startCopy`) @@ -430,6 +443,7 @@ export default { `setCurrentCodeTheme`, `setWxRendererOptions`, `setIsMacCodeBlock`, + `setIsEditOnLeft`, ]), }, mounted() { @@ -439,6 +453,7 @@ export default { this.selectCodeTheme = this.codeTheme this.citeStatus = this.currentCiteStatus this.isMacCodeBlock = this.currentIsMacCodeBlock + this.isEditOnLeft = this.currentIsEditOnLeft const fileInput = this.$refs.fileInput fileInput.onchange = () => { diff --git a/src/stores/index.js b/src/stores/index.js index 593d079..60fe6b4 100644 --- a/src/stores/index.js +++ b/src/stores/index.js @@ -26,6 +26,7 @@ export const useStore = defineStore(`store`, { nightMode: false, codeTheme: config.codeThemeOption[2].value, isMacCodeBlock: true, + isEditOnLeft: true, }), actions: { setEditorValue(data) { @@ -61,6 +62,10 @@ export const useStore = defineStore(`store`, { this.isMacCodeBlock = data localStorage.setItem(`isMacCodeBlock`, data) }, + setIsEditOnLeft(data) { + this.isEditOnLeft = data + localStorage.setItem(`isEditOnLeft`, data) + }, themeChanged() { this.nightMode = !this.nightMode localStorage.setItem(`nightMode`, this.nightMode) @@ -79,6 +84,7 @@ export const useStore = defineStore(`store`, { this.isMacCodeBlock = !( localStorage.getItem(`isMacCodeBlock`) === `false` ) + this.isEditOnLeft = !(localStorage.getItem(`isEditOnLeft`) === `false`) this.wxRenderer = new WxRenderer({ theme: setColor(this.currentColor), fonts: this.currentFont, diff --git a/src/views/CodemirrorEditor.vue b/src/views/CodemirrorEditor.vue index 9ee1fec..adf7495 100644 --- a/src/views/CodemirrorEditor.vue +++ b/src/views/CodemirrorEditor.vue @@ -22,6 +22,7 @@