@hbixinlian/as-editor-components 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +451 -387
- package/dist/as-editor-components.css +1 -1
- package/dist/as-editor-components.es.js +2529 -3450
- package/dist/as-editor-components.es.js.map +1 -1
- package/dist/as-editor-components.umd.js +1 -45
- package/dist/as-editor-components.umd.js.map +1 -1
- package/dist/config/config.js +4 -4
- package/dist/index.html +21 -21
- package/dist/langs/zh_CN.js +415 -415
- package/dist/types/index.d.ts +26 -219
- package/package.json +107 -106
package/README.md
CHANGED
|
@@ -1,388 +1,452 @@
|
|
|
1
|
-
# @hbixinlian/as-editor-components
|
|
2
|
-
|
|
3
|
-
AS-Editor 可视化拖拽编辑器组件库 - 基于Vue3的可复用UI组件集合
|
|
4
|
-
|
|
5
|
-
## 📦 安装
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @hbixinlian/as-editor-components
|
|
9
|
-
# 或
|
|
10
|
-
pnpm install @hbixinlian/as-editor-components
|
|
11
|
-
# 或
|
|
12
|
-
yarn add @hbixinlian/as-editor-components
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## 🚀 快速开始
|
|
16
|
-
|
|
17
|
-
### 完整引入
|
|
18
|
-
|
|
19
|
-
```javascript
|
|
20
|
-
import { createApp } from
|
|
21
|
-
import
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
###
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
```vue
|
|
196
|
-
<
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
1
|
+
# @hbixinlian/as-editor-components
|
|
2
|
+
|
|
3
|
+
AS-Editor 可视化拖拽编辑器组件库 - 基于Vue3的可复用UI组件集合
|
|
4
|
+
|
|
5
|
+
## 📦 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @hbixinlian/as-editor-components
|
|
9
|
+
# 或
|
|
10
|
+
pnpm install @hbixinlian/as-editor-components
|
|
11
|
+
# 或
|
|
12
|
+
yarn add @hbixinlian/as-editor-components
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 🚀 快速开始
|
|
16
|
+
|
|
17
|
+
### 完整引入
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
import { createApp } from "vue";
|
|
21
|
+
import App from "./App.vue";
|
|
22
|
+
// 必要
|
|
23
|
+
import ElementPlus from "element-plus";
|
|
24
|
+
import "element-plus/dist/index.css";
|
|
25
|
+
// 必要
|
|
26
|
+
import vant from "vant";
|
|
27
|
+
import "vant/lib/index.css";
|
|
28
|
+
// 必要
|
|
29
|
+
import AsEditorComponents from "@hbixinlian/as-editor-components";
|
|
30
|
+
import "@hbixinlian/as-editor-components/dist/as-editor-components.css";
|
|
31
|
+
|
|
32
|
+
const app = createApp(App);
|
|
33
|
+
app.use(ElementPlus);
|
|
34
|
+
app.use(vant);
|
|
35
|
+
app.use(AsEditorComponents);
|
|
36
|
+
|
|
37
|
+
app.mount("#app");
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 按需引入
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
import { ComponentRenderer, CaptionText, PictureAds } from '@hbixinlian/as-editor-components'
|
|
45
|
+
|
|
46
|
+
// 在组件中使用
|
|
47
|
+
export default {
|
|
48
|
+
components: {
|
|
49
|
+
ComponentRenderer,
|
|
50
|
+
CaptionText,
|
|
51
|
+
PictureAds
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 分类引入
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
import {
|
|
60
|
+
BasicComponents, // 基础组件
|
|
61
|
+
BusinessComponents, // 业务组件
|
|
62
|
+
LayoutComponents, // 布局组件
|
|
63
|
+
MediaComponents // 媒体组件
|
|
64
|
+
} from '@hbixinlian/as-editor-components'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## 📋 组件列表
|
|
68
|
+
|
|
69
|
+
### 核心组件
|
|
70
|
+
|
|
71
|
+
#### JSON格式渲染器使用方法
|
|
72
|
+
```vue
|
|
73
|
+
<template>
|
|
74
|
+
<div class="app">
|
|
75
|
+
<!-- 渲染器组件 -->
|
|
76
|
+
<ComponentRenderer
|
|
77
|
+
:pageConfig="pageConfig"
|
|
78
|
+
:components="components"
|
|
79
|
+
:minHeight="800"
|
|
80
|
+
:showEditControls="false"
|
|
81
|
+
:enableInteraction="true"
|
|
82
|
+
@renderer-ready="onRendererReady"
|
|
83
|
+
@component-click="onComponentClick"
|
|
84
|
+
/>
|
|
85
|
+
</div>
|
|
86
|
+
</template>
|
|
87
|
+
|
|
88
|
+
<script setup lang="ts">
|
|
89
|
+
import { ref } from "vue";
|
|
90
|
+
|
|
91
|
+
const pageData = {
|
|
92
|
+
id: null,
|
|
93
|
+
name: "页面标题",
|
|
94
|
+
templateJson:
|
|
95
|
+
'{}',
|
|
96
|
+
component:
|
|
97
|
+
'[{}]',
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// 解析 JSON 字符串
|
|
101
|
+
const pageConfig = ref(JSON.parse(pageData.templateJson));
|
|
102
|
+
const components = ref(JSON.parse(pageData.component));
|
|
103
|
+
|
|
104
|
+
// 回调
|
|
105
|
+
const onRendererReady = () => {
|
|
106
|
+
console.log("Renderer ready!");
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const onComponentClick = (data: any) => {
|
|
110
|
+
console.log("Clicked component:", data);
|
|
111
|
+
};
|
|
112
|
+
</script>
|
|
113
|
+
|
|
114
|
+
<style>
|
|
115
|
+
.app {
|
|
116
|
+
padding: 20px;
|
|
117
|
+
}
|
|
118
|
+
</style>
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### ComponentRenderer - 组件渲染器
|
|
123
|
+
核心渲染组件,用于渲染页面配置和组件列表。
|
|
124
|
+
|
|
125
|
+
```vue
|
|
126
|
+
<template>
|
|
127
|
+
<ComponentRenderer
|
|
128
|
+
:pageConfig="pageConfig"
|
|
129
|
+
:components="components"
|
|
130
|
+
:minHeight="600"
|
|
131
|
+
:showEditControls="false"
|
|
132
|
+
:enableInteraction="true"
|
|
133
|
+
@component-click="handleComponentClick"
|
|
134
|
+
@component-delete="handleComponentDelete"
|
|
135
|
+
@renderer-ready="handleRendererReady"
|
|
136
|
+
/>
|
|
137
|
+
</template>
|
|
138
|
+
|
|
139
|
+
<script setup>
|
|
140
|
+
import { ComponentRenderer } from '@hbixinlian/as-editor-components'
|
|
141
|
+
|
|
142
|
+
const pageConfig = {
|
|
143
|
+
name: '页面标题',
|
|
144
|
+
isPerson: false,
|
|
145
|
+
isBack: true,
|
|
146
|
+
titleHeight: 35,
|
|
147
|
+
bgColor: '#f9f9f9',
|
|
148
|
+
bgImg: ''
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const components = [
|
|
152
|
+
{
|
|
153
|
+
component: 'CaptionText',
|
|
154
|
+
setStyle: {
|
|
155
|
+
name: '标题文本',
|
|
156
|
+
wordSize: 16,
|
|
157
|
+
wordColor: '#333'
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
|
|
162
|
+
const handleComponentClick = ({ component, index }) => {
|
|
163
|
+
console.log('组件点击:', component, index)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const handleComponentDelete = ({ index }) => {
|
|
167
|
+
console.log('删除组件:', index)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const handleRendererReady = () => {
|
|
171
|
+
console.log('渲染器准备完成')
|
|
172
|
+
}
|
|
173
|
+
</script>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 基础组件
|
|
177
|
+
|
|
178
|
+
#### CaptionText - 标题文本组件
|
|
179
|
+
用于显示标题和描述文本。
|
|
180
|
+
|
|
181
|
+
```vue
|
|
182
|
+
<CaptionText :datas="{
|
|
183
|
+
name: '标题文本',
|
|
184
|
+
description: '描述文本',
|
|
185
|
+
wordSize: 16,
|
|
186
|
+
wordColor: '#333',
|
|
187
|
+
positions: 'left',
|
|
188
|
+
backColor: '#fff'
|
|
189
|
+
}" />
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### PictureAds - 图片广告组件
|
|
193
|
+
支持单图、轮播等多种展示模式。
|
|
194
|
+
|
|
195
|
+
```vue
|
|
196
|
+
<PictureAds :datas="{
|
|
197
|
+
imageList: [
|
|
198
|
+
{ src: 'image1.jpg', text: '图片1' },
|
|
199
|
+
{ src: 'image2.jpg', text: '图片2' }
|
|
200
|
+
],
|
|
201
|
+
swiperType: 1,
|
|
202
|
+
borderRadius: 8
|
|
203
|
+
}" />
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
#### RichText - 富文本组件
|
|
207
|
+
支持富文本内容展示。
|
|
208
|
+
|
|
209
|
+
```vue
|
|
210
|
+
<RichText :datas="{
|
|
211
|
+
content: '<p>富文本内容</p>',
|
|
212
|
+
padding: 16
|
|
213
|
+
}" />
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
#### Notice - 通知栏组件
|
|
217
|
+
用于展示通知消息。
|
|
218
|
+
|
|
219
|
+
```vue
|
|
220
|
+
<Notice :datas="{
|
|
221
|
+
text: '通知内容',
|
|
222
|
+
speed: 50,
|
|
223
|
+
color: '#333',
|
|
224
|
+
backgroundColor: '#fff'
|
|
225
|
+
}" />
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### TabBar - 标签栏组件
|
|
229
|
+
用于标签页切换。
|
|
230
|
+
|
|
231
|
+
```vue
|
|
232
|
+
<TabBar :datas="{
|
|
233
|
+
tabs: [
|
|
234
|
+
{ name: '标签1', active: true },
|
|
235
|
+
{ name: '标签2', active: false }
|
|
236
|
+
]
|
|
237
|
+
}" />
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
#### Videos - 视频组件
|
|
241
|
+
用于视频播放展示。
|
|
242
|
+
|
|
243
|
+
```vue
|
|
244
|
+
<Videos :datas="{
|
|
245
|
+
src: 'video.mp4',
|
|
246
|
+
poster: 'poster.jpg',
|
|
247
|
+
autoplay: false
|
|
248
|
+
}" />
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### 业务组件
|
|
252
|
+
|
|
253
|
+
#### CommoditySearch - 商品搜索组件
|
|
254
|
+
```vue
|
|
255
|
+
<CommoditySearch :datas="{ placeholder: '请输入搜索关键词' }" />
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
#### CommunityPowder - 社群运营组件
|
|
259
|
+
```vue
|
|
260
|
+
<CommunityPowder :datas="{ title: '社群标题', memberCount: 1000 }" />
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
#### PersonalizedRecommendation - 个性化推荐组件
|
|
264
|
+
```vue
|
|
265
|
+
<PersonalizedRecommendation :datas="{
|
|
266
|
+
title: '为您推荐',
|
|
267
|
+
products: []
|
|
268
|
+
}" />
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### 布局组件
|
|
272
|
+
|
|
273
|
+
#### AuxiliarySegmentation - 辅助分割线组件
|
|
274
|
+
```vue
|
|
275
|
+
<AuxiliarySegmentation :datas="{
|
|
276
|
+
height: 10,
|
|
277
|
+
backgroundColor: '#f5f5f5'
|
|
278
|
+
}" />
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
#### MagicCube - 魔方组件
|
|
282
|
+
```vue
|
|
283
|
+
<MagicCube :datas="{
|
|
284
|
+
items: [
|
|
285
|
+
{ icon: 'icon1', text: '选项1' },
|
|
286
|
+
{ icon: 'icon2', text: '选项2' }
|
|
287
|
+
]
|
|
288
|
+
}" />
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### 媒体组件
|
|
292
|
+
|
|
293
|
+
#### CourseModule - 课程模块组件
|
|
294
|
+
```vue
|
|
295
|
+
<CourseModule :datas="{
|
|
296
|
+
courseList: [],
|
|
297
|
+
title: '推荐课程'
|
|
298
|
+
}" />
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
#### LiveModule - 直播模块组件
|
|
302
|
+
```vue
|
|
303
|
+
<LiveModule :datas="{
|
|
304
|
+
liveList: [],
|
|
305
|
+
title: '直播间'
|
|
306
|
+
}" />
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## 🛠 工具和配置
|
|
310
|
+
|
|
311
|
+
### ComponentProperties
|
|
312
|
+
组件属性配置数据,包含所有组件的默认配置和属性定义。
|
|
313
|
+
|
|
314
|
+
```javascript
|
|
315
|
+
import { Utils } from '@hbixinlian/as-editor-components'
|
|
316
|
+
const { ComponentProperties } = Utils
|
|
317
|
+
|
|
318
|
+
// 获取组件配置
|
|
319
|
+
const captionTextConfig = ComponentProperties.find(item => item.name === 'captiontext')
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### ComponentFactory
|
|
323
|
+
组件工厂,用于动态创建和管理组件。
|
|
324
|
+
|
|
325
|
+
```javascript
|
|
326
|
+
import { Utils } from '@hbixinlian/as-editor-components'
|
|
327
|
+
const { ComponentFactory } = Utils
|
|
328
|
+
|
|
329
|
+
// 使用组件工厂
|
|
330
|
+
const componentInstance = ComponentFactory.createComponent('captiontext', config)
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
## 📝 TypeScript 支持
|
|
334
|
+
|
|
335
|
+
本组件库提供完整的TypeScript类型定义:
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
import { ComponentRendererProps, ComponentItem, PageConfig } from '@hbixinlian/as-editor-components'
|
|
339
|
+
|
|
340
|
+
const pageConfig: PageConfig = {
|
|
341
|
+
name: '页面标题',
|
|
342
|
+
bgColor: '#f9f9f9'
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const components: ComponentItem[] = [
|
|
346
|
+
{
|
|
347
|
+
component: 'CaptionText',
|
|
348
|
+
setStyle: {
|
|
349
|
+
name: '标题'
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
]
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
## 🎯 依赖要求
|
|
356
|
+
|
|
357
|
+
### Peer Dependencies
|
|
358
|
+
- Vue 3.x
|
|
359
|
+
- Vant 3.x (UI组件库)
|
|
360
|
+
- Element Plus 1.x (部分组件使用)
|
|
361
|
+
|
|
362
|
+
请确保在项目中安装这些依赖:
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
npm install vue@^3.0.0 vant@^3.0.0 element-plus@^1.0.0
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
## 📖 完整示例
|
|
369
|
+
|
|
370
|
+
```vue
|
|
371
|
+
<template>
|
|
372
|
+
<div class="app">
|
|
373
|
+
<ComponentRenderer
|
|
374
|
+
:pageConfig="pageConfig"
|
|
375
|
+
:components="components"
|
|
376
|
+
:minHeight="600"
|
|
377
|
+
@component-click="handleClick"
|
|
378
|
+
/>
|
|
379
|
+
</div>
|
|
380
|
+
</template>
|
|
381
|
+
|
|
382
|
+
<script setup>
|
|
383
|
+
import { ref } from 'vue'
|
|
384
|
+
import { ComponentRenderer } from '@hbixinlian/as-editor-components'
|
|
385
|
+
import '@hbixinlian/as-editor-components/dist/as-editor-components.css'
|
|
386
|
+
|
|
387
|
+
const pageConfig = ref({
|
|
388
|
+
name: '商城首页',
|
|
389
|
+
bgColor: '#f9f9f9'
|
|
390
|
+
})
|
|
391
|
+
|
|
392
|
+
const components = ref([
|
|
393
|
+
{
|
|
394
|
+
component: 'CaptionText',
|
|
395
|
+
setStyle: {
|
|
396
|
+
name: '热门推荐',
|
|
397
|
+
wordSize: 18,
|
|
398
|
+
wordColor: '#333',
|
|
399
|
+
positions: 'center'
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
component: 'PictureAds',
|
|
404
|
+
setStyle: {
|
|
405
|
+
imageList: [
|
|
406
|
+
{ src: 'banner1.jpg', text: '广告1' },
|
|
407
|
+
{ src: 'banner2.jpg', text: '广告2' }
|
|
408
|
+
],
|
|
409
|
+
swiperType: 1,
|
|
410
|
+
borderRadius: 8
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
])
|
|
414
|
+
|
|
415
|
+
const handleClick = ({ component, index }) => {
|
|
416
|
+
console.log('点击了组件:', component.component, '索引:', index)
|
|
417
|
+
}
|
|
418
|
+
</script>
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
## 🔧 开发与构建
|
|
422
|
+
|
|
423
|
+
```bash
|
|
424
|
+
# 安装依赖
|
|
425
|
+
npm install
|
|
426
|
+
|
|
427
|
+
# 开发模式
|
|
428
|
+
npm run dev
|
|
429
|
+
|
|
430
|
+
# 构建库
|
|
431
|
+
npm run build:lib
|
|
432
|
+
|
|
433
|
+
# 代码检查
|
|
434
|
+
npm run lint
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
## 📄 许可证
|
|
438
|
+
|
|
439
|
+
MIT License
|
|
440
|
+
|
|
441
|
+
## 🤝 贡献
|
|
442
|
+
|
|
443
|
+
欢迎提交 Issues 和 Pull Requests!
|
|
444
|
+
|
|
445
|
+
## 📞 联系
|
|
446
|
+
|
|
447
|
+
- 作者: 孤傲 <9068149@qq.com>
|
|
448
|
+
- GitHub: https://github.com/hbixinlian/as-editor
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
388
452
|
更多详细使用说明请参考各组件的具体文档。
|