12
12
<el-button-group class =" header-right" >
13
13
<el-tooltip content =" 重置" >
14
14
<el-button @click =" handleReset" >
15
- <Icon icon =" system-uicons:reset-alt" :size = " 24 " />
15
+ <Icon :size = " 24 " icon =" system-uicons:reset-alt" />
16
16
</el-button >
17
17
</el-tooltip >
18
- <el-tooltip content = " 预览 " v-if =" previewUrl" >
18
+ <el-tooltip v-if =" previewUrl" content = " 预览 " >
19
19
<el-button @click =" handlePreview" >
20
- <Icon icon = " ep:view " :size = " 24 " />
20
+ <Icon :size = " 24 " icon = " ep:view " />
21
21
</el-button >
22
22
</el-tooltip >
23
23
<el-tooltip content =" 保存" >
24
24
<el-button @click =" handleSave" >
25
- <Icon icon = " ep:check " :size = " 24 " />
25
+ <Icon :size = " 24 " icon = " ep:check " />
26
26
</el-button >
27
27
</el-tooltip >
28
28
</el-button-group >
31
31
<!-- 中心区域 -->
32
32
<el-container class =" editor-container" >
33
33
<!-- 左侧:组件库(ComponentLibrary) -->
34
- <ComponentLibrary ref = " componentLibrary " :list = " libs " v-if =" libs && libs.length > 0" />
34
+ <ComponentLibrary v-if =" libs && libs.length > 0" ref = " componentLibrary " :list = " libs " />
35
35
<!-- 中心:设计区域(ComponentContainer) -->
36
36
<div class =" editor-center page-prop-area" @click =" handlePageSelected" >
37
37
<!-- 手机顶部 -->
38
38
<div class =" editor-design-top" >
39
39
<!-- 手机顶部状态栏 -->
40
- <img src =" @/assets/imgs/diy/statusBar.png" alt = " " class = " status-bar " />
40
+ <img alt = " " class = " status-bar " src =" @/assets/imgs/diy/statusBar.png" />
41
41
<!-- 手机顶部导航栏 -->
42
42
<ComponentContainer
43
43
v-if =" showNavigationBar"
44
+ :active =" selectedComponent?.id === navigationBarComponent.id"
44
45
:component =" navigationBarComponent"
45
46
:show-toolbar =" false"
46
- :active =" selectedComponent?.id === navigationBarComponent.id"
47
- @click =" handleNavigationBarSelected"
48
47
class =" cursor-pointer!"
48
+ @click =" handleNavigationBarSelected"
49
49
/>
50
50
</div >
51
51
<!-- 绝对定位的组件:例如 弹窗、浮动按钮等 -->
55
55
@click =" handleComponentSelected(component, index)"
56
56
>
57
57
<component
58
- v-if =" component.position === 'fixed' && selectedComponent?.uid === component.uid"
59
58
:is =" component.id"
59
+ v-if =" component.position === 'fixed' && selectedComponent?.uid === component.uid"
60
60
:property =" component.property"
61
61
/>
62
62
</div >
63
63
<!-- 手机页面编辑区域 -->
64
64
<el-scrollbar
65
- height =" 100%"
66
- wrap-class =" editor-design-center page-prop-area"
67
- view-class =" phone-container"
68
65
:view-style =" {
69
66
backgroundColor: pageConfigComponent.property.backgroundColor,
70
67
backgroundImage: `url(${pageConfigComponent.property.backgroundImage})`
71
68
}"
69
+ height =" 100%"
70
+ view-class =" phone-container"
71
+ wrap-class =" editor-design-center page-prop-area"
72
72
>
73
73
<draggable
74
- class =" page-prop-area drag-area"
75
74
v-model =" pageComponents"
76
- item-key =" index"
77
75
:animation =" 200"
76
+ :force-fallback =" true"
77
+ class =" page-prop-area drag-area"
78
78
filter =" .component-toolbar"
79
79
ghost-class =" draggable-ghost"
80
- :force-fallback =" true"
81
80
group =" component"
81
+ item-key =" index"
82
82
@change =" handleComponentChange"
83
83
>
84
84
<template #item =" { element , index } " >
85
85
<ComponentContainer
86
86
v-if =" !element.position || element.position === 'center'"
87
- :component =" element"
88
87
:active =" selectedComponentIndex === index"
89
- :can-move-up =" index > 0"
90
88
:can-move-down =" index < pageComponents.length - 1"
91
- @move =" (direction) => handleMoveComponent(index, direction)"
89
+ :can-move-up =" index > 0"
90
+ :component =" element"
91
+ @click =" handleComponentSelected(element, index)"
92
92
@copy =" handleCopyComponent(index)"
93
93
@delete =" handleDeleteComponent(index)"
94
- @click = " handleComponentSelected(element, index)"
94
+ @move = " (direction) => handleMoveComponent( index, direction )"
95
95
/>
96
96
</template >
97
97
</draggable >
98
98
</el-scrollbar >
99
99
<!-- 手机底部导航 -->
100
100
<div v-if =" showTabBar" :class =" ['editor-design-bottom', 'component', 'cursor-pointer!']" >
101
101
<ComponentContainer
102
+ :active =" selectedComponent?.id === tabBarComponent.id"
102
103
:component =" tabBarComponent"
103
104
:show-toolbar =" false"
104
- :active =" selectedComponent?.id === tabBarComponent.id"
105
105
@click =" handleTabBarSelected"
106
106
/>
107
107
</div >
108
108
<!-- 固定布局的组件 操作按钮区 -->
109
109
<div class =" fixed-component-action-group" >
110
110
<el-tag
111
111
v-if =" showPageConfig"
112
- size =" large"
113
112
:effect =" selectedComponent?.uid === pageConfigComponent.uid ? 'dark' : 'plain'"
114
113
:type =" selectedComponent?.uid === pageConfigComponent.uid ? '' : 'info'"
114
+ size =" large"
115
115
@click =" handleComponentSelected(pageConfigComponent)"
116
116
>
117
117
<Icon :icon =" pageConfigComponent.icon" :size =" 12" />
120
120
<template v-for =" (component , index ) in pageComponents " :key =" index " >
121
121
<el-tag
122
122
v-if =" component.position === 'fixed'"
123
- size =" large"
124
- closable
125
123
:effect =" selectedComponent?.uid === component.uid ? 'dark' : 'plain'"
126
124
:type =" selectedComponent?.uid === component.uid ? '' : 'info'"
125
+ closable
126
+ size =" large"
127
127
@click =" handleComponentSelected(component)"
128
128
@close =" handleDeleteComponent(index)"
129
129
>
134
134
</div >
135
135
</div >
136
136
<!-- 右侧:属性面板(ComponentContainerProperty) -->
137
- <el-aside class =" editor-right" width =" 350px" v-if = " selectedComponent?.property " >
137
+ <el-aside v-if = " selectedComponent?.property " class =" editor-right" width =" 350px" >
138
138
<el-card
139
- shadow =" never"
140
139
body-class =" h-[calc(100%-var(--el-card-padding)-var(--el-card-padding))]"
141
140
class =" h-full"
141
+ shadow =" never"
142
142
>
143
143
<!-- 组件名称 -->
144
144
<template #header >
152
152
view-class =" p-[var(--el-card-padding)] p-b-[calc(var(--el-card-padding)+var(--el-card-padding))] property"
153
153
>
154
154
<component
155
- :key =" selectedComponent?.uid || selectedComponent?.id"
156
155
:is =" selectedComponent?.id + 'Property'"
156
+ :key =" selectedComponent?.uid || selectedComponent?.id"
157
157
v-model =" selectedComponent.property"
158
158
/>
159
159
</el-scrollbar >
166
166
<Dialog v-model =" previewDialogVisible" title =" 预览" width =" 700" >
167
167
<div class =" flex justify-around" >
168
168
<IFrame
169
- class =" w-375px border-4px border-rounded-8px border-solid p-2px h-667px!"
170
169
:src =" previewUrl"
170
+ class =" w-375px border-4px border-rounded-8px border-solid p-2px h-667px!"
171
171
/>
172
172
<div class =" flex flex-col" >
173
173
<el-text >手机扫码预览</el-text >
179
179
<script lang="ts">
180
180
// 注册所有的组件
181
181
import { components } from ' ./components/mobile/index'
182
+
182
183
export default {
183
184
components: { ... components }
184
185
}
@@ -257,6 +258,11 @@ watch(
257
258
258
259
// 保存
259
260
const handleSave = () => {
261
+ // 发送保存通知
262
+ emits (' save' )
263
+ }
264
+ // 监听配置修改
265
+ const pageConfigChange = () => {
260
266
const pageConfig = {
261
267
page: pageConfigComponent .value .property ,
262
268
navigationBar: navigationBarComponent .value .property ,
@@ -272,10 +278,19 @@ const handleSave = () => {
272
278
// 发送数据更新通知
273
279
const modelValue = isString (props .modelValue ) ? JSON .stringify (pageConfig ) : pageConfig
274
280
emits (' update:modelValue' , modelValue )
275
- // 发送保存通知
276
- emits (' save' , pageConfig )
277
281
}
278
-
282
+ watch (
283
+ () => [
284
+ pageConfigComponent .value .property ,
285
+ navigationBarComponent .value .property ,
286
+ tabBarComponent .value .property ,
287
+ pageComponents .value
288
+ ],
289
+ () => {
290
+ pageConfigChange ()
291
+ },
292
+ { deep: true }
293
+ )
279
294
// 处理页面选中:显示属性表单
280
295
const handlePageSelected = (event : any ) => {
281
296
if (! props .showPageConfig ) return
@@ -547,6 +562,7 @@ $toolbar-height: 42px;
547
562
:deep (.el-tag ) {
548
563
box-shadow : 0 2px 8px 0 rgba (0 , 0 , 0 , 0.1 );
549
564
border : none ;
565
+
550
566
.el-tag__content {
551
567
width : 100% ;
552
568
display : flex ;
0 commit comments