w-echarts-vue 1.0.0

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.
Files changed (81) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +55 -0
  4. package/.jsdoc +25 -0
  5. package/LICENSE +21 -0
  6. package/README.md +130 -0
  7. package/SECURITY.md +5 -0
  8. package/babel.config.js +16 -0
  9. package/dist/w-echarts-vue.umd.js +30 -0
  10. package/dist/w-echarts-vue.umd.js.map +1 -0
  11. package/docs/components_WEchartsVue.vue.html +420 -0
  12. package/docs/examples/app.html +62 -0
  13. package/docs/examples/app.umd.js +31 -0
  14. package/docs/examples/app.umd.js.map +1 -0
  15. package/docs/examples/w-echarts-vue_area.html +1733 -0
  16. package/docs/examples/w-echarts-vue_bar3D.html +1733 -0
  17. package/docs/examples/w-echarts-vue_continuous.html +1733 -0
  18. package/docs/examples/w-echarts-vue_heatmap.html +1733 -0
  19. package/docs/examples/w-echarts-vue_line.html +1733 -0
  20. package/docs/examples/w-echarts-vue_line3D.html +1733 -0
  21. package/docs/examples/w-echarts-vue_parallel.html +1733 -0
  22. package/docs/examples/w-echarts-vue_polar heatmap.html +1733 -0
  23. package/docs/examples/w-echarts-vue_polar.html +1733 -0
  24. package/docs/examples/w-echarts-vue_radar.html +1733 -0
  25. package/docs/examples/w-echarts-vue_resize.html +1746 -0
  26. package/docs/examples/w-echarts-vue_scatter.html +1733 -0
  27. package/docs/examples/w-echarts-vue_stack.html +1733 -0
  28. package/docs/examples/w-echarts-vue_surface.html +1733 -0
  29. package/docs/examples/w-echarts-vue_tree.html +1736 -0
  30. package/docs/examples/w-echarts-vue_treemap.html +1734 -0
  31. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  32. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  33. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  34. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  35. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  36. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  37. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  38. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  39. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  40. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  41. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  42. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  43. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  44. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  45. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  46. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  47. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  48. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  49. package/docs/global.html +281 -0
  50. package/docs/index.html +84 -0
  51. package/docs/js_iniEcharts.mjs.html +104 -0
  52. package/docs/module-WEchartsVue.html +1006 -0
  53. package/docs/scripts/collapse.js +39 -0
  54. package/docs/scripts/commonNav.js +28 -0
  55. package/docs/scripts/linenumber.js +25 -0
  56. package/docs/scripts/nav.js +12 -0
  57. package/docs/scripts/polyfill.js +4 -0
  58. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  59. package/docs/scripts/prettify/lang-css.js +2 -0
  60. package/docs/scripts/prettify/prettify.js +28 -0
  61. package/docs/scripts/search.js +99 -0
  62. package/docs/styles/jsdoc.css +776 -0
  63. package/docs/styles/prettify.css +80 -0
  64. package/package.json +70 -0
  65. package/public/index.html +31 -0
  66. package/script.txt +22 -0
  67. package/src/App.vue +180 -0
  68. package/src/AppZoneWEchartsVue.vue +1171 -0
  69. package/src/components/WEchartsVue.vue +348 -0
  70. package/src/js/iniEcharts.mjs +32 -0
  71. package/src/main.js +8 -0
  72. package/test/all.test.mjs +10 -0
  73. package/toolg/addVersion.mjs +4 -0
  74. package/toolg/cleanFolder.mjs +5 -0
  75. package/toolg/cvCasename.mjs +43 -0
  76. package/toolg/gDistApp.mjs +35 -0
  77. package/toolg/gDistRollupComps.mjs +24 -0
  78. package/toolg/gDocExams.mjs +47 -0
  79. package/toolg/gExtractHtml.mjs +285 -0
  80. package/toolg/modifyReadme.mjs +4 -0
  81. package/vue.config.js +27 -0
@@ -0,0 +1,348 @@
1
+ <template>
2
+ <!-- ref=$self為供外部存取繪圖容器之用; 寬高由外部以style給予 -->
3
+ <div ref="$self" class="w-echarts-vue"></div>
4
+ </template>
5
+
6
+ <script>
7
+ import { throttle } from 'echarts/core'
8
+ import iniEcharts from '../js/iniEcharts.mjs'
9
+
10
+
11
+ //echarts, 直接引用echarts與echarts-gl不使用cdn
12
+ //注意: 本組件直接以echarts原生API實作生命週期(init, setOption, resize, dispose)與事件轉發,
13
+ //不使用vue-echarts, 因其runtime依賴vue-demi, 而vue-demi出廠為Vue3模式須靠postinstall切換,
14
+ //npm>=12/pnpm>=10/bun預設封鎖依賴套件install scripts, 下游以src方式引用本套件時會靜默停在Vue3模式而壞掉;
15
+ //直接實作後全依賴樹零install script, 下游任意套件管理器與打包器皆零設定可用
16
+ let echarts = iniEcharts()
17
+
18
+
19
+ /**
20
+ * echarts繪圖組件, 已內含echarts全量圖表與組件, 以及echarts-gl之3D圖表(bar3D, line3D, scatter3D, surface等), 不須自cdn額外引用
21
+ *
22
+ * 注意: 組件本身不帶預設高度, 須由外部給予寬高(例如style="width:620px; height:300px;"), 否則因高度為0而看不見圖形
23
+ *
24
+ * @vue-prop {Object} [options={}] 輸入echarts設定物件,即echarts之option,預設{}。變更時自動重繪:給予新物件(參照改變)採整體置換(notMerge),原物件內變更(mutation)採合併更新,與vue-echarts語意一致
25
+ * @vue-prop {String|Object} [theme=''] 輸入echarts主題字串或主題設定物件,字串為已使用echarts.registerTheme註冊之主題名稱,變更時會自動銷毀重建圖表,預設''
26
+ * @vue-prop {Object} [initOptions={}] 輸入echarts初始化設定物件,即echarts.init之opts,可設定renderer('canvas'或'svg')、locale、devicePixelRatio等,變更時會自動銷毀重建圖表,預設{}
27
+ * @vue-prop {Object} [updateOptions={}] 輸入echarts更新設定物件,即echarts之setOption之opts,可設定notMerge、replaceMerge、lazyUpdate等,預設{}
28
+ * @vue-prop {String} [group=''] 輸入圖表群組名稱字串,供echarts.connect跨圖表連動使用,預設''
29
+ * @vue-prop {Boolean} [manualUpdate=false] 輸入是否關閉options之深度監聽布林值,若為true則變更options不會自動重繪,須自行取得實例呼叫setOption更新,適用於資料量龐大時,預設false
30
+ * @vue-prop {Boolean} [loading=false] 輸入是否顯示讀取中動畫布林值,預設false
31
+ * @vue-prop {Object} [loadingOptions={}] 輸入讀取中動畫設定物件,即echarts之showLoading之opts,可設定text、color、maskColor等,預設{}
32
+ * @vue-prop {Boolean|Object} [autoresize=true] 輸入是否於容器尺寸改變時自動重繪布林值,亦可給物件設定{throttle,onResize},throttle為節流毫秒數預設100,預設true
33
+ * @vue-event {Object} * 對外轉發echarts之全部事件,例如click、mouseover、legendselectchanged、datazoom、finished等,回傳事件參數物件;zrender事件以zr:前綴綁定,例如@zr:click
34
+ */
35
+ export default {
36
+ props: {
37
+ options: {
38
+ type: Object,
39
+ default: () => {},
40
+ },
41
+ theme: {
42
+ type: [String, Object],
43
+ default: () => '',
44
+ },
45
+ initOptions: {
46
+ type: Object,
47
+ default: () => {},
48
+ },
49
+ updateOptions: {
50
+ type: Object,
51
+ default: () => {},
52
+ },
53
+ group: {
54
+ type: String,
55
+ default: () => '',
56
+ },
57
+ manualUpdate: {
58
+ type: Boolean,
59
+ default: () => false,
60
+ },
61
+ loading: {
62
+ type: Boolean,
63
+ default: () => false,
64
+ },
65
+ loadingOptions: {
66
+ type: Object,
67
+ default: () => {},
68
+ },
69
+ autoresize: {
70
+ type: [Boolean, Object],
71
+ default: () => true,
72
+ },
73
+ },
74
+ data: function() {
75
+ //chart與resizeObserver為echarts實例與瀏覽器原生物件, 不可放入data,
76
+ //否則Vue會對其深層響應化(遞迴defineProperty), 造成效能問題, 故於init時直接掛this成非響應式屬性
77
+ return {
78
+ }
79
+ },
80
+ mounted: function() {
81
+ //console.log('mounted')
82
+
83
+ let vo = this
84
+
85
+ //init
86
+ vo.init()
87
+
88
+ },
89
+ beforeDestroy: function() {
90
+ //console.log('beforeDestroy')
91
+
92
+ let vo = this
93
+
94
+ //clear
95
+ vo.clear()
96
+
97
+ },
98
+ watch: {
99
+
100
+ options: {
101
+ deep: true,
102
+ handler: function(nv, ov) {
103
+ let vo = this
104
+
105
+ //manualUpdate, 關閉自動重繪
106
+ if (vo.manualUpdate) {
107
+ return
108
+ }
109
+
110
+ //check
111
+ if (!vo.chart) {
112
+ return
113
+ }
114
+
115
+ //setOption, 參照改變(給予新物件)採整體置換, 原物件內變更採合併更新, 與vue-echarts語意一致
116
+ vo.chart.setOption(nv || {}, { notMerge: nv !== ov, ...vo.updateOptions })
117
+
118
+ },
119
+ },
120
+
121
+ theme: function() {
122
+ this.reinit()
123
+ },
124
+
125
+ initOptions: {
126
+ deep: true,
127
+ handler: function() {
128
+ this.reinit()
129
+ },
130
+ },
131
+
132
+ group: function(nv) {
133
+ let vo = this
134
+ if (vo.chart) {
135
+ vo.chart.group = nv || ''
136
+ }
137
+ },
138
+
139
+ loading: function() {
140
+ this.updateLoading()
141
+ },
142
+
143
+ loadingOptions: {
144
+ deep: true,
145
+ handler: function() {
146
+ this.updateLoading()
147
+ },
148
+ },
149
+
150
+ autoresize: function() {
151
+ let vo = this
152
+ vo.clearResize()
153
+ vo.bindResize()
154
+ },
155
+
156
+ },
157
+ computed: {
158
+ },
159
+ methods: {
160
+
161
+ /**
162
+ * 初始化圖表, 建立echarts實例並綁定事件, 讀取中動畫與尺寸監聽(內部使用)
163
+ */
164
+ init: function() {
165
+ let vo = this
166
+
167
+ //el
168
+ let el = vo.$refs['$self']
169
+ if (!el) {
170
+ return
171
+ }
172
+
173
+ //init
174
+ let chart = echarts.init(el, vo.theme || null, vo.initOptions || {})
175
+
176
+ //chart, 掛this成非響應式屬性
177
+ vo.chart = chart
178
+
179
+ //group
180
+ if (vo.group) {
181
+ chart.group = vo.group
182
+ }
183
+
184
+ //setOption
185
+ chart.setOption(vo.options || {}, vo.updateOptions || {})
186
+
187
+ //事件轉發, 由$listeners綁定echarts事件, zr:前綴綁定zrender事件
188
+ Object.keys(vo.$listeners || {}).forEach((key) => {
189
+
190
+ //k, 剝除Vue事件修飾前綴(~為once, &為passive, !為capture)
191
+ let k = key.replace(/^[~!&]+/, '')
192
+
193
+ //fn
194
+ let fn = vo.$listeners[key]
195
+
196
+ //on
197
+ if (k.indexOf('zr:') === 0) {
198
+ chart.getZr().on(k.slice(3), fn)
199
+ }
200
+ else {
201
+ chart.on(k, fn)
202
+ }
203
+
204
+ })
205
+
206
+ //updateLoading
207
+ vo.updateLoading()
208
+
209
+ //bindResize
210
+ vo.bindResize()
211
+
212
+ },
213
+
214
+ /**
215
+ * 銷毀並重建圖表, 供theme或initOptions變更時使用(內部使用)
216
+ */
217
+ reinit: function() {
218
+ let vo = this
219
+
220
+ //clear
221
+ vo.clear()
222
+
223
+ //init
224
+ vo.init()
225
+
226
+ },
227
+
228
+ /**
229
+ * 更新讀取中動畫(內部使用)
230
+ */
231
+ updateLoading: function() {
232
+ let vo = this
233
+
234
+ //check
235
+ if (!vo.chart) {
236
+ return
237
+ }
238
+
239
+ //showLoading, hideLoading
240
+ if (vo.loading) {
241
+ vo.chart.showLoading('default', vo.loadingOptions || {})
242
+ }
243
+ else {
244
+ vo.chart.hideLoading()
245
+ }
246
+
247
+ },
248
+
249
+ /**
250
+ * 綁定容器尺寸監聽, 尺寸改變時自動重繪(內部使用)
251
+ */
252
+ bindResize: function() {
253
+ let vo = this
254
+
255
+ //check
256
+ if (!vo.autoresize || !vo.chart) {
257
+ return
258
+ }
259
+
260
+ //el
261
+ let el = vo.$refs['$self']
262
+ if (!el) {
263
+ return
264
+ }
265
+
266
+ //wait, onResize
267
+ let opt = (vo.autoresize === true) ? {} : vo.autoresize
268
+ let wait = Number.isFinite(opt.throttle) ? opt.throttle : 100
269
+ let onResize = opt.onResize
270
+
271
+ //callback, 重繪並通知外部
272
+ let callback = () => {
273
+ if (!vo.chart) {
274
+ return
275
+ }
276
+ vo.chart.resize()
277
+ if (typeof onResize === 'function') {
278
+ onResize()
279
+ }
280
+ }
281
+ if (wait > 0) {
282
+ callback = throttle(callback, wait)
283
+ }
284
+
285
+ //resizeObserver, 掛this成非響應式屬性, 首次observe必觸發一次callback故跳過
286
+ let bFirst = true
287
+ vo.resizeObserver = new ResizeObserver(() => {
288
+ if (bFirst) {
289
+ bFirst = false
290
+ return
291
+ }
292
+ callback()
293
+ })
294
+ vo.resizeObserver.observe(el)
295
+
296
+ },
297
+
298
+ /**
299
+ * 解除容器尺寸監聽(內部使用)
300
+ */
301
+ clearResize: function() {
302
+ let vo = this
303
+
304
+ //disconnect
305
+ if (vo.resizeObserver) {
306
+ vo.resizeObserver.disconnect()
307
+ vo.resizeObserver = null
308
+ }
309
+
310
+ },
311
+
312
+ /**
313
+ * 銷毀圖表與監聽(內部使用)
314
+ */
315
+ clear: function() {
316
+ let vo = this
317
+
318
+ //clearResize
319
+ vo.clearResize()
320
+
321
+ //dispose
322
+ if (vo.chart) {
323
+ vo.chart.dispose()
324
+ vo.chart = null
325
+ }
326
+
327
+ },
328
+
329
+ /**
330
+ * 取得內部echarts實例, 供外部呼叫echarts原生方法(setOption, resize, getDataURL, dispatchAction等)之用
331
+ * 因echarts實例於組件掛載後才建立, 故初始化前呼叫會回傳null
332
+ *
333
+ * @returns {Object|null} 回傳echarts實例物件, 若尚未初始化則回傳null
334
+ */
335
+ getChart: function() {
336
+ let vo = this
337
+ return vo.chart || null
338
+ },
339
+
340
+ },
341
+ }
342
+ </script>
343
+
344
+ <style scoped>
345
+ .w-echarts-vue {
346
+ display: block;
347
+ }
348
+ </style>
@@ -0,0 +1,32 @@
1
+ import * as echarts from 'echarts'
2
+ import 'echarts-gl'
3
+
4
+
5
+ /**
6
+ * 初始化echarts, 直接引用echarts與echarts-gl不使用cdn
7
+ *
8
+ * echarts採全量引入(import 'echarts'), 已自動註冊全部內建圖表(line, bar, pie, scatter, radar, heatmap, tree, treemap, sunburst, parallel, custom等)
9
+ * 與全部內建組件(title, legend, tooltip, toolbox, dataZoom, visualMap, grid, polar, geo等), 故使用時不須另外呼叫echarts.use註冊
10
+ *
11
+ * echarts-gl為3D擴充模組, 匯入時即自行向echarts註冊bar3D, line3D, scatter3D, surface, lines3D等圖表, 以及grid3D, geo3D, globe等座標系,
12
+ * 其package.json已正確宣告sideEffects白名單(index.js與lib/export/all.js等), 故純副作用引入不會被tree-shaking移除
13
+ *
14
+ * 注意: echarts-gl之esm原始碼含無副檔名之深層引用(如'zrender/lib/core/LRU', 'echarts/lib/util/layout'),
15
+ * 而echarts與zrender之package.json exports末端為萬用對應"./*": "./*", 依Node規範解析結果不補副檔名,
16
+ * 故打包工具須具備[深層子路徑補.js重試]之解析能力(webpack內建此行為; rollup需由w-package-tools之rollupFile提供)
17
+ *
18
+ * @returns {Object} 回傳echarts命名空間物件
19
+ * @example
20
+ *
21
+ * import iniEcharts from 'w-echarts-vue/src/js/iniEcharts.mjs'
22
+ *
23
+ * let echarts = iniEcharts()
24
+ * echarts.registerTheme('myTheme', { ... })
25
+ *
26
+ */
27
+ function iniEcharts() {
28
+ return echarts
29
+ }
30
+
31
+
32
+ export default iniEcharts
package/src/main.js ADDED
@@ -0,0 +1,8 @@
1
+ import Vue from 'vue'
2
+ import App from './App.vue'
3
+
4
+ Vue.config.productionTip = false
5
+
6
+ new Vue({
7
+ render: h => h(App)
8
+ }).$mount('#app')
@@ -0,0 +1,10 @@
1
+ import assert from 'assert'
2
+
3
+
4
+ describe('all', function() {
5
+
6
+ it('test in localhost', function() {
7
+ assert.strict.deepEqual(1, 1)
8
+ })
9
+
10
+ })
@@ -0,0 +1,4 @@
1
+ import addVersion from 'w-package-tools/src/addVersion.mjs'
2
+
3
+
4
+ addVersion()
@@ -0,0 +1,5 @@
1
+ import cleanFolder from 'w-package-tools/src/cleanFolder.mjs'
2
+
3
+
4
+ cleanFolder('dist')
5
+ cleanFolder('docs')
@@ -0,0 +1,43 @@
1
+ import map from 'lodash-es/map.js'
2
+ import trim from 'lodash-es/trim.js'
3
+ import filter from 'lodash-es/filter.js'
4
+ import toUpper from 'lodash-es/toUpper.js'
5
+ import split from 'lodash-es/split.js'
6
+ import size from 'lodash-es/size.js'
7
+ import join from 'lodash-es/join.js'
8
+
9
+
10
+ function seCut(str) {
11
+
12
+ //split
13
+ let s = split(str, '&')
14
+
15
+ //trim
16
+ s = map(s, function(v) {
17
+ return trim(v)
18
+ })
19
+
20
+ //n
21
+ let n = size(s)
22
+ n = Math.min(4, n)
23
+
24
+ //r
25
+ let r = []
26
+ for (let i = 0; i < n; i++) {
27
+ r.push(s[i])
28
+ }
29
+
30
+ //join
31
+ let c = join(r, '_')
32
+
33
+ return c
34
+ }
35
+
36
+
37
+ function cvCasename(casename) {
38
+ //return seEncode(casename)
39
+ return seCut(casename)
40
+ }
41
+
42
+
43
+ export default cvCasename
@@ -0,0 +1,35 @@
1
+ import rollupVueToHtml from 'w-package-tools/src/rollupVueToHtml.mjs'
2
+
3
+
4
+ let opt = {
5
+ title: `w-echarts-vue`,
6
+ head: `
7
+
8
+ <!-- rollupVueToHtml已自動添加@babel/polyfill與vue -->
9
+
10
+ <!-- fontawesome -->
11
+ <link href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.2/css/all.min.css" rel="stylesheet">
12
+
13
+ <!-- mdi, 各組件使用mdi/js故不需引用 -->
14
+ <link _href="https://cdn.jsdelivr.net/npm/@mdi/font@7.4.47/css/materialdesignicons.min.css" rel="stylesheet">
15
+
16
+ <!-- google, 各組件使用mdi/js故不需引用 -->
17
+ <link _href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
18
+ <link _href="https://fonts.googleapis.com/css?family=Material+Icons" rel="stylesheet">
19
+
20
+ <!-- data -->
21
+ <script src="https://cdn.jsdelivr.net/npm/w-demores/res/data/dataAAPL.js"></script>
22
+ <script src="https://cdn.jsdelivr.net/npm/w-demores/res/data/dataUSD2EUR.js"></script>
23
+ <script src="https://cdn.jsdelivr.net/npm/w-demores/res/data/dataHousePriceArea.js"></script>
24
+ <script src="https://cdn.jsdelivr.net/npm/w-demores/res/data/dataFlare.js"></script>
25
+
26
+ `,
27
+ globals: {
28
+ 'vue': 'Vue',
29
+ },
30
+ external: [
31
+ 'vue',
32
+ ],
33
+ }
34
+ rollupVueToHtml('./src/App.vue', './docs/examples/app.html', opt)
35
+
@@ -0,0 +1,24 @@
1
+ import rollupFiles from 'w-package-tools/src/rollupFiles.mjs'
2
+
3
+
4
+ let fdSrc = './src/components/'
5
+ let fdTar = './dist'
6
+
7
+
8
+ rollupFiles({
9
+ fns: 'WEchartsVue.vue',
10
+ fdSrc,
11
+ fdTar,
12
+ format: 'umd',
13
+ //nameDistType: 'kebabCase',
14
+ hookNameDist: () => {
15
+ return 'w-echarts-vue'
16
+ },
17
+ globals: {
18
+ 'vue': 'Vue',
19
+ },
20
+ external: [
21
+ 'vue',
22
+ ],
23
+ })
24
+
@@ -0,0 +1,47 @@
1
+ import fs from 'fs'
2
+ import _ from 'lodash-es'
3
+ import getFiles from 'w-package-tools/src/getFiles.mjs'
4
+ import getPks from 'w-package-tools/src/getPks.mjs'
5
+
6
+
7
+ let fdSrc = './test-html/'
8
+ let fdTar = './docs/examples/'
9
+
10
+
11
+ function main() {
12
+ //把example裡面cdn更換, 再複製到docs的example內, 作為日後發佈為靜態網站
13
+
14
+ //pks
15
+ let pks = getPks()
16
+
17
+ //cdn
18
+ let cdn = `<script src="https://cdn.jsdelivr.net/npm/w-echarts-vue@${pks.version}/dist/w-echarts-vue.umd.js"></script>`
19
+
20
+ //mkdirSync
21
+ if (!fs.existsSync(fdTar)) {
22
+ fs.mkdirSync(fdTar)
23
+ }
24
+
25
+ //getFiles
26
+ let ltfs = getFiles(fdSrc)
27
+
28
+ _.each(ltfs, function(v) {
29
+
30
+ //fn
31
+ let fn = fdSrc + v
32
+
33
+ //c
34
+ let c = fs.readFileSync(fn, 'utf8')
35
+
36
+ //replace
37
+ let r = `<script src="../dist/w-echarts-vue.umd.js"></script>`
38
+ c = c.replace(r, cdn)
39
+
40
+ //write
41
+ //console.log(c)
42
+ fs.writeFileSync(fdTar + v, c, 'utf8')
43
+
44
+ })
45
+
46
+ }
47
+ main()