@zhangqingcq/vgce 0.1.8 → 0.1.9
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 +35 -20
- package/dist/style.css +1 -1
- package/dist/vgce.js +147 -51
- package/dist/vgce.umd.cjs +2 -2
- package/package.json +1 -1
- package/src/assets/svgs/text-box.svg +1 -0
- package/src/config/files/text-box.vue +72 -0
- package/src/config/index.ts +5 -3
- package/src/config/svg/animation/index.ts +3 -2
- package/src/config/svg/animation/thermometer.ts +2 -1
- package/src/config/svg/custom/clock-a.ts +2 -1
- package/src/config/svg/custom/index.ts +6 -5
- package/src/config/svg/custom/light.ts +2 -1
- package/src/config/svg/custom/svg-text.ts +2 -1
- package/src/config/svg/custom/switch-r.ts +2 -1
- package/src/config/svg/index.ts +6 -10
- package/src/config/svg/stateful/alert-light.ts +2 -1
- package/src/config/svg/stateful/index.ts +3 -2
- package/src/config/svg/stateless/bot-2.ts +2 -1
- package/src/config/svg/stateless/bot-9.ts +2 -1
- package/src/config/svg/stateless/hamburger.ts +2 -1
- package/src/config/svg/stateless/hotpot.ts +2 -1
- package/src/config/svg/stateless/index.ts +6 -5
- package/src/config/vue/component/button.ts +2 -1
- package/src/config/vue/component/common-table.ts +2 -1
- package/src/config/vue/component/index.ts +9 -7
- package/src/config/vue/component/now-time.ts +2 -1
- package/src/config/vue/component/progress.ts +2 -1
- package/src/config/vue/component/tag.ts +2 -1
- package/src/config/vue/component/text-box.ts +66 -0
- package/src/config/vue/echarts/index.ts +3 -2
- package/src/config/vue/echarts/pie-charts.ts +2 -1
- package/src/config/vue/index.ts +4 -3
package/README.md
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
Vector graphics configure editor. 矢量图组态编辑器。
|
4
4
|
|
5
|
-
## Guide
|
5
|
+
## Guide 使用说明
|
6
6
|
|
7
|
-
### 1. install
|
7
|
+
### 1. install 安装依赖
|
8
8
|
|
9
9
|
```
|
10
10
|
npm i @zhangqingcq/vgce element-plus@^2.3.8 ace-builds@^1.14.0 lodash-es^4.17.21 vue-echarts@^6.5.1 animate.css@^4.1.1
|
@@ -16,7 +16,7 @@ Vector graphics configure editor. 矢量图组态编辑器。
|
|
16
16
|
pnpm add @zhangqingcq/vgce element-plus@^2.3.8 ace-builds@^1.14.0 lodash-es^4.17.21 vue-echarts@^6.5.1 animate.css@^4.1.1
|
17
17
|
```
|
18
18
|
|
19
|
-
### 2. change main.ts or main.js
|
19
|
+
### 2. change main.ts or main.js 修改项目主文件
|
20
20
|
|
21
21
|
```
|
22
22
|
//main.js or main.ts
|
@@ -24,7 +24,7 @@ Vector graphics configure editor. 矢量图组态编辑器。
|
|
24
24
|
import '@zhangqingcq/vgce/dist/style.css'
|
25
25
|
```
|
26
26
|
|
27
|
-
### 3. use editor
|
27
|
+
### 3. use editor 使用编辑器
|
28
28
|
```
|
29
29
|
<script setup lang="ts">
|
30
30
|
import {SvgEditor} from '@zhangqingcq/vgce'
|
@@ -37,7 +37,7 @@ Vector graphics configure editor. 矢量图组态编辑器。
|
|
37
37
|
<SvgEditor @onPreview="preview"/>
|
38
38
|
</template>
|
39
39
|
```
|
40
|
-
### 4. use viewer
|
40
|
+
### 4. use viewer 使用查看器
|
41
41
|
```
|
42
42
|
<script setup lang="ts">
|
43
43
|
import {SvgViewer} from '@zhangqingcq/vgce'
|
@@ -46,15 +46,15 @@ Vector graphics configure editor. 矢量图组态编辑器。
|
|
46
46
|
<SvgViewer :data="xxx"/>
|
47
47
|
</template>
|
48
48
|
```
|
49
|
-
### 5. custom toolbar
|
49
|
+
### 5. custom toolbar 自定义组件
|
50
50
|
|
51
|
-
|
51
|
+
- copy `src/config/` and change as you want (复制`src/config/`文件夹,然后更改里面的配置)
|
52
52
|
|
53
|
-
|
53
|
+
- put svg files into `src/asset/svgs` , then file name need to be same with config.name (将svg文件放到`src/asset/svgs`,文件名需要和配置文件里的`name`的值一致)
|
54
54
|
|
55
|
-
|
55
|
+
- put custom vue components file into `src/config/files`, then import in `src/config/index.ts` and export with `vueComp` (将自定义vue组件放到`src/config/files`,然后在`src/config/index.ts`引入并以`vueComp`具名导出,组件在vueComp下的key应和配置文件里`tag`的值一致)
|
56
56
|
|
57
|
-
-
|
57
|
+
- send the vue components to the editor and viewer with the props vueComp (在编辑器和查看器使用处把`src/config/index.ts`导出的vueComp引入并以`vueComp`作为props传递给编辑器和查看器组件)
|
58
58
|
|
59
59
|
```
|
60
60
|
// editor
|
@@ -79,11 +79,12 @@ Vector graphics configure editor. 矢量图组态编辑器。
|
|
79
79
|
<SvgViewer :vueComp="vueComp" :data="xxx"/>
|
80
80
|
</template>
|
81
81
|
```
|
82
|
+
- PS: you have to install `vite-plugin-svg-icons` plugin to append your svg to html dom.(你需要在项目安装npm依赖`vite-plugin-svg-icons`,用以把svg文件添加到项目入口html文件中进行使用)
|
82
83
|
|
83
|
-
### 6. how to use `vite-plugin-svg-icons`
|
84
|
+
### 6. how to use `vite-plugin-svg-icons` 如何使用 vite-plugin-svg-icons
|
84
85
|
|
85
|
-
- `npm i vite-plugin-svg-icons -D` or `pnpm add vite-plugin-svg-icons -D`
|
86
|
-
- change `vite.config.ts`
|
86
|
+
- `npm i vite-plugin-svg-icons -D` or `pnpm add vite-plugin-svg-icons -D` (安装依赖)
|
87
|
+
- change `vite.config.ts` (修改项目vite配置文件)
|
87
88
|
|
88
89
|
````
|
89
90
|
// vite.config.ts
|
@@ -98,7 +99,7 @@ Vector graphics configure editor. 矢量图组态编辑器。
|
|
98
99
|
iconDirs: [fileURLToPath(new URL('./src/assets/svgs', import.meta.url))],
|
99
100
|
symbolId: 'svg-[name]',
|
100
101
|
svgoOptions: false,
|
101
|
-
customDomId: '__svg__icons__dom__'//your id, do not use this id
|
102
|
+
customDomId: '__svg__icons__dom__'//your id, do not use this id!(使用你自己定义的id,不能使用__svg__icons__dom__,这是内置svg文件使用的id)
|
102
103
|
})
|
103
104
|
],
|
104
105
|
xxx
|
@@ -106,7 +107,7 @@ Vector graphics configure editor. 矢量图组态编辑器。
|
|
106
107
|
```
|
107
108
|
````
|
108
109
|
|
109
|
-
- change `main.ts`
|
110
|
+
- change `main.ts` (修改项目主文件)
|
110
111
|
|
111
112
|
```
|
112
113
|
// main.ts
|
@@ -114,12 +115,26 @@ Vector graphics configure editor. 矢量图组态编辑器。
|
|
114
115
|
import 'virtual:svg-icons-register'
|
115
116
|
```
|
116
117
|
|
117
|
-
- PS: if there is error: `Cannot find module ‘fast-glob’`,then run `npm i fast-glob -D` or `pnpm add fast-glob -D`
|
118
|
+
- PS: if there is error: `Cannot find module ‘fast-glob’`,then run `npm i fast-glob -D` or `pnpm add fast-glob -D` (如果报前面的错,就安装`fast-glob`npm 依赖)
|
118
119
|
|
119
|
-
### 7.
|
120
|
+
### 7.mqtt 通信
|
121
|
+
- 在编辑器右侧‘通信’菜单下配置好mqtt通信需要的url、username、password、topics
|
122
|
+
- 在使用查看器的地方监听查看器emit的`onMessage`事件,并处理事件返回的数据`{ topics, message }`
|
123
|
+
- message可以用JSON.parse解析成对象(后端推给前端的MQTT消息内容需要是JSON格式)
|
124
|
+
- 拿到消息后可以配合setNodeAttrByID方法更新界面
|
125
|
+
- setNodeAttrByID的参数id可以在传给本组件的props.data(用户传进来的,自然知道值是多少)里done_json找到
|
126
|
+
>如何找到指定组件的两种方案:
|
127
|
+
> 1. 用你的项目里前后端约定的svg组件唯一标识符替换掉编辑器生成的id(必须保证唯一),然后调用setNodeAttrByID改变组件属性。
|
128
|
+
> 2. 如果不想改动id(避免因不能保证手动改过的id唯一性导致编辑器功能异常),可以在config里给想要改变的组件的配置文件的props里增加一个字段,
|
129
|
+
如deviceCode(svg-text的配置文件里有被注释的例子),然后在编辑组态时,给对应组件填上对应的deviceCode(这样deviceCode就和组件id实现
|
130
|
+
了映射关系),并保存,后台给前台推MQTT消息时带上指定的deviceCode,前台预览时,在收到MQTT消息后,凭借消息里的deviceCode在done_json
|
131
|
+
找到组件的id(可以用vue的computed计算一份deviceCode和id的映射关系存到一个对象里,这样在需要id时可直接在计算出的对象凭借deviceCode
|
132
|
+
直接取到),即可用setNodeAttrByID改变组件属性
|
120
133
|
|
121
|
-
|
134
|
+
### 8. example 查看示例
|
122
135
|
|
123
|
-
-
|
136
|
+
- download [VGCE](https://github.com/RickyHeaven/VGCE.git) (下载项目)
|
124
137
|
|
125
|
-
- `pnpm
|
138
|
+
- `pnpm i` or `npm i` (安装依赖)
|
139
|
+
|
140
|
+
- `pnpm dev` or `npm run dev` (运行项目,使用示例参考`src/views`下两个页面)
|