mixdashboards 1.0.2 → 1.0.4

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 CHANGED
@@ -1,73 +1,337 @@
1
- # MixDashboards
2
-
3
- 一个基于Vue 3的工业物联网数据可视化组件库,提供大屏展示、Pro版和移动端适配的显示板组件。
4
-
5
- ## 简介
6
-
7
- MixDashboards(mixdashboards)是一个专注于工业物联网领域的前端组件库,提供了可视化大屏、Pro版和App端的显示板组件,服务于设备监控和数据展示需求。
8
-
9
- ## 安装
10
-
11
- ```bash
12
- npm install mixdashboards
13
- ```
14
-
15
- ## 使用
16
-
17
- ### 全局引入
18
-
19
- ```javascript
20
- import { createApp } from 'vue'
21
- import mixdashboards from 'mixdashboards'
22
- import 'mixdashboards/style'
23
-
24
- const app = createApp(App)
25
- app.use(mixdashboards)
26
- ```
27
-
28
- ### 按需引入
29
-
30
- ```javascript
31
- import { DesignPro, DesignShow, DesignApp } from 'mixdashboards'
32
- import 'mixdashboards/style'
33
- ```
34
-
35
- ### 组件使用
36
-
37
- ```vue
38
- <template>
39
- <DesignShow :uid="uid" :script="script" />
40
- <DesignPro :uid="uid" :script="script" />
41
- <DesignApp :uid="uid" :script="script" />
42
- </template>
43
-
44
- <script setup>
45
- const uid = '设备唯一标识'
46
- const script = {
47
- // 组件配置脚本
48
- }
49
- </script>
50
- ```
51
-
52
- ## 组件说明
53
-
54
- - `DesignShow` - 大屏显示板组件,适用于PC端大型数据可视化界面
55
- - `DesignPro` - Pro级显示板组件,支持复杂的布局与交互逻辑
56
- - `DesignApp` - App端适配的显示板组件,适用于移动端或轻量化场景
57
-
58
- ## 主要特性
59
-
60
- - 所有组件通过 `script` 脚本配置驱动,实现高度动态化渲染
61
- - 支持通过 `uid` 指定数据源对象,便于绑定具体设备或实体的数据流
62
- - 提供暗色主题支持
63
- - 内置拖拽布局能力
64
-
65
- ## 依赖
66
-
67
- - Vue 3.5+
68
- - Element Plus 2.9+
69
- - ECharts 5.6+
70
-
71
- ## 许可证
72
-
73
- MIT
1
+ # MixDashboards
2
+
3
+ <div align="center">
4
+
5
+ [![npm version](https://img.shields.io/npm/v/mixdashboards.svg)](https://www.npmjs.com/package/mixdashboards)
6
+ [![license](https://img.shields.io/npm/l/mixdashboards.svg)](https://github.com/mixlinker/mixdashboards/blob/main/LICENSE)
7
+
8
+ MixDashboards - 新一代企业级可视化组件库
9
+
10
+ 专为工业物联网和数据可视化场景设计的 Vue 3 组件库
11
+
12
+ </div>
13
+
14
+ ---
15
+
16
+ ## ✨ 特性
17
+
18
+ - 🎯 **开箱即用** - 内置丰富的图表和可视化组件
19
+ - 🚀 **实时数据** - 基于 WebSocket 的实时数据推送
20
+ - 🎨 **高度可定制** - 灵活的配置系统,满足各种业务需求
21
+ - 📱 **响应式设计** - 完美适配桌面和大屏展示
22
+ - 🔧 **Vue 3 + TypeScript** - 基于最新技术栈构建
23
+ - 🌐 **多场景支持** - Pro、Show、App、Pad 四种展示模式
24
+
25
+ ---
26
+
27
+ ## 📦 安装
28
+
29
+ ```bash
30
+ # 使用 npm
31
+ npm install mixdashboards vue element-plus
32
+
33
+ # 使用 pnpm
34
+ pnpm add mixdashboards vue element-plus
35
+
36
+ # 使用 yarn
37
+ yarn add mixdashboards vue element-plus
38
+ ```
39
+
40
+ ### 依赖要求
41
+
42
+ - Vue 3.5+
43
+ - Element Plus 2.11+
44
+
45
+ ```bash
46
+ npm install vue@^3.5.0 element-plus@^2.11.0
47
+ ```
48
+
49
+ ---
50
+
51
+ ## 🚀 快速开始
52
+
53
+ ### 方式一:按需引入(推荐)
54
+
55
+ ```vue
56
+ <script setup lang="ts">
57
+ import { DesignPro } from 'mixdashboards'
58
+ import 'mixdashboards/dist/style.css'
59
+ import 'element-plus/dist/index.css'
60
+
61
+ const config = {
62
+ name: "销售数据看板",
63
+ type: "pro",
64
+ version: "2.0.0",
65
+ sheets: [
66
+ {
67
+ name: "概览",
68
+ components: [
69
+ {
70
+ type: "bar",
71
+ name: "月度销售额",
72
+ common: {
73
+ object_id: "3713089264" // 数据对象ID
74
+ },
75
+ data: [{
76
+ fv: "sales_amount", // 数据字段
77
+ name: "销售额"
78
+ }]
79
+ }
80
+ ]
81
+ }
82
+ ]
83
+ }
84
+ </script>
85
+
86
+ <template>
87
+ <DesignPro
88
+ :script="config"
89
+ uid="sales-dashboard"
90
+ :enableWebSocket="true"
91
+ />
92
+ </template>
93
+ ```
94
+
95
+ ### 方式二:完整引入
96
+
97
+ ```typescript
98
+ // main.ts
99
+ import { createApp } from 'vue'
100
+ import ElementPlus from 'element-plus'
101
+ import 'element-plus/dist/index.css'
102
+ import MixDashboards from 'mixdashboards'
103
+ import 'mixdashboards/dist/style.css'
104
+ import App from './App.vue'
105
+
106
+ const app = createApp(App)
107
+ app.use(ElementPlus)
108
+ app.use(MixDashboards)
109
+ app.mount('#app')
110
+ ```
111
+
112
+ 然后在组件中直接使用:
113
+
114
+ ```vue
115
+ <template>
116
+ <DesignPro :script="config" uid="dashboard-001" />
117
+ </template>
118
+ ```
119
+
120
+ ---
121
+
122
+ ## 📚 组件说明
123
+
124
+ ### DesignPro - 专业版仪表盘
125
+
126
+ 功能最完整的仪表盘组件,支持实时数据、交互操作等。
127
+
128
+ **Props**
129
+
130
+ | 属性 | 类型 | 默认值 | 必填 | 说明 |
131
+ |------|------|--------|------|------|
132
+ | `script` | `Object` | - | ✅ | 仪表盘配置对象 |
133
+ | `uid` | `String` | - | ✅ | 唯一标识符,用于区分不同实例 |
134
+ | `enableWebSocket` | `Boolean` | `false` | ❌ | 是否启用 WebSocket 实时数据 |
135
+
136
+ **使用示例**
137
+
138
+ ```vue
139
+ <DesignPro
140
+ :script="dashboardConfig"
141
+ uid="prod-dashboard-001"
142
+ :enableWebSocket="true"
143
+ />
144
+ ```
145
+
146
+ ---
147
+
148
+ ### DesignShow - 展示版
149
+
150
+ 只读展示模式,适合大屏展示场景。
151
+
152
+ ```vue
153
+ <DesignShow :script="config" uid="show-001" />
154
+ ```
155
+
156
+ ---
157
+
158
+ ### DesignApp - 应用版
159
+
160
+ 移动端优化版本。
161
+
162
+ ```vue
163
+ <DesignApp :script="config" uid="app-001" />
164
+ ```
165
+
166
+ ---
167
+
168
+ ### DesignPad - 平板版
169
+
170
+ 平板设备优化版本。
171
+
172
+ ```vue
173
+ <DesignPad :script="config" uid="pad-001" />
174
+ ```
175
+
176
+ ---
177
+
178
+ ## 🔌 WebSocket 实时数据
179
+
180
+ ### 启用实时数据
181
+
182
+ 设置 `enableWebSocket="true"` 即可启用实时数据推送:
183
+
184
+ ```vue
185
+ <DesignPro
186
+ :script="config"
187
+ uid="dashboard"
188
+ :enableWebSocket="true"
189
+ />
190
+ ```
191
+
192
+ ### 用户认证
193
+
194
+ 组件会自动从 localStorage 读取用户信息进行认证:
195
+
196
+ ```typescript
197
+ // 在组件挂载前设置用户信息
198
+ localStorage.setItem('user', JSON.stringify({
199
+ token: 'YOUR_AUTH_TOKEN',
200
+ id: 1,
201
+ username: 'admin'
202
+ }))
203
+ ```
204
+
205
+ ### 数据订阅
206
+
207
+ 在组件配置中指定 `object_id` 和 `fv` 字段来订阅数据:
208
+
209
+ ```typescript
210
+ {
211
+ type: "bar",
212
+ common: {
213
+ object_id: "3713089264" // 数据对象ID
214
+ },
215
+ data: [{
216
+ fv: "temperature", // 要订阅的字段
217
+ name: "温度"
218
+ }]
219
+ }
220
+ ```
221
+
222
+ ## 配置结构
223
+
224
+ ```typescript
225
+ interface DashboardConfig {
226
+ name: string // 仪表盘名称
227
+ type: 'pro' | 'show' // 类型
228
+ version: string // 版本号
229
+ sheets: Sheet[] // 页面列表
230
+ currentPage: number // 当前页码
231
+ }
232
+
233
+ interface Sheet {
234
+ name: string // 页面名称
235
+ components: Component[] // 组件列表
236
+ background?: string // 背景设置
237
+ }
238
+
239
+ interface Component {
240
+ type: string // 组件类型(如 'bar', 'line', 'pie' 等)
241
+ name: string // 组件名称
242
+ options: object // 组件配置
243
+ data: DataItem[] // 数据配置
244
+ common: CommonConfig // 通用配置
245
+ }
246
+ ```
247
+
248
+ ---
249
+
250
+ ## 💡 开发模式
251
+
252
+ ### 静态数据模式(开发调试)
253
+
254
+ ```vue
255
+ <!-- 适合开发调试,不需要后端连接 -->
256
+ <DesignPro :script="config" uid="dev-001" />
257
+ ```
258
+
259
+ ### 实时数据模式(生产环境)
260
+
261
+ ```vue
262
+ <!-- 连接后端实时数据推送 -->
263
+ <DesignPro :script="config" uid="prod-001" :enableWebSocket="true" />
264
+ ```
265
+
266
+ ---
267
+
268
+ ## 🎨 支持的图表类型
269
+
270
+ - 📊 **柱状图 (bar)** - 横向/纵向柱状图
271
+ - 📈 **折线图 (line)** - 单线/多线图
272
+ - 🥧 **饼图 (pie)** - 饼图/环形图
273
+ - 📉 **散点图 (scatter)** - 散点分布图
274
+ - 🎯 **仪表盘 (gauge)** - 仪表盘图表
275
+ - 🗺️ **地图 (map)** - 地理数据可视化
276
+ - 📊 **竞赛条图 (raceBar)** - 动态排名图
277
+ - 🔢 **数字 (number)** - 数值展示组件
278
+ - 📝 **表格 (table)** - 数据表格
279
+ - 还有更多...
280
+
281
+ ---
282
+
283
+ ## ❓ 常见问题
284
+
285
+ ### 1. 样式没有生效?
286
+
287
+ 确保导入了样式文件:
288
+
289
+ ```typescript
290
+ import 'mixdashboards/dist/style.css'
291
+ import 'element-plus/dist/index.css'
292
+ ```
293
+
294
+ ### 2. WebSocket 连接失败?
295
+
296
+ 检查以下几点:
297
+ 1. 确保设置了 `enableWebSocket="true"`
298
+ 2. 确保 localStorage 中有用户 token
299
+ 3. 检查网络连接和后端服务状态
300
+
301
+ ### 3. 图表不显示数据?
302
+
303
+ 确保配置中包含:
304
+ - `common.object_id` - 数据对象ID
305
+ - `data[].fv` - 数据字段名
306
+
307
+ ### 4. 如何自定义主题?
308
+
309
+ 可以通过 CSS 变量覆盖默认样式:
310
+
311
+ ```css
312
+ :root {
313
+ --primary-color: #409EFF;
314
+ --background-color: #1a1a1a;
315
+ }
316
+ ```
317
+
318
+ ---
319
+
320
+ ## 🔗 相关链接
321
+
322
+ - [在线文档](https://docs.mixlinker.com/mixdashboards)
323
+ - [GitHub 仓库](http://192.168.88.6/mixiot/v8/frontend/newui/mixdashboards)
324
+ - [更新日志](./CHANGELOG.md)
325
+ - [问题反馈](http://192.168.88.6/mixiot/v8/frontend/newui/mixdashboards/issues)
326
+
327
+ ---
328
+
329
+ ## 📄 许可证
330
+
331
+ MIT © 2025 Mixlinker Technical Team
332
+
333
+ ---
334
+
335
+ <div align="center">
336
+ Made with ❤️ by Mixlinker
337
+ </div>