Commit 383deb83c18fe80380228e8e7b3da3de219d254b
1 parent
1406139a
refactor: #293
Showing
2 changed files
with
19 additions
and
7 deletions
front-end/h5/src/components/core/editor/left-panel/shortcuts-panel/index.js
| @@ -26,15 +26,15 @@ export default { | @@ -26,15 +26,15 @@ export default { | ||
| 26 | * #!en click the plugin shortcut, create new Element with the plugin's meta data | 26 | * #!en click the plugin shortcut, create new Element with the plugin's meta data |
| 27 | * pluginInfo {Object}: 插件列表中的基础数据, {name}=pluginInfo | 27 | * pluginInfo {Object}: 插件列表中的基础数据, {name}=pluginInfo |
| 28 | * | 28 | * |
| 29 | - * shortcutItem: PluginListItem = { | 29 | + * elementShortcutConfig: PluginListItem = { |
| 30 | name: String, | 30 | name: String, |
| 31 | shortcutProps: {} | 31 | shortcutProps: {} |
| 32 | } | 32 | } |
| 33 | */ | 33 | */ |
| 34 | - clone (shortcutItem) { | 34 | + clone (elementShortcutConfig) { |
| 35 | this.elementManager({ | 35 | this.elementManager({ |
| 36 | type: 'add', | 36 | type: 'add', |
| 37 | - value: shortcutItem | 37 | + value: elementShortcutConfig |
| 38 | }) | 38 | }) |
| 39 | } | 39 | } |
| 40 | /** | 40 | /** |
front-end/h5/src/components/core/store/modules/element.js
| @@ -32,7 +32,18 @@ export const mutations = { | @@ -32,7 +32,18 @@ export const mutations = { | ||
| 32 | ...payload | 32 | ...payload |
| 33 | } | 33 | } |
| 34 | }, | 34 | }, |
| 35 | + /** | ||
| 36 | + * 元素管理:增/删/复制/上移/下移 | ||
| 37 | + * @param {*} state | ||
| 38 | + * @param {*} { | ||
| 39 | + * type: add/copy/delete/move2Top/move2Bottom 增/删/复制/上移/下移 | ||
| 40 | + * value(elementShortcutConfig) 左侧元素列表中元素对应的配置,主要包含: | ||
| 41 | + * - shortcutProps:默认Props,比如一个Chart是饼图、折线图、漏斗图,可以通过此指定 | ||
| 42 | + * - dragStyle:用于拖拽结束,确定最终放置的位置, // {left: Number, top: Number} | ||
| 43 | + * } | ||
| 44 | + */ | ||
| 35 | elementManager (state, { type, value }) { | 45 | elementManager (state, { type, value }) { |
| 46 | + const elementShortcutConfig = value | ||
| 36 | const { editingPage, editingElement } = state | 47 | const { editingPage, editingElement } = state |
| 37 | const elements = editingPage.elements | 48 | const elements = editingPage.elements |
| 38 | const len = elements.length | 49 | const len = elements.length |
| @@ -41,10 +52,11 @@ export const mutations = { | @@ -41,10 +52,11 @@ export const mutations = { | ||
| 41 | case 'add': | 52 | case 'add': |
| 42 | const vm = getVM(value.name) | 53 | const vm = getVM(value.name) |
| 43 | const basicElement = vm.$options | 54 | const basicElement = vm.$options |
| 44 | - basicElement.shortcutProps = value.shortcutProps | ||
| 45 | - // 用于拖拽结束,确定最终放置的位置 | ||
| 46 | - basicElement.dragStyle = value.dragStyle // {left: Number, top: Number} | ||
| 47 | - const element = new Element({ ...basicElement, zindex: len + 1 }) | 55 | + const element = new Element({ |
| 56 | + ...basicElement, | ||
| 57 | + ...elementShortcutConfig, | ||
| 58 | + zindex: len + 1 | ||
| 59 | + }) | ||
| 48 | elements.push(element) | 60 | elements.push(element) |
| 49 | break | 61 | break |
| 50 | case 'copy': | 62 | case 'copy': |