Commit 26985a0aba1f0df26856217799010976cc04650b

Authored by ly525
1 parent 27863bc3

feat(#35): fixed toolbar

front-end/h5/package.json
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 "deploy": "rm -rf dist && npm run build && ./deploy.sh" 11 "deploy": "rm -rf dist && npm run build && ./deploy.sh"
12 }, 12 },
13 "dependencies": { 13 "dependencies": {
14 - "ant-design-vue": "^1.3.10", 14 + "ant-design-vue": "^1.3.14",
15 "core-js": "^2.6.5", 15 "core-js": "^2.6.5",
16 "element-ui": "^2.9.1", 16 "element-ui": "^2.9.1",
17 "font-awesome": "4.7.0", 17 "font-awesome": "4.7.0",
front-end/h5/src/components/core/editor/index.js
@@ -29,6 +29,53 @@ const sidebarMenus = [ @@ -29,6 +29,53 @@ const sidebarMenus = [
29 antIcon: 'appstore' 29 antIcon: 'appstore'
30 } 30 }
31 ] 31 ]
  32 +
  33 +const fixedTools = [
  34 + {
  35 + 'tooltip': '撤消', // TODO 支持快捷键
  36 + 'text': '撤消',
  37 + 'icon': 'mail-reply',
  38 + 'action': () => undoRedoHistory.undo()
  39 + },
  40 + {
  41 + 'tooltip': '恢复',
  42 + 'text': '恢复',
  43 + 'icon': 'mail-forward',
  44 + 'action': () => undoRedoHistory.redo()
  45 + },
  46 + {
  47 + 'tooltip': '刷新预览',
  48 + 'text': '刷新预览',
  49 + 'icon': 'eye',
  50 + 'action': function () { this.previewVisible = true }
  51 + },
  52 + {
  53 + 'tooltip': '复制当前页',
  54 + 'text': '复制当前页',
  55 + 'icon': 'copy',
  56 + 'action': function () { this.pageManager({ type: 'copy' }) }
  57 + },
  58 + {
  59 + 'tooltip': '导入PSD',
  60 + 'text': 'Ps',
  61 + 'icon': '',
  62 + 'action': '',
  63 + 'disabled': true
  64 + },
  65 + {
  66 + 'tooltip': '放大画布',
  67 + 'text': '放大画布',
  68 + 'icon': 'plus',
  69 + 'action': function () { this.scaleRate += 0.25 }
  70 + },
  71 + {
  72 + 'tooltip': '缩小画布',
  73 + 'text': '缩小画布',
  74 + 'icon': 'minus',
  75 + 'action': function () { this.scaleRate -= 0.25 }
  76 + }
  77 +]
  78 +
32 export default { 79 export default {
33 name: 'Editor', 80 name: 'Editor',
34 components: {}, 81 components: {},
@@ -36,7 +83,8 @@ export default { @@ -36,7 +83,8 @@ export default {
36 activeMenuKey: 'pluginList', 83 activeMenuKey: 'pluginList',
37 isPreviewMode: false, 84 isPreviewMode: false,
38 activeTabKey: '属性', 85 activeTabKey: '属性',
39 - previewVisible: false 86 + previewVisible: false,
  87 + scaleRate: 1
40 }), 88 }),
41 computed: { 89 computed: {
42 ...mapState('editor', { 90 ...mapState('editor', {
@@ -145,16 +193,17 @@ export default { @@ -145,16 +193,17 @@ export default {
145 <a-layout-content style={{ padding: '24px', margin: 0, minHeight: '280px' }}> 193 <a-layout-content style={{ padding: '24px', margin: 0, minHeight: '280px' }}>
146 <div style="text-align: center;"> 194 <div style="text-align: center;">
147 <a-radio-group 195 <a-radio-group
  196 + size="small"
148 value={this.isPreviewMode} 197 value={this.isPreviewMode}
149 onInput={value => { 198 onInput={value => {
150 this.isPreviewMode = value 199 this.isPreviewMode = value
151 }} 200 }}
152 > 201 >
153 - <a-radio-button label={false} value={false}>Edit</a-radio-button>  
154 - <a-radio-button label={true} value={true}>Preview</a-radio-button> 202 + <a-radio-button label={false} value={false}>编辑模式</a-radio-button>
  203 + <a-radio-button label={true} value={true}>预览模式</a-radio-button>
155 </a-radio-group> 204 </a-radio-group>
156 </div> 205 </div>
157 - <div class='canvas-wrapper'> 206 + <div class='canvas-wrapper' style={{ transform: `scale(${this.scaleRate})` }}>
158 {/* { this.isPreviewMode ? this.renderPreview(h, this.elements) : this.renderCanvas(h, this.elements) } */} 207 {/* { this.isPreviewMode ? this.renderPreview(h, this.elements) : this.renderCanvas(h, this.elements) } */}
159 { this.isPreviewMode 208 { this.isPreviewMode
160 ? <RenderPreviewCanvas elements={this.elements}/> 209 ? <RenderPreviewCanvas elements={this.elements}/>
@@ -165,6 +214,23 @@ export default { @@ -165,6 +214,23 @@ export default {
165 </div> 214 </div>
166 </a-layout-content> 215 </a-layout-content>
167 </a-layout> 216 </a-layout>
  217 + <a-layout-sider width="40" theme='light' style={{ background: '#fff', border: '1px solid #eee' }}>
  218 + {/* <div>
  219 + <a-button shape="circle" icon="search" type="link" />
  220 + </div> */}
  221 + <a-button-group style={{ display: 'flex', flexDirection: 'column' }}>
  222 + {
  223 + fixedTools.map(tool => (
  224 + <a-tooltip effect="dark" placement="left" title={tool.tooltip}>
  225 + <a-button block class="transparent-bg" type="link" size="small" style={{ height: '40px', color: '#000' }} onClick={() => tool.action && tool.action.call(this) } disabled={!!tool.disabled}>
  226 + { tool.icon ? <i class={['shortcut-icon', 'fa', `fa-${tool.icon}`]} aria-hidden='true'/> : tool.text }
  227 + </a-button>
  228 + </a-tooltip>
  229 + ))
  230 + }
  231 + <div style={{ fontSize: '12px', textAlign: 'center' }}>{this.scaleRate * 100}%</div>
  232 + </a-button-group>
  233 + </a-layout-sider>
168 <a-layout-sider width="340" theme='light' style={{ background: '#fff', padding: '0 12px' }}> 234 <a-layout-sider width="340" theme='light' style={{ background: '#fff', padding: '0 12px' }}>
169 <a-tabs 235 <a-tabs
170 style="height: 100%;" 236 style="height: 100%;"
@@ -190,6 +256,7 @@ export default { @@ -190,6 +256,7 @@ export default {
190 <a-tab-pane label="脚本" key='脚本' tab='脚本'><RenderScriptEditor/></a-tab-pane> 256 <a-tab-pane label="脚本" key='脚本' tab='脚本'><RenderScriptEditor/></a-tab-pane>
191 </a-tabs> 257 </a-tabs>
192 </a-layout-sider> 258 </a-layout-sider>
  259 +
193 </a-layout> 260 </a-layout>
194 { 261 {
195 this.previewVisible && <PreviewDialog work={this.work} visible={this.previewVisible} handleClose={() => { this.previewVisible = false }} /> 262 this.previewVisible && <PreviewDialog work={this.work} visible={this.previewVisible} handleClose={() => { this.previewVisible = false }} />
front-end/h5/yarn.lock
@@ -2,18 +2,25 @@ @@ -2,18 +2,25 @@
2 # yarn lockfile v1 2 # yarn lockfile v1
3 3
4 4
5 -"@ant-design/icons-vue@^1.0.1":  
6 - version "1.0.1"  
7 - resolved "https://registry.npm.taobao.org/@ant-design/icons-vue/download/@ant-design/icons-vue-1.0.1.tgz#343579219c04190831c9ca3826aec7361bb8b4d4"  
8 - integrity sha1-NDV5IZwEGQgxyco4Jq7HNhu4tNQ= 5 +"@ant-design/colors@^3.1.0":
  6 + version "3.1.0"
  7 + resolved "https://registry.npm.taobao.org/@ant-design/colors/download/@ant-design/colors-3.1.0.tgz#b7e2cc61a4e86d3d109494034acfb1222dacaa3c"
  8 + integrity sha1-t+LMYaTobT0QlJQDSs+xIi2sqjw=
  9 + dependencies:
  10 + tinycolor2 "^1.4.1"
  11 +
  12 +"@ant-design/icons-vue@^2.0.0":
  13 + version "2.0.0"
  14 + resolved "https://registry.npm.taobao.org/@ant-design/icons-vue/download/@ant-design/icons-vue-2.0.0.tgz#0357f5010a404e9f34a87a4b41b2a08df691dbce"
  15 + integrity sha1-A1f1AQpATp80qHpLQbKgjfaR284=
9 dependencies: 16 dependencies:
10 - ant-design-palettes "^1.1.3" 17 + "@ant-design/colors" "^3.1.0"
11 babel-runtime "^6.26.0" 18 babel-runtime "^6.26.0"
12 19
13 -"@ant-design/icons@^1.1.15":  
14 - version "1.2.1"  
15 - resolved "https://registry.npm.taobao.org/@ant-design/icons/download/@ant-design/icons-1.2.1.tgz#8e19301b1433ec67d6bbd0e892782e2ade561ff9"  
16 - integrity sha1-jhkwGxQz7GfWu9DoknguKt5WH/k= 20 +"@ant-design/icons@^2.1.1":
  21 + version "2.1.1"
  22 + resolved "https://registry.npm.taobao.org/@ant-design/icons/download/@ant-design/icons-2.1.1.tgz#7b9c08dffd4f5d41db667d9dbe5e0107d0bd9a4a"
  23 + integrity sha1-e5wI3/1PXUHbZn2dvl4BB9C9mko=
17 24
18 "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.0.0-beta.35": 25 "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.0.0-beta.35":
19 version "7.0.0" 26 version "7.0.0"
@@ -1404,20 +1411,13 @@ ansi-styles@^3.2.0, ansi-styles@^3.2.1: @@ -1404,20 +1411,13 @@ ansi-styles@^3.2.0, ansi-styles@^3.2.1:
1404 dependencies: 1411 dependencies:
1405 color-convert "^1.9.0" 1412 color-convert "^1.9.0"
1406 1413
1407 -ant-design-palettes@^1.1.3:  
1408 - version "1.1.3"  
1409 - resolved "https://registry.npm.taobao.org/ant-design-palettes/download/ant-design-palettes-1.1.3.tgz#84119b1a4d86363adc52a38d587e65336a0a27dd"  
1410 - integrity sha1-hBGbGk2GNjrcUqONWH5lM2oKJ90=  
1411 - dependencies:  
1412 - tinycolor2 "^1.4.1"  
1413 -  
1414 -ant-design-vue@^1.3.10:  
1415 - version "1.3.10"  
1416 - resolved "https://registry.npm.taobao.org/ant-design-vue/download/ant-design-vue-1.3.10.tgz#82813f90888f77dd0e56c8a71e14efa0f8d8e3da"  
1417 - integrity sha1-goE/kIiPd90OVsinHhTvoPjY49o= 1414 +ant-design-vue@^1.3.14:
  1415 + version "1.3.14"
  1416 + resolved "https://registry.npm.taobao.org/ant-design-vue/download/ant-design-vue-1.3.14.tgz#4bef079ec7a74e79a20c5c4fab7b0ab7fb3568fc"
  1417 + integrity sha1-S+8HnsenTnmiDFxPq3sKt/s1aPw=
1418 dependencies: 1418 dependencies:
1419 - "@ant-design/icons" "^1.1.15"  
1420 - "@ant-design/icons-vue" "^1.0.1" 1419 + "@ant-design/icons" "^2.1.1"
  1420 + "@ant-design/icons-vue" "^2.0.0"
1421 add-dom-event-listener "^1.0.2" 1421 add-dom-event-listener "^1.0.2"
1422 array-tree-filter "^2.1.0" 1422 array-tree-filter "^2.1.0"
1423 async-validator "^1.8.2" 1423 async-validator "^1.8.2"
@@ -1436,6 +1436,7 @@ ant-design-vue@^1.3.10: @@ -1436,6 +1436,7 @@ ant-design-vue@^1.3.10:
1436 lodash "^4.17.5" 1436 lodash "^4.17.5"
1437 moment "^2.21.0" 1437 moment "^2.21.0"
1438 mutationobserver-shim "^0.3.2" 1438 mutationobserver-shim "^0.3.2"
  1439 + node-emoji "^1.10.0"
1439 omit.js "^1.0.0" 1440 omit.js "^1.0.0"
1440 raf "^3.4.0" 1441 raf "^3.4.0"
1441 resize-observer-polyfill "^1.5.1" 1442 resize-observer-polyfill "^1.5.1"
@@ -6804,6 +6805,11 @@ lodash.templatesettings@^4.0.0: @@ -6804,6 +6805,11 @@ lodash.templatesettings@^4.0.0:
6804 dependencies: 6805 dependencies:
6805 lodash._reinterpolate "^3.0.0" 6806 lodash._reinterpolate "^3.0.0"
6806 6807
  6808 +lodash.toarray@^4.4.0:
  6809 + version "4.4.0"
  6810 + resolved "https://registry.npm.taobao.org/lodash.toarray/download/lodash.toarray-4.4.0.tgz#24c4bfcd6b2fba38bfd0594db1179d8e9b656561"
  6811 + integrity sha1-JMS/zWsvuji/0FlNsRedjptlZWE=
  6812 +
6807 lodash.transform@^4.6.0: 6813 lodash.transform@^4.6.0:
6808 version "4.6.0" 6814 version "4.6.0"
6809 resolved "https://registry.npm.taobao.org/lodash.transform/download/lodash.transform-4.6.0.tgz#12306422f63324aed8483d3f38332b5f670547a0" 6815 resolved "https://registry.npm.taobao.org/lodash.transform/download/lodash.transform-4.6.0.tgz#12306422f63324aed8483d3f38332b5f670547a0"
@@ -7321,6 +7327,13 @@ node-cache@^4.1.1: @@ -7321,6 +7327,13 @@ node-cache@^4.1.1:
7321 clone "2.x" 7327 clone "2.x"
7322 lodash "4.x" 7328 lodash "4.x"
7323 7329
  7330 +node-emoji@^1.10.0:
  7331 + version "1.10.0"
  7332 + resolved "https://registry.npm.taobao.org/node-emoji/download/node-emoji-1.10.0.tgz#8886abd25d9c7bb61802a658523d1f8d2a89b2da"
  7333 + integrity sha1-iIar0l2ce7YYAqZYUj0fjSqJsto=
  7334 + dependencies:
  7335 + lodash.toarray "^4.4.0"
  7336 +
7324 node-eta@^0.1.1: 7337 node-eta@^0.1.1:
7325 version "0.1.1" 7338 version "0.1.1"
7326 resolved "https://registry.npm.taobao.org/node-eta/download/node-eta-0.1.1.tgz#4066109b39371c761c72b7ebda9a9ea0a5de121f" 7339 resolved "https://registry.npm.taobao.org/node-eta/download/node-eta-0.1.1.tgz#4066109b39371c761c72b7ebda9a9ea0a5de121f"