beta version

This commit is contained in:
JimQing 2020-05-02 12:33:44 +08:00
parent 2cd6eb54c8
commit 7aae308859
2 changed files with 40 additions and 34 deletions

View File

@ -3,6 +3,7 @@
<el-container> <el-container>
<el-header class="top editor__header"> <el-header class="top editor__header">
<editor-header <editor-header
@cssChanged="cssChanged"
@showBox="showBox = !showBox" @showBox="showBox = !showBox"
@showAboutDialog="aboutDialogVisible = true" @showAboutDialog="aboutDialogVisible = true"
@showDialogForm="dialogFormVisible = true" @showDialogForm="dialogFormVisible = true"
@ -54,6 +55,9 @@
import aboutDialog from './codeMirror/aboutDialog'; import aboutDialog from './codeMirror/aboutDialog';
import insertFormDialog from './codeMirror/insertForm'; import insertFormDialog from './codeMirror/insertForm';
import { import {
setFontSize,
css2json,
customCssWithTemplate,
saveEditorContent, saveEditorContent,
isImageIllegal isImageIllegal
} from '../scripts/util' } from '../scripts/util'
@ -83,6 +87,8 @@
output: state=> state.output, output: state=> state.output,
editor: state=> state.editor, editor: state=> state.editor,
cssEditor: state=> state.cssEditor, cssEditor: state=> state.cssEditor,
currentSize: state=> state.currentSize,
currentColor: state=> state.currentColor,
html: state=> state.html html: state=> state.html
}) })
}, },
@ -146,6 +152,16 @@
saveEditorContent(this.cssEditor, '__css_content') saveEditorContent(this.cssEditor, '__css_content')
}) })
}, },
cssChanged() {
let json = css2json(this.cssEditor.getValue(0))
let theme = setFontSize(this.currentSize.replace('px', ''))
theme = customCssWithTemplate(json, this.currentColor, theme)
this.setWxRendererOptions({
theme: theme
});
this.editorRefresh()
},
// //
uploaded(response, file, fileList) { uploaded(response, file, fileList) {
if (response.success) { if (response.success) {
@ -213,7 +229,8 @@
}, 100) }, 100)
}) })
}, },
...mapMutations(['initEditorState', 'initEditorEntity', 'editorRefresh', 'initCssEditorEntity']) ...mapMutations(['initEditorState', 'initEditorEntity', 'setWxRendererOptions',
'editorRefresh', 'initCssEditorEntity'])
}, },
mounted() { mounted() {
this.leftAndRightScroll() this.leftAndRightScroll()

View File

@ -67,9 +67,7 @@
import { import {
setColorWithCustomTemplate, setColorWithCustomTemplate,
setFontSize, setFontSize,
css2json, isImageIllegal
isImageIllegal,
customCssWithTemplate,
} from '../../scripts/util' } from '../../scripts/util'
import { import {
solveWeChatImage, solveWeChatImage,
@ -131,15 +129,6 @@ export default {
this.setCiteStatus(val) this.setCiteStatus(val)
this.editorRefresh() this.editorRefresh()
}, },
cssChanged() {
let json = css2json(this.cssEditor.getValue(0))
let theme = setFontSize(this.currentSize.replace('px', ''))
theme = customCssWithTemplate(json, this.currentColor, theme)
this.setWxRendererOptions({
theme: theme
});
this.editorRefresh()
},
// //
uploaded(response, file, fileList) { uploaded(response, file, fileList) {
if (response.success) { if (response.success) {
@ -229,7 +218,7 @@ export default {
this.fontChanged(this.config.builtinFonts[0].value) this.fontChanged(this.config.builtinFonts[0].value)
this.colorChanged(this.config.colorOption[1].value) this.colorChanged(this.config.colorOption[1].value)
this.sizeChanged(this.config.sizeOption[2].value) this.sizeChanged(this.config.sizeOption[2].value)
this.cssChanged() this.$emit('cssChanged')
}).catch(() => { }).catch(() => {
this.editor.focus() this.editor.focus()
}) })