Commit 0bf1d9eeb4ac5bef3671e4708e4e8e0c9193493b
1 parent
05c56f89
fix: #107
Showing
5 changed files
with
18 additions
and
9 deletions
front-end/h5/public/index.html
front-end/h5/src/components/core/editor/shortcuts-panel/index.js
| 1 | import ShortcutButton from './shortcut-button' | 1 | import ShortcutButton from './shortcut-button' |
| 2 | +import LoadNpmPlugins from './load-npm-plugins.vue' | ||
| 2 | import langMixin from '@/mixins/i18n' | 3 | import langMixin from '@/mixins/i18n' |
| 3 | export default { | 4 | export default { |
| 4 | mixins: [langMixin], | 5 | mixins: [langMixin], |
| @@ -12,6 +13,9 @@ export default { | @@ -12,6 +13,9 @@ export default { | ||
| 12 | type: Function | 13 | type: Function |
| 13 | } | 14 | } |
| 14 | }, | 15 | }, |
| 16 | + data: () => ({ | ||
| 17 | + npmPackages: [] | ||
| 18 | + }), | ||
| 15 | methods: { | 19 | methods: { |
| 16 | onClickShortcut (item) { | 20 | onClickShortcut (item) { |
| 17 | if (this.handleClickShortcut) { | 21 | if (this.handleClickShortcut) { |
| @@ -89,7 +93,7 @@ export default { | @@ -89,7 +93,7 @@ export default { | ||
| 89 | return ( | 93 | return ( |
| 90 | <a-row gutter={20}> | 94 | <a-row gutter={20}> |
| 91 | { | 95 | { |
| 92 | - this.pluginsList.filter(plugin => plugin.visible).map(plugin => ( | 96 | + [].concat(this.pluginsList, this.npmPackages).filter(plugin => plugin.visible).map(plugin => ( |
| 93 | <a-col span={12} style={{ marginTop: '10px' }}> | 97 | <a-col span={12} style={{ marginTop: '10px' }}> |
| 94 | <ShortcutButton | 98 | <ShortcutButton |
| 95 | clickFn={this.onClickShortcut.bind(this, plugin)} | 99 | clickFn={this.onClickShortcut.bind(this, plugin)} |
| @@ -101,6 +105,9 @@ export default { | @@ -101,6 +105,9 @@ export default { | ||
| 101 | </a-col> | 105 | </a-col> |
| 102 | )) | 106 | )) |
| 103 | } | 107 | } |
| 108 | + <LoadNpmPlugins onLoadComplete={npmPackages => { | ||
| 109 | + this.npmPackages = npmPackages | ||
| 110 | + }} /> | ||
| 104 | </a-row> | 111 | </a-row> |
| 105 | ) | 112 | ) |
| 106 | } | 113 | } |
front-end/h5/src/components/core/models/element.js
| @@ -31,7 +31,7 @@ class Element { | @@ -31,7 +31,7 @@ class Element { | ||
| 31 | * 3. 为何需要 clone,因为会有 element.clone() 以及 page.clone(), | 31 | * 3. 为何需要 clone,因为会有 element.clone() 以及 page.clone(), |
| 32 | * element.pluginProps 和 elementcommonStyle 是引用类型,如果不做 deep_clone 可能会出现意外错误 | 32 | * element.pluginProps 和 elementcommonStyle 是引用类型,如果不做 deep_clone 可能会出现意外错误 |
| 33 | */ | 33 | */ |
| 34 | - this.pluginProps = (typeof ele.pluginProps === 'object' && cloneObj(ele.pluginProps)) || this.getDefaultPluginProps(ele.editorConfig || {}) | 34 | + this.pluginProps = (typeof ele.pluginProps === 'object' && cloneObj({ ...ele.pluginProps, uuid: this.uuid })) || this.getDefaultPluginProps(ele.editorConfig || {}) |
| 35 | this.commonStyle = (typeof ele.commonStyle === 'object' && cloneObj(ele.commonStyle)) || { ...defaultStyle, zindex: ele.zindex } | 35 | this.commonStyle = (typeof ele.commonStyle === 'object' && cloneObj(ele.commonStyle)) || { ...defaultStyle, zindex: ele.zindex } |
| 36 | this.events = [] | 36 | this.events = [] |
| 37 | this.animations = ele.animations || [] | 37 | this.animations = ele.animations || [] |
| @@ -39,7 +39,9 @@ class Element { | @@ -39,7 +39,9 @@ class Element { | ||
| 39 | 39 | ||
| 40 | // init prop of plugin | 40 | // init prop of plugin |
| 41 | getDefaultPluginProps (propsConfig) { | 41 | getDefaultPluginProps (propsConfig) { |
| 42 | - const pluginProps = {} | 42 | + const pluginProps = { |
| 43 | + uuid: this.uuid | ||
| 44 | + } | ||
| 43 | Object.keys(propsConfig).forEach(key => { | 45 | Object.keys(propsConfig).forEach(key => { |
| 44 | // #6 | 46 | // #6 |
| 45 | if (key === 'name') { | 47 | if (key === 'name') { |
front-end/h5/src/components/plugins/lbp-form-checkbox-group.js
| 1 | import LbpFormRadio from './lbp-form-radio.js' | 1 | import LbpFormRadio from './lbp-form-radio.js' |
| 2 | -import { genUUID } from '../../utils/element.js' | ||
| 3 | 2 | ||
| 4 | const defaultItems = [ | 3 | const defaultItems = [ |
| 5 | { | 4 | { |
| @@ -21,7 +20,7 @@ export default { | @@ -21,7 +20,7 @@ export default { | ||
| 21 | props: { | 20 | props: { |
| 22 | aliasName: { | 21 | aliasName: { |
| 23 | type: String, | 22 | type: String, |
| 24 | - default: `标题演示-${genUUID().slice(0, 6)}`, | 23 | + default: `标题演示`, |
| 25 | editor: { | 24 | editor: { |
| 26 | type: 'a-input', | 25 | type: 'a-input', |
| 27 | label: '填写标题', | 26 | label: '填写标题', |
| @@ -110,7 +109,7 @@ export default { | @@ -110,7 +109,7 @@ export default { | ||
| 110 | render () { | 109 | render () { |
| 111 | return ( | 110 | return ( |
| 112 | <div> | 111 | <div> |
| 113 | - <h3>{this.aliasName}{this.type}</h3> | 112 | + <h3>{this.aliasName}</h3> |
| 114 | <input type="text" hidden value={this.value_} data-type="lbp-form-input" data-uuid={this.uuid} /> | 113 | <input type="text" hidden value={this.value_} data-type="lbp-form-input" data-uuid={this.uuid} /> |
| 115 | { | 114 | { |
| 116 | this.items.map(item => ( | 115 | this.items.map(item => ( |
| @@ -118,7 +117,7 @@ export default { | @@ -118,7 +117,7 @@ export default { | ||
| 118 | vertical | 117 | vertical |
| 119 | value={item.value} | 118 | value={item.value} |
| 120 | checked={this.type === 'radio' ? this.value === item.value : this.value.includes(item.value)} | 119 | checked={this.type === 'radio' ? this.value === item.value : this.value.includes(item.value)} |
| 121 | - aliasName={this.aliasName} | 120 | + aliasName={this.uuid} |
| 122 | type={this.type} | 121 | type={this.type} |
| 123 | onChange={this.onChange} | 122 | onChange={this.onChange} |
| 124 | >{item.value}</lbp-form-radio> | 123 | >{item.value}</lbp-form-radio> |
front-end/h5/src/components/plugins/lbp-form-radio-group.js
| @@ -18,7 +18,7 @@ export default { | @@ -18,7 +18,7 @@ export default { | ||
| 18 | props: { | 18 | props: { |
| 19 | aliasName: { | 19 | aliasName: { |
| 20 | type: String, | 20 | type: String, |
| 21 | - default: `标题演示-${genUUID().slice(0, 6)}`, | 21 | + default: `标题演示`, |
| 22 | editor: { | 22 | editor: { |
| 23 | type: 'a-input', | 23 | type: 'a-input', |
| 24 | label: '填写标题', | 24 | label: '填写标题', |
| @@ -115,7 +115,7 @@ export default { | @@ -115,7 +115,7 @@ export default { | ||
| 115 | vertical | 115 | vertical |
| 116 | value={item.value} | 116 | value={item.value} |
| 117 | checked={this.value === item.value} | 117 | checked={this.value === item.value} |
| 118 | - aliasName={this.aliasName} | 118 | + aliasName={this.uuid} |
| 119 | type={this.type} | 119 | type={this.type} |
| 120 | onChange={this.onChange} | 120 | onChange={this.onChange} |
| 121 | >{item.value} | 121 | >{item.value} |