Commit f40cbae2dd2302f5908fe183e73195a5a6a0ee01

Authored by ly525
1 parent e63b59c1

style(constant): add PAGE_MODE

front-end/h5/src/components/core/editor/edit-panel/props/global-work.vue
@@ -10,15 +10,10 @@ @@ -10,15 +10,10 @@
10 --> 10 -->
11 <template> 11 <template>
12 <a-form :layout="formLayout"> 12 <a-form :layout="formLayout">
13 - <a-form-item  
14 - label="H5类型"  
15 - >  
16 - <a-radio-group default-value="h5_swipper" @change="handleModeChange" size="small">  
17 - <a-radio-button value="h5_swipper">  
18 - 翻页H5  
19 - </a-radio-button>  
20 - <a-radio-button value="h5_long_page">  
21 - 长页面H5 13 + <a-form-item label="H5类型">
  14 + <a-radio-group v-model="pageMode" @change="handleModeChange" size="small">
  15 + <a-radio-button v-for="(value, key) in PAGE_MODE" :key="key" :value="value">
  16 + {{PAGE_MODE_LABEL[key]}}
22 </a-radio-button> 17 </a-radio-button>
23 </a-radio-group> 18 </a-radio-group>
24 </a-form-item> 19 </a-form-item>
@@ -26,11 +21,29 @@ @@ -26,11 +21,29 @@
26 </template> 21 </template>
27 22
28 <script> 23 <script>
29 -import { mapActions } from 'vuex' 24 +import { mapState, mapActions } from 'vuex'
  25 +import { PAGE_MODE, PAGE_MODE_LABEL } from '@/constants/work'
  26 +
30 export default { 27 export default {
31 data () { 28 data () {
32 return { 29 return {
33 - formLayout: 'vertical' 30 + formLayout: 'vertical',
  31 + PAGE_MODE: Object.freeze(PAGE_MODE),
  32 + PAGE_MODE_LABEL: Object.freeze(PAGE_MODE_LABEL)
  33 + }
  34 + },
  35 + computed: {
  36 + ...mapState('editor', ['work']),
  37 + // 翻页模式、长页面模式
  38 + // src/constants/work -> PAGE_MODE
  39 + // https://vuex.vuejs.org/zh/guide/forms.html#%E5%8F%8C%E5%90%91%E7%BB%91%E5%AE%9A%E7%9A%84%E8%AE%A1%E7%AE%97%E5%B1%9E%E6%80%A7
  40 + pageMode: {
  41 + get () {
  42 + return this.work.mode
  43 + },
  44 + set (model) {
  45 + this.updateWork({ mode })
  46 + }
34 } 47 }
35 }, 48 },
36 methods: { 49 methods: {
front-end/h5/src/components/core/models/work.js
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 * @Copyright 2018 - 2019 luban-h5. All Rights Reserved 9 * @Copyright 2018 - 2019 luban-h5. All Rights Reserved
10 */ 10 */
11 import Page from './page.js' 11 import Page from './page.js'
  12 +import { PAGE_MODE } from '@/constants/work'
12 13
13 class Work { 14 class Work {
14 constructor (work = {}) { 15 constructor (work = {}) {
@@ -32,12 +33,7 @@ class Work { @@ -32,12 +33,7 @@ class Work {
32 this.is_publish = false 33 this.is_publish = false
33 this.is_template = false 34 this.is_template = false
34 this.height = work.height || 568 35 this.height = work.height || 568
35 - /**  
36 - * 页面模式,枚举值  
37 - * h5_swipper 翻页H5  
38 - * h5_long_page 长页面H5  
39 - */  
40 - this.mode = work.mode || 'h5_swipper' 36 + this.mode = work.mode || PAGE_MODE.SWIPPER_PAGE
41 } 37 }
42 } 38 }
43 39
front-end/h5/src/constants/work.js 0 → 100644
  1 +/**
  2 + * 页面模式,枚举值
  3 + * h5_swipper 翻页H5
  4 + * h5_long_page 长页面H5
  5 + */
  6 +export const PAGE_MODE = {
  7 + SWIPPER_PAGE: 'h5_swipper',
  8 + LONG_PAGE: 'h5_long_page',
  9 +}
  10 +
  11 +export const PAGE_MODE_LABEL = {
  12 + SWIPPER_PAGE: '翻页H5',
  13 + LONG_PAGE: '长页面',
  14 +}
0 \ No newline at end of file 15 \ No newline at end of file
front-end/h5/src/engine-entry.js
@@ -19,6 +19,7 @@ import message from &#39;ant-design-vue/lib/message&#39; // 加载 JS @@ -19,6 +19,7 @@ import message from &#39;ant-design-vue/lib/message&#39; // 加载 JS
19 import 'ant-design-vue/lib/message/style/css' // 加载 CSS 19 import 'ant-design-vue/lib/message/style/css' // 加载 CSS
20 20
21 import { pluginsList } from './mixins/load-plugins.js' 21 import { pluginsList } from './mixins/load-plugins.js'
  22 +import { PAGE_MODE } from './constants/work.js'
22 import Element from './components/core/models/element' 23 import Element from './components/core/models/element'
23 import NodeWrapper from '@/components/preview/node-wrapper.js' 24 import NodeWrapper from '@/components/preview/node-wrapper.js'
24 25
@@ -32,7 +33,7 @@ const Engine = { @@ -32,7 +33,7 @@ const Engine = {
32 }, 33 },
33 data() { 34 data() {
34 return { 35 return {
35 - isLongPage: window.__work.mode === 'h5_long_page', 36 + isLongPage: window.__work.mode === PAGE_MODE.LONG_PAGE
36 } 37 }
37 }, 38 },
38 methods: { 39 methods: {