Commit 45f3bfc48f6ac242af942411cb8319f2be39ce7d

Authored by ly525
Committed by 小小鲁班
1 parent 6bc30118

feat: support resize the props panel; !#zh: 支持拖动调整右侧编辑面板

front-end/h5/src/components/core/editor/canvas/edit.js
... ... @@ -294,8 +294,8 @@ export default {
294 294 top: `${this.work.height}px`,
295 295 width: '100%'
296 296 }}>
297   - <div class="long-page-adjust">
298   - <div class="adjust-line"></div>
  297 + <div class="adjust-line-wrapper adjust-line-wrapper-h">
  298 + <div class="adjust-line adjust-line-h"></div>
299 299 <div class="adjust-button" onMousedown={this.mousedownForAdjustLine}><div class="indicator"></div></div>
300 300 <div class="adjust-tip">
301 301 <span>320 x</span>
... ...
front-end/h5/src/components/core/editor/index.js
... ... @@ -20,6 +20,7 @@ import LogoOfHeader from &#39;@/components/common/header/logo.js&#39;
20 20 import ExternalLinksOfHeader from '@/components/common/header/links.js'
21 21 import LangSelect from '@/components/common/header/LangSelect.vue'
22 22 import Feedback from '@/components/common/feedback/index'
  23 +import AdjustLineV from '@/components/core/support/adjust-line/vertical'
23 24  
24 25 // const sidebarMenus = [
25 26 // {
... ... @@ -113,7 +114,8 @@ export default {
113 114 isPreviewMode: false,
114 115 activeTabKey: '属性',
115 116 previewVisible: false,
116   - scaleRate: 1
  117 + scaleRate: 1,
  118 + propsPanelWidth: 320
117 119 }),
118 120 computed: {
119 121 ...mapState('editor', {
... ... @@ -349,6 +351,9 @@ export default {
349 351 </div>
350 352 </a-layout-content>
351 353 </a-layout>
  354 + <AdjustLineV onLineMove={(offset) => {
  355 + this.propsPanelWidth += offset
  356 + }} />
352 357 <a-layout-sider width="40" theme='light' style={{ background: '#fff', border: '1px solid #eee' }}>
353 358 {/* <div>
354 359 <a-button shape="circle" icon="search" type="link" />
... ... @@ -366,7 +371,7 @@ export default {
366 371 }
367 372 </a-button-group>
368 373 </a-layout-sider>
369   - <a-layout-sider width="320" theme='light' style={{ background: '#fff', padding: '0 0 0 12px' }}>
  374 + <a-layout-sider width={this.propsPanelWidth} data-set-width={this.propsPanelWidth} theme='light' style={{ background: '#fff', padding: '0 0 0 12px' }}>
370 375 <a-tabs
371 376 style="height: 100%;"
372 377 tabBarGutter={10}
... ...
front-end/h5/src/components/core/styles/canvas-wrapper.scss
... ... @@ -35,40 +35,3 @@ $designerWidthHalf: $designerWidth / 2;
35 35 text-align: center;
36 36 }
37 37  
38   -
39   -.long-page-adjust {
40   - .adjust-line {
41   - width: 100%;
42   - height: 1px;
43   - background-color: #1593ff;
44   - }
45   -
46   - .adjust-button {
47   - margin: 0 auto;
48   - width: 30px;
49   - height: 10px;
50   - border-radius: 2px;
51   - padding-top: 4px;
52   - cursor: ns-resize;
53   - background-color: #1593ff;
54   -
55   - .indicator {
56   - margin: 0 auto;
57   - width: 10px;
58   - height: 1px;
59   - background-color: #ccd5db;
60   - }
61   - }
62   -
63   - .adjust-tip {
64   - letter-spacing: 1px;
65   - padding: 0;
66   - height: 24px;
67   - margin: 2px auto 0;
68   - text-align: center;
69   - line-height: 24px;
70   - font-size: 12px;
71   - color: #868484;
72   - vertical-align: middle;
73   - }
74   -}
75 38 \ No newline at end of file
... ...
front-end/h5/src/components/core/styles/index.scss
... ... @@ -91,4 +91,80 @@
91 91 border-left: .2rem solid #dfe2e5;
92 92 // margin: 1rem 0;
93 93 padding: .25rem 0 .25rem 0.5rem;
  94 +}
  95 +
  96 +.ant-layout-sider {
  97 + // 防止拖动延迟
  98 + transition: none !important;
  99 +}
  100 +
  101 +$activeHoverColor: #1593ff;
  102 +.adjust-line-wrapper {
  103 + .adjust-line {
  104 + border: 1px solid #eee;
  105 + }
  106 +
  107 + .adjust-line-h {
  108 + width: 100%;
  109 + }
  110 +
  111 + .adjust-line-v {
  112 + height: 100%;
  113 + }
  114 +
  115 + .adjust-button {
  116 + display: flex;
  117 + align-items: center;
  118 + justify-content: center;
  119 + margin: 0 auto;
  120 + width: 30px;
  121 + height: 10px;
  122 + background-color: #fff;
  123 +
  124 + .indicator {
  125 + margin: 0 auto;
  126 + width: 10px;
  127 + height: 1px;
  128 + background-color: #ccd5db;
  129 + }
  130 + }
  131 +
  132 + &:hover {
  133 + .adjust-button {
  134 + background-color: $activeHoverColor;
  135 + }
  136 +
  137 + .adjust-line {
  138 + border-color: $activeHoverColor;
  139 + }
  140 + }
  141 +}
  142 +
  143 +.adjust-line-wrapper-h {
  144 + cursor: ns-resize;
  145 +
  146 + .adjust-tip {
  147 + letter-spacing: 1px;
  148 + padding: 0;
  149 + height: 24px;
  150 + margin: 2px auto 0;
  151 + text-align: center;
  152 + line-height: 24px;
  153 + font-size: 12px;
  154 + color: #868484;
  155 + vertical-align: middle;
  156 + }
  157 +}
  158 +
  159 +.adjust-line-wrapper-v {
  160 + position: relative;
  161 + height: 100%;
  162 + cursor: ew-resize;
  163 +
  164 + .adjust-button {
  165 + position: absolute;
  166 + right: -10px;
  167 + top: 50%;
  168 + transform: rotate(90deg);
  169 + }
94 170 }
95 171 \ No newline at end of file
... ...
front-end/h5/src/components/core/support/adjust-line/vertical.js 0 → 100644
  1 +export default {
  2 + methods: {
  3 + onMousedown (e) {
  4 + let startX = e.clientX
  5 + let move = moveEvent => {
  6 + moveEvent.preventDefault()
  7 + moveEvent.stopPropagation()
  8 + const offset = startX - moveEvent.clientX
  9 + this.$emit('lineMove', offset)
  10 + startX -= offset
  11 + }
  12 +
  13 + let up = moveEvent => {
  14 + document.removeEventListener('mousemove', move, true)
  15 + document.removeEventListener('mouseup', up, true)
  16 + }
  17 + document.addEventListener('mousemove', move, true)
  18 + document.addEventListener('mouseup', up, true)
  19 + }
  20 + },
  21 + render () {
  22 + return <div class="adjust-line-wrapper adjust-line-wrapper-v" onMousedown={this.onMousedown}>
  23 + <div class="adjust-line adjust-line-v"></div>
  24 + <div class="adjust-button">
  25 + <div class="indicator"></div>
  26 + </div>
  27 + </div>
  28 + }
  29 +}
... ...