Skip to content

Commit 722031c

Browse files
committed
feat: support long page mode(alpha);
#!zh: 支持长页面(alpha)
1 parent d21296a commit 722031c

File tree

12 files changed

+266
-19
lines changed

12 files changed

+266
-19
lines changed

back-end/h5-api/api/work/documentation/1.0.0/work.json

+24
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,18 @@
10021002
},
10031003
"is_template": {
10041004
"type": "boolean"
1005+
},
1006+
"mode": {
1007+
"type": "string",
1008+
"enum": [
1009+
"h5_swipper",
1010+
"h5_long_page",
1011+
"h5_form"
1012+
]
1013+
},
1014+
"height": {
1015+
"type": "integer",
1016+
"default": 568
10051017
}
10061018
}
10071019
},
@@ -1024,6 +1036,18 @@
10241036
},
10251037
"is_template": {
10261038
"type": "boolean"
1039+
},
1040+
"mode": {
1041+
"type": "string",
1042+
"enum": [
1043+
"h5_swipper",
1044+
"h5_long_page",
1045+
"h5_form"
1046+
]
1047+
},
1048+
"height": {
1049+
"type": "integer",
1050+
"default": 568
10271051
}
10281052
}
10291053
}

back-end/h5-api/api/work/models/Work.settings.json

+13-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@
3131
},
3232
"is_template": {
3333
"type": "boolean"
34+
},
35+
"mode": {
36+
"type": "enumeration",
37+
"enum": [
38+
"h5_swipper",
39+
"h5_long_page",
40+
"h5_form"
41+
]
42+
},
43+
"height": {
44+
"type": "integer",
45+
"default": 568
3446
}
3547
}
36-
}
48+
}

back-end/h5-api/api/workform/documentation/1.0.0/workform.json

+6
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,12 @@
550550
},
551551
"is_template": {
552552
"type": "boolean"
553+
},
554+
"mode": {
555+
"type": "string"
556+
},
557+
"height": {
558+
"type": "integer"
553559
}
554560
}
555561
}

back-end/h5-api/extensions/documentation/documentation/1.0.0/full_documentation.json

+44-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
{
22
"openapi": "3.0.0",
33
"info": {
4-
"version": "0.0.1",
5-
"title": "#!zh: 鲁班H5-后端API 文档",
6-
"description": "#!zh: 鲁班H5-后端API 文档(#!en: API docs for luban-h5)",
4+
"version": "1.0.0",
5+
"title": "DOCUMENTATION",
6+
"description": "",
7+
"termsOfService": "YOUR_TERMS_OF_SERVICE_URL",
78
"contact": {
8-
"name": "Feedback",
9-
"url": "https://github.com/ly525/luban-h5/issues/new?title=[api-docs-feedback]"
9+
"name": "TEAM",
10+
"email": "[email protected]",
11+
"url": "mywebsite.io"
1012
},
11-
"x-generation-date": "01/26/2020 5:36:49 PM"
13+
"license": {
14+
"name": "Apache 2.0",
15+
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
16+
},
17+
"x-generation-date": "05/10/2020 10:31:59 PM"
1218
},
1319
"x-strapi-config": {
1420
"path": "/documentation",
@@ -29,8 +35,8 @@
2935
}
3036
],
3137
"externalDocs": {
32-
"description": "#!zh 鲁班H5完整文档(#!en Full Docs for Luban-H5)",
33-
"url": "https://ly525.github.io/luban-h5/"
38+
"description": "Find out more",
39+
"url": "https://strapi.io/documentation/3.0.0-beta.x/"
3440
},
3541
"security": [
3642
{
@@ -3706,6 +3712,18 @@
37063712
},
37073713
"is_template": {
37083714
"type": "boolean"
3715+
},
3716+
"mode": {
3717+
"type": "string",
3718+
"enum": [
3719+
"h5_swipper",
3720+
"h5_long_page",
3721+
"h5_form"
3722+
]
3723+
},
3724+
"height": {
3725+
"type": "integer",
3726+
"default": 568
37093727
}
37103728
}
37113729
},
@@ -3728,6 +3746,18 @@
37283746
},
37293747
"is_template": {
37303748
"type": "boolean"
3749+
},
3750+
"mode": {
3751+
"type": "string",
3752+
"enum": [
3753+
"h5_swipper",
3754+
"h5_long_page",
3755+
"h5_form"
3756+
]
3757+
},
3758+
"height": {
3759+
"type": "integer",
3760+
"default": 568
37313761
}
37323762
}
37333763
},
@@ -3767,6 +3797,12 @@
37673797
},
37683798
"is_template": {
37693799
"type": "boolean"
3800+
},
3801+
"mode": {
3802+
"type": "string"
3803+
},
3804+
"height": {
3805+
"type": "integer"
37703806
}
37713807
}
37723808
}

front-end/h5/src/components/core/editor/canvas/edit.js

+60-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ export default {
1010
contextmenuPos: []
1111
}),
1212
computed: {
13-
...mapState('editor', ['editingElement'])
13+
...mapState('editor', ['editingElement', 'work'])
1414
},
1515
methods: {
1616
...mapActions('editor', [
1717
'setEditingElement',
1818
'setElementPosition',
1919
'setElementShape',
2020
'recordElementRect',
21-
'elementManager'
21+
'elementManager',
22+
'updateWork'
2223
]),
2324
// TODO #!zh: 优化代码
2425
// generate vertical line
@@ -141,6 +142,43 @@ export default {
141142
this.setEditingElement()
142143
}
143144
},
145+
/**
146+
* 更新作品高度
147+
* @param {Number} height
148+
*/
149+
updateWorkHeight (height) {
150+
this.updateWork({ height })
151+
},
152+
/**
153+
* TODO 封装 adjust editor scale 组件
154+
* scale: height/width
155+
* @param {MouseEvent} e
156+
*/
157+
mousedownForAdjustLine (e) {
158+
let startY = e.clientY
159+
let startHeight = this.work.height
160+
161+
const canvasOuterWrapper = document.querySelector('#canvas-outer-wrapper')
162+
163+
let move = moveEvent => {
164+
// !#zh 移动的时候,不需要向后代元素传递事件,只需要单纯的移动就OK
165+
moveEvent.stopPropagation()
166+
moveEvent.preventDefault()
167+
168+
let currY = moveEvent.clientY
169+
let currentHeight = currY - startY + startHeight
170+
this.updateWorkHeight(currentHeight)
171+
// 交互效果:滚动条同步滚动至底部
172+
canvasOuterWrapper && (canvasOuterWrapper.scrollTop = canvasOuterWrapper.scrollHeight)
173+
}
174+
175+
let up = moveEvent => {
176+
document.removeEventListener('mousemove', move, true)
177+
document.removeEventListener('mouseup', up, true)
178+
}
179+
document.addEventListener('mousemove', move, true)
180+
document.addEventListener('mouseup', up, true)
181+
},
144182
/**
145183
* #!zh: renderCanvas 渲染中间画布
146184
* elements
@@ -251,6 +289,26 @@ export default {
251289
onHideMenu={this.hideContextMenu}
252290
/> : null
253291
}
292+
<div style={{
293+
position: 'absolute',
294+
top: `${this.work.height}px`,
295+
width: '100%'
296+
}}>
297+
<div class="long-page-adjust">
298+
<div class="adjust-line"></div>
299+
<div class="adjust-button" onMousedown={this.mousedownForAdjustLine}><div class="indicator"></div></div>
300+
<div class="adjust-tip">
301+
<span>320 x</span>
302+
<a-input-number
303+
size="small"
304+
style="margin: 0 4px; width:60px;"
305+
value={this.work.height}
306+
onChange={height => { this.updateWork({ height }) }}
307+
/>
308+
<span>px</span>
309+
</div>
310+
</div>
311+
</div>
254312
</div>
255313
)
256314
}

front-end/h5/src/components/core/editor/edit-panel/props.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Vue from 'vue'
22
import { mapState, mapActions } from 'vuex'
33
import { getVM, getComponentsForPropsEditor } from '../../../../utils/element'
4+
import RenderGlobalWorkPropsEditor from './props/global-work.vue'
45

56
export default {
67
data: () => ({
@@ -141,11 +142,14 @@ export default {
141142
}
142143
</a-form>
143144
)
145+
},
146+
renderWorkGlobalPropsPanel (h) {
147+
return <RenderGlobalWorkPropsEditor />
144148
}
145149
},
146150
render (h) {
147151
const ele = this.editingElement
148-
if (!ele) return (<span>{this.$t('editor.editPanel.common.empty')}</span>)
152+
if (!ele) return this.renderWorkGlobalPropsPanel(h)
149153
this.mixinEnhancedPropsEditor(ele)
150154
return this.renderPropsEditorPanel(h, ele)
151155
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!--
2+
* @Author: ly525
3+
* @Date: 2020-05-10 23:10:52
4+
* @LastEditors: ly525
5+
* @LastEditTime: 2020-05-10 23:20:22
6+
* @FilePath: /luban-h5/front-end/h5/src/components/core/editor/edit-panel/props/global-work.vue
7+
* @Github: https://github.com/ly525/luban-h5
8+
* @Description: Do not edit
9+
* @Copyright 2018 - 2019 luban-h5. All Rights Reserved
10+
-->
11+
<template>
12+
<a-form :layout="formLayout">
13+
<a-form-item
14+
label="H5类型"
15+
>
16+
<a-radio-group default-value="h5_swipper" @change="handleChangeMode" 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
22+
</a-radio-button>
23+
</a-radio-group>
24+
</a-form-item>
25+
</a-form>
26+
</template>
27+
28+
<script>
29+
import { mapActions } from 'vuex'
30+
export default {
31+
data () {
32+
return {
33+
formLayout: 'vertical'
34+
}
35+
},
36+
methods: {
37+
...mapActions('editor', [
38+
'updateWork'
39+
]),
40+
handleModeChange (e) {
41+
this.updateWork({ mode: e.target.value })
42+
}
43+
}
44+
}
45+
</script>

front-end/h5/src/components/core/editor/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ export default {
311311
<a-layout-sider width="240" theme='light' style={{ background: '#fff', padding: '12px' }}>
312312
{ this._renderMenuContent() }
313313
</a-layout-sider>
314-
<a-layout>
314+
<a-layout id="canvas-outer-wrapper">
315315
<div class="mode-toggle-wrapper">
316316
<a-radio-group
317317
size="small"
@@ -330,7 +330,9 @@ export default {
330330
</a-radio-group>
331331
</div>
332332
<a-layout-content style={{ transform: `scale(${this.scaleRate})`, 'transform-origin': 'center top' }}>
333-
<div class='canvas-wrapper'>
333+
<div class='canvas-wrapper' style={{
334+
height: `${this.work.height}px`
335+
}}>
334336
{/* { this.isPreviewMode ? this.renderPreview(h, this.elements) : this.renderCanvas(h, this.elements) } */}
335337
{ this.isPreviewMode
336338
? <RenderPreviewCanvas elements={this.elements}/>

front-end/h5/src/components/core/models/work.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: ly525
33
* @Date: 2019-11-24 18:51:58
44
* @LastEditors: ly525
5-
* @LastEditTime: 2019-12-15 16:24:33
5+
* @LastEditTime: 2020-05-10 23:23:40
66
* @FilePath: /luban-h5/front-end/h5/src/components/core/models/work.js
77
* @Github: https://github.com/ly525/luban-h5
88
* @Description: work model
@@ -12,6 +12,7 @@ import Page from './page.js'
1212

1313
class Work {
1414
constructor (work = {}) {
15+
this.id = work.id
1516
this.title = work.title || '标题'
1617
this.description = work.description || '描述'
1718
this.pages = work.pages || [new Page()]
@@ -30,6 +31,13 @@ class Work {
3031

3132
this.is_publish = false
3233
this.is_template = false
34+
this.height = work.height || 568
35+
/**
36+
* 页面模式,枚举值
37+
* h5_swipper 翻页H5
38+
* h5_long_page 长页面H5
39+
*/
40+
this.mode = work.mode || 'h5_swipper'
3341
}
3442
}
3543

0 commit comments

Comments
 (0)