Commit 0cd99c685f22d09542c6f085ad19f96954a63085
1 parent
525072e0
add script editor panel
Showing
3 changed files
with
98 additions
and
4 deletions
front-end/h5/src/components/core/editor/edit-panel/action.js
0 → 100644
| 1 | +import { mapState, mapActions } from 'vuex' | |
| 2 | + | |
| 3 | +export default { | |
| 4 | + data: () => ({ | |
| 5 | + }), | |
| 6 | + computed: { | |
| 7 | + ...mapState('element', { | |
| 8 | + editingElement: state => state.editingElement | |
| 9 | + }) | |
| 10 | + }, | |
| 11 | + methods: { | |
| 12 | + ...mapActions('element', [ | |
| 13 | + 'setEditingElement' // -> this.foo() | |
| 14 | + ]) | |
| 15 | + }, | |
| 16 | + created () {}, | |
| 17 | + render (h) { | |
| 18 | + const ele = this.editingElement | |
| 19 | + if (!ele) return (<span>请先选择一个元素</span>) | |
| 20 | + return (<div> | |
| 21 | + TODO | |
| 22 | + </div>) | |
| 23 | + } | |
| 24 | +} | ... | ... |
front-end/h5/src/components/core/editor/edit-panel/script.js
0 → 100644
| 1 | +import { mapState, mapActions } from 'vuex' | |
| 2 | + | |
| 3 | +export default { | |
| 4 | + data: () => ({ | |
| 5 | + editorContent: `return { | |
| 6 | + editorMethods: { // 此项配置自定义方法的在组件配置面板如何展示 | |
| 7 | + projectJump1: { // 方法名,对应于 methods 内的某方法 | |
| 8 | + label: '外部跳转1', // 自定义方法显示名 | |
| 9 | + params: [ // 参数列表,对象数组 | |
| 10 | + { | |
| 11 | + label: '跳转地址', // 参数1的名称 | |
| 12 | + desc: '项目相对地址', // 参数1的描述 | |
| 13 | + type: 'string', // 参数1的类型,支持string|number|boolean|array|object | |
| 14 | + default: '' // 参数1默认值 | |
| 15 | + }, | |
| 16 | + { | |
| 17 | + label: '参数', | |
| 18 | + desc: 'query形式参数', | |
| 19 | + type: 'object', | |
| 20 | + default: {} | |
| 21 | + } | |
| 22 | + ] | |
| 23 | + } | |
| 24 | + }, | |
| 25 | + methods:{ | |
| 26 | + projectJump1:function(url, query){ | |
| 27 | + console.log(url, query) | |
| 28 | + let win = window.open(url, '_blank') | |
| 29 | + win.focus() | |
| 30 | + } | |
| 31 | + } | |
| 32 | + }` | |
| 33 | + }), | |
| 34 | + computed: { | |
| 35 | + ...mapState('element', { | |
| 36 | + editingElement: state => state.editingElement | |
| 37 | + }) | |
| 38 | + }, | |
| 39 | + methods: { | |
| 40 | + ...mapActions('element', [ | |
| 41 | + 'setEditingElement' // -> this.foo() | |
| 42 | + ]), | |
| 43 | + mixinScript () { | |
| 44 | + // TODO mixin script | |
| 45 | + } | |
| 46 | + }, | |
| 47 | + render (h) { | |
| 48 | + const ele = this.editingElement | |
| 49 | + if (!ele) return (<span>请先选择一个元素</span>) | |
| 50 | + return <div> | |
| 51 | + <a-button onClick={this.mixinScript} disabled>使用脚本</a-button> | |
| 52 | + <div style={{ margin: '20px' }}></div> | |
| 53 | + <a-textarea | |
| 54 | + rows={12} | |
| 55 | + placeholder="Basic usage" | |
| 56 | + value={this.editorContent} | |
| 57 | + onChange={(e) => { | |
| 58 | + this.editorContent = e.target.value | |
| 59 | + }} | |
| 60 | + /> | |
| 61 | + </div> | |
| 62 | + } | |
| 63 | +} | ... | ... |
front-end/h5/src/components/core/editor/index.js
| ... | ... | @@ -8,6 +8,8 @@ import '../styles/index.scss' |
| 8 | 8 | import RenderEditCanvas from './canvas/edit' |
| 9 | 9 | import RenderPreviewCanvas from './canvas/preview' |
| 10 | 10 | import RenderPropsEditor from './edit-panel/props' |
| 11 | +import RenderScriptEditor from './edit-panel/script' | |
| 12 | +import RenderActoionEditor from './edit-panel/action' | |
| 11 | 13 | import RenderShortcutsPanel from './shortcuts-panel/index' |
| 12 | 14 | |
| 13 | 15 | const sidebarMenus = [ |
| ... | ... | @@ -34,7 +36,8 @@ export default { |
| 34 | 36 | activeMenuKey: 'pluginList', |
| 35 | 37 | pages: [], |
| 36 | 38 | // elements: [], |
| 37 | - isPreviewMode: false | |
| 39 | + isPreviewMode: false, | |
| 40 | + activeTabKey: '属性' | |
| 38 | 41 | }), |
| 39 | 42 | computed: { |
| 40 | 43 | ...mapState('element', { |
| ... | ... | @@ -137,7 +140,11 @@ export default { |
| 137 | 140 | </a-layout-content> |
| 138 | 141 | </a-layout> |
| 139 | 142 | <a-layout-sider width="340" theme='light' style={{ background: '#fff', padding: '0 12px' }}> |
| 140 | - <a-tabs style="height: 100%;" tabBarGutter={10}> | |
| 143 | + <a-tabs | |
| 144 | + style="height: 100%;" | |
| 145 | + tabBarGutter={10} | |
| 146 | + onChange={activeTabKey => { this.activeTabKey = activeTabKey }} | |
| 147 | + > | |
| 141 | 148 | {/* |
| 142 | 149 | #!zh tab 标题: |
| 143 | 150 | #!en tab title |
| ... | ... | @@ -153,8 +160,8 @@ export default { |
| 153 | 160 | <RenderPropsEditor/> |
| 154 | 161 | </a-tab-pane> |
| 155 | 162 | <a-tab-pane label="动画" key='动画' tab='动画'>动画</a-tab-pane> |
| 156 | - <a-tab-pane label="动作" key='动作' tab='动作'>动作</a-tab-pane> | |
| 157 | - <a-tab-pane label="脚本" key='脚本' tab='脚本'>脚本</a-tab-pane> | |
| 163 | + <a-tab-pane label="动作" key='动作' tab='动作'>{this.activeTabKey === '动作'}{ this.activeTabKey === '动作' && <RenderActoionEditor/> }</a-tab-pane> | |
| 164 | + <a-tab-pane label="脚本" key='脚本' tab='脚本'><RenderScriptEditor/></a-tab-pane> | |
| 158 | 165 | </a-tabs> |
| 159 | 166 | </a-layout-sider> |
| 160 | 167 | </a-layout> | ... | ... |