@@ -24,7 +24,7 @@ const state = {
2424 currentColor : '' ,
2525 citeStatus : 0 ,
2626 nightMode : false ,
27- rightClickMenuVisible :false
27+ rightClickMenuVisible : false
2828} ;
2929const mutations = {
3030 setEditorValue ( state , data ) {
@@ -52,7 +52,7 @@ const mutations = {
5252 state . currentColor = data ;
5353 localStorage . setItem ( 'color' , data )
5454 } ,
55- setRightClickMenuVisible ( state , data ) {
55+ setRightClickMenuVisible ( state , data ) {
5656 state . rightClickMenuVisible = data ;
5757 } ,
5858 themeChanged ( state ) {
@@ -72,8 +72,7 @@ const mutations = {
7272 } ,
7373 initEditorEntity ( state ) {
7474 state . editor = CodeMirror . fromTextArea (
75- document . getElementById ( 'editor' ) ,
76- {
75+ document . getElementById ( 'editor' ) , {
7776 value : '' ,
7877 mode : 'text/x-markdown' ,
7978 theme : 'xq-light' ,
@@ -90,19 +89,13 @@ const mutations = {
9089 }
9190 }
9291 )
93- // 如果有编辑器内容被保存则读取,否则加载默认内容
94- if ( localStorage . getItem ( '__editor_content' ) ) {
95- state . editor . setValue ( localStorage . getItem ( '__editor_content' ) )
96- } else {
97- const doc = formatDoc ( DEFAULT_CONTENT )
98- state . editor . setValue ( doc )
99- }
10092
93+ // 如果有编辑器内容被保存则读取,否则加载默认内容
94+ state . editor . setValue ( localStorage . getItem ( '__editor_content' ) || formatDoc ( DEFAULT_CONTENT ) )
10195 } ,
10296 initCssEditorEntity ( state ) {
10397 state . cssEditor = CodeMirror . fromTextArea (
104- document . getElementById ( 'cssEditor' ) ,
105- {
98+ document . getElementById ( 'cssEditor' ) , {
10699 value : '' ,
107100 mode : 'css' ,
108101 theme : 'style-mirror' ,
@@ -113,7 +106,6 @@ const mutations = {
113106 extraKeys : {
114107 'Ctrl-F' : function autoFormat ( editor ) {
115108 const totalLines = editor . lineCount ( )
116-
117109 editor . autoFormatRange ( {
118110 line : 0 ,
119111 ch : 0
@@ -126,11 +118,7 @@ const mutations = {
126118 )
127119
128120 // 如果有编辑器内容被保存则读取,否则加载默认内容
129- if ( localStorage . getItem ( '__css_content' ) ) {
130- state . cssEditor . setValue ( localStorage . getItem ( '__css_content' ) )
131- } else {
132- state . cssEditor . setValue ( DEFAULT_CSS_CONTENT )
133- }
121+ state . cssEditor . setValue ( localStorage . getItem ( '__css_content' ) || DEFAULT_CSS_CONTENT )
134122 } ,
135123 editorRefresh ( state ) {
136124 let output = marked ( state . editor . getValue ( 0 ) , {
0 commit comments