Commit eaa179a396670f17a555d992dedd4d2891e3f817

Authored by ly525
1 parent d08ebdff

chore: 使用v-chart cdn 以减小构建体积

back-end/h5-api/views/engine.ejs
@@ -19,11 +19,16 @@ @@ -19,11 +19,16 @@
19 <meta content="black" name="apple-mobile-web-app-status-bar-style"> 19 <meta content="black" name="apple-mobile-web-app-status-bar-style">
20 <meta content="telephone=no" name="format-detection"> 20 <meta content="telephone=no" name="format-detection">
21 <meta content="email=no" name="format-detection"> 21 <meta content="email=no" name="format-detection">
22 - <script src="/third-libs/vue.js"></script>  
23 - <link rel="stylesheet" href="/third-libs/animate.min.css">  
24 - <link rel="stylesheet" href="/third-libs/swiper.min.css">  
25 - <script src="/third-libs/swiper.min.js"></script>  
26 - <script src="/third-libs/swiper-animation.umd.min.js"></script> 22 + <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  23 + <script src="https://cdn.jsdelivr.net/npm/vuex/dist/vuex.js"></script>
  24 + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@4.1.1/animate.min.css">
  25 + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper/dist/css/swiper.min.css">
  26 + <script src="https://cdn.jsdelivr.net/npm/swiper/dist/js/swiper.min.js"></script>
  27 + <script src="https://cdn.jsdelivr.net/npm/swiper-animation@2.0.2/build/swiper-animation.min.js"></script>
  28 + <!-- <script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js" async></script> -->
  29 + <script src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
  30 +<script src="https://cdn.jsdelivr.net/npm/v-charts/lib/index.min.js"></script>
  31 +<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/v-charts/lib/style.min.css">
27 <script>window.__work = <%- JSON.stringify(work) %></script> 32 <script>window.__work = <%- JSON.stringify(work) %></script>
28 <script src="/engine-assets/engine.umd.min.js"></script> 33 <script src="/engine-assets/engine.umd.min.js"></script>
29 <style> 34 <style>
front-end/h5/public/index.html
@@ -25,6 +25,10 @@ @@ -25,6 +25,10 @@
25 </style> 25 </style>
26 <!-- <script src="https://code.createjs.com/1.0.0/createjs.min.js"></script> --> 26 <!-- <script src="https://code.createjs.com/1.0.0/createjs.min.js"></script> -->
27 <script src="https://cdn.jsdelivr.net/npm/createjs@1.0.1/builds/1.0.0/createjs.min.js" async></script> 27 <script src="https://cdn.jsdelivr.net/npm/createjs@1.0.1/builds/1.0.0/createjs.min.js" async></script>
  28 + <!-- <script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js" async></script> -->
  29 + <script src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
  30 + <script src="https://cdn.jsdelivr.net/npm/v-charts/lib/index.min.js"></script>
  31 + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/v-charts/lib/style.min.css">
28 <script> 32 <script>
29 // Note: 增加html userAgent标记, 33 // Note: 增加html userAgent标记,
30 // windows启用下仿mac的滚动条样式。 34 // windows启用下仿mac的滚动条样式。
front-end/h5/src/components/core/plugins/charts/chart-mixin.js
1 -import echarts from 'echarts/lib/echarts'  
2 import debounce from 'lodash/debounce' 1 import debounce from 'lodash/debounce'
3 import { addListener, removeListener } from 'resize-detector' 2 import { addListener, removeListener } from 'resize-detector'
4 import { LineChart } from './chart-model' 3 import { LineChart } from './chart-model'
front-end/h5/src/components/core/plugins/charts/chart-model.js
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 * TODO X轴 formatter:1.只针对 X轴,不针对 tooltip 2. tooltip 和 X轴同时生效 5 * TODO X轴 formatter:1.只针对 X轴,不针对 tooltip 2. tooltip 和 X轴同时生效
6 * TODO legend(series) 到多Y轴的映射 6 * TODO legend(series) 到多Y轴的映射
7 */ 7 */
8 -import _ from 'lodash' 8 +import { uniqBy } from 'lodash'
9 9
10 export class LineChart { 10 export class LineChart {
11 constructor ({ xAxis = [], yIndexMap = {}, dataset }) { 11 constructor ({ xAxis = [], yIndexMap = {}, dataset }) {
@@ -65,7 +65,7 @@ export class LineChart { @@ -65,7 +65,7 @@ export class LineChart {
65 */ 65 */
66 getLegends () { 66 getLegends () {
67 const legendKey = this.keys.legend 67 const legendKey = this.keys.legend
68 - const allLegends = _.uniqBy(this.dataset, legendKey).map((item) => item[legendKey]) 68 + const allLegends = uniqBy(this.dataset, legendKey).map((item) => item[legendKey])
69 const legends = Array.from(new Set(allLegends)) 69 const legends = Array.from(new Set(allLegends))
70 return legends 70 return legends
71 } 71 }
front-end/h5/src/components/core/plugins/charts/chart-model.ts
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 * TODO X轴 formatter:1.只针对 X轴,不针对 tooltip 2. tooltip 和 X轴同时生效 5 * TODO X轴 formatter:1.只针对 X轴,不针对 tooltip 2. tooltip 和 X轴同时生效
6 * TODO legend(series) 到多Y轴的映射 6 * TODO legend(series) 到多Y轴的映射
7 */ 7 */
8 -import _ from "lodash"; 8 +import { uniqBy } from "lodash";
9 // import numeral from "numeral"; 9 // import numeral from "numeral";
10 10
11 /** 11 /**
@@ -249,7 +249,7 @@ export class LineChart { @@ -249,7 +249,7 @@ export class LineChart {
249 */ 249 */
250 getLegends(): string[] { 250 getLegends(): string[] {
251 const legendKey = this.keys.legend; 251 const legendKey = this.keys.legend;
252 - const allLegends: string[] = _.uniqBy(this.dataset, legendKey).map( 252 + const allLegends: string[] = uniqBy(this.dataset, legendKey).map(
253 (item: uniqByResultType) => item[legendKey] 253 (item: uniqByResultType) => item[legendKey]
254 ); 254 );
255 const legends: string[] = Array.from(new Set(allLegends)); 255 const legends: string[] = Array.from(new Set(allLegends));
front-end/h5/src/components/core/plugins/charts/line.js
1 -import VeLine from 'v-charts/lib/line.common'  
2 -import VeRadar from 'v-charts/lib/radar.common'  
3 -import VePie from 'v-charts/lib/pie.common'  
4 -import VeHistogram from 'v-charts/lib/histogram.common'  
5 -import VeFunnel from 'v-charts/lib/funnel.common'  
6 import PropTypes from '@luban-h5/plugin-common-props' 1 import PropTypes from '@luban-h5/plugin-common-props'
7 -import 'echarts/lib/component/legend'  
8 -import 'echarts/lib/component/markLine'  
9 -import 'echarts/lib/component/markPoint'  
10 -import 'echarts/lib/component/markArea'  
11 import Parser from '@/utils/excel-parser' 2 import Parser from '@/utils/excel-parser'
12 3
  4 +const {
  5 + VeLine,
  6 + VeRadar,
  7 + VePie,
  8 + VeHistogram,
  9 + VeFunnel
  10 +} = window.VeIndex
  11 +
13 // const title = str => str.slice(0, 1).toUpperCase() + str.slice(1) 12 // const title = str => str.slice(0, 1).toUpperCase() + str.slice(1)
14 13
15 export default { 14 export default {
front-end/h5/src/components/core/plugins/lbp-form-button.js
1 // https://github.com/luban-h5-components/plugin-common-props 1 // https://github.com/luban-h5-components/plugin-common-props
2 import PropTypes from '@luban-h5/plugin-common-props' 2 import PropTypes from '@luban-h5/plugin-common-props'
  3 +import Toast from 'vant/lib/toast'
  4 +import 'vant/lib/toast/style'
3 5
4 export default { 6 export default {
5 render () { 7 render () {
@@ -55,14 +57,13 @@ export default { @@ -55,14 +57,13 @@ export default {
55 // #!zh: data-type=lbp-form-input 在 lbp-form-input 组件中定义 57 // #!zh: data-type=lbp-form-input 在 lbp-form-input 组件中定义
56 let inputs = document.querySelectorAll("[data-type^='lbp-form-input']") 58 let inputs = document.querySelectorAll("[data-type^='lbp-form-input']")
57 if (!inputs.length) return 59 if (!inputs.length) return
58 - const self = this  
59 let formData = new FormData() 60 let formData = new FormData()
60 inputs.forEach(input => formData.append(input.dataset.uuid, input.value)) 61 inputs.forEach(input => formData.append(input.dataset.uuid, input.value))
61 const req = new XMLHttpRequest() 62 const req = new XMLHttpRequest()
62 req.onreadystatechange = function () { 63 req.onreadystatechange = function () {
63 if (req.readyState === 4) { 64 if (req.readyState === 4) {
64 const message = req.status === 200 ? '提交成功' : '提交失败' 65 const message = req.status === 200 ? '提交成功' : '提交失败'
65 - self.$message.info(message) 66 + Toast(message)
66 } 67 }
67 } 68 }
68 69
front-end/h5/src/engine-entry.js
@@ -14,9 +14,6 @@ @@ -14,9 +14,6 @@
14 */ 14 */
15 15
16 import Vue from 'vue' 16 import Vue from 'vue'
17 -// import 'font-awesome/css/font-awesome.min.css'  
18 -import message from 'ant-design-vue/lib/message' // 加载 JS  
19 -import 'ant-design-vue/lib/message/style/css' // 加载 CSS  
20 17
21 import { pluginsList } from 'core/plugins/index.js' 18 import { pluginsList } from 'core/plugins/index.js'
22 import { PAGE_MODE } from 'core/constants/work.js' 19 import { PAGE_MODE } from 'core/constants/work.js'
@@ -25,7 +22,6 @@ import RenderPreview from &#39;core/editor/canvas/preview&#39; @@ -25,7 +22,6 @@ import RenderPreview from &#39;core/editor/canvas/preview&#39;
25 import NodeWrapper from 'core/preview/node-wrapper.js' 22 import NodeWrapper from 'core/preview/node-wrapper.js'
26 23
27 Vue.config.productionTip = true 24 Vue.config.productionTip = true
28 -Vue.prototype.$message = message  
29 25
30 const Engine = { 26 const Engine = {
31 name: 'engine', 27 name: 'engine',
front-end/h5/vue.config.js
@@ -55,6 +55,8 @@ const configureWebpack = { @@ -55,6 +55,8 @@ const configureWebpack = {
55 new webpack.ContextReplacementPlugin(/moment\/locale$/, /(zh-cn)$/) 55 new webpack.ContextReplacementPlugin(/moment\/locale$/, /(zh-cn)$/)
56 ], 56 ],
57 externals: { 57 externals: {
  58 + echarts: 'echarts',
  59 + VeIndex: 'echarts'
58 } 60 }
59 } 61 }
60 62