Ver código fonte

feat: 换行调整

王家程 3 anos atrás
pai
commit
81db57fcc8

+ 3 - 11
src/components/generator/html.js

@@ -16,23 +16,15 @@ export function dialogWrapper(str) {
 }
 
 export function vueTemplate(str) {
-  return `\n<template>
-      ${str}
-  </template>
-  \n`
+  return `<template>${str}</template>\n`
 }
 
 export function vueScript(str) {
-  return `<script>
-    ${str}
-  </script>
-  \n`
+  return `<script>${str}</script>\n`
 }
 
 export function cssStyle(cssStr, isScoped) {
-  return `<style lang="less" ${isScoped ? 'scoped' : ''}>
-    ${cssStr}
-    </style>`
+  return `<style lang="less" ${isScoped ? 'scoped' : ''}>${cssStr}</style>`
 }
 
 function buildFormTemplate(scheme, child, type) {

+ 2 - 3
src/components/generator/js.js

@@ -267,9 +267,8 @@ function buildOptionMethod(methodName, model, methodList, scheme) {
 function buildWcExport(config, type, props, methods) {
   const str = `
   import tab1 from './tab1/index'
-  \n
+
   ${exportDefault} {
-  ${inheritAttrs[type]}
   name: 'ContentComp',
   components: {},
   data () {
@@ -284,7 +283,7 @@ function buildWcExport(config, type, props, methods) {
           }
         }
       ]
-      ${props}
+      ${props || ''}
     }
   },
   computed: {},

+ 2 - 2
src/utils/index.js

@@ -45,7 +45,7 @@ export const beautifierConf = {
   html: {
     indent_size: '2',
     indent_char: ' ',
-    max_preserve_newlines: '-1',
+    max_preserve_newlines: '10',
     preserve_newlines: true,
     keep_array_indentation: false,
     break_chained_methods: false,
@@ -64,7 +64,7 @@ export const beautifierConf = {
   js: {
     indent_size: '2',
     indent_char: ' ',
-    max_preserve_newlines: '-1',
+    max_preserve_newlines: '10',
     preserve_newlines: true,
     keep_array_indentation: false,
     break_chained_methods: false,

+ 0 - 29
src/views/Page/Edit/test.vue

@@ -1,29 +0,0 @@
-<template>
-  <w-layout>
-    <w-content :tabList='tabList'></w-content>
-  </w-layout>
-</template>
-<script>
-import tab1 from './tab1/index'
-export default {
-  name: 'ContentComp',
-  components: {},
-  data() {
-    const self = this
-    return {
-      tabList: [{
-        name: '123',
-        key: 'tab1',
-        component: tab1,
-        props: {}
-      }]
-    }
-  },
-  computed: {},
-  mounted() {},
-  methods: {}
-}
-
-</script>
-<style lang="less">
-</style>

+ 1 - 2
src/views/components/previewCode.vue

@@ -159,7 +159,6 @@ export default {
       this.htmlCode = makeUpWcHtml(this.formData, type)
       this.jsCode = makeUpWcJs(this.formData, type)
       this.cssCode = makeUpCss(this.formData)
-      console.log('html', this.jsCode)
 
       loadBeautifier(btf => {
         beautifier = btf
@@ -251,7 +250,7 @@ export default {
       const html = vueTemplate(editorObj.html.getValue())
       const script = vueScript(editorObj.js.getValue())
       const css = cssStyle(editorObj.css.getValue())
-      return beautifier.html(html + script + css, beautifierConf.html)
+      return beautifier.html(`${html}\n${script}\n${css}`, beautifierConf.html)
     },
     exportFile() {
       this.$prompt('文件名:', '导出文件', {