Commit eaa179a396670f17a555d992dedd4d2891e3f817
1 parent
d08ebdff
chore: 使用v-chart cdn 以减小构建体积
Showing
9 changed files
with
31 additions
and
25 deletions
back-end/h5-api/views/engine.ejs
| ... | ... | @@ -19,11 +19,16 @@ |
| 19 | 19 | <meta content="black" name="apple-mobile-web-app-status-bar-style"> |
| 20 | 20 | <meta content="telephone=no" name="format-detection"> |
| 21 | 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 | 32 | <script>window.__work = <%- JSON.stringify(work) %></script> |
| 28 | 33 | <script src="/engine-assets/engine.umd.min.js"></script> |
| 29 | 34 | <style> | ... | ... |
front-end/h5/public/index.html
| ... | ... | @@ -25,6 +25,10 @@ |
| 25 | 25 | </style> |
| 26 | 26 | <!-- <script src="https://code.createjs.com/1.0.0/createjs.min.js"></script> --> |
| 27 | 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 | 32 | <script> |
| 29 | 33 | // Note: 增加html userAgent标记, |
| 30 | 34 | // windows启用下仿mac的滚动条样式。 | ... | ... |
front-end/h5/src/components/core/plugins/charts/chart-mixin.js
front-end/h5/src/components/core/plugins/charts/chart-model.js
| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | * TODO X轴 formatter:1.只针对 X轴,不针对 tooltip 2. tooltip 和 X轴同时生效 |
| 6 | 6 | * TODO legend(series) 到多Y轴的映射 |
| 7 | 7 | */ |
| 8 | -import _ from 'lodash' | |
| 8 | +import { uniqBy } from 'lodash' | |
| 9 | 9 | |
| 10 | 10 | export class LineChart { |
| 11 | 11 | constructor ({ xAxis = [], yIndexMap = {}, dataset }) { |
| ... | ... | @@ -65,7 +65,7 @@ export class LineChart { |
| 65 | 65 | */ |
| 66 | 66 | getLegends () { |
| 67 | 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 | 69 | const legends = Array.from(new Set(allLegends)) |
| 70 | 70 | return legends |
| 71 | 71 | } | ... | ... |
front-end/h5/src/components/core/plugins/charts/chart-model.ts
| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | * TODO X轴 formatter:1.只针对 X轴,不针对 tooltip 2. tooltip 和 X轴同时生效 |
| 6 | 6 | * TODO legend(series) 到多Y轴的映射 |
| 7 | 7 | */ |
| 8 | -import _ from "lodash"; | |
| 8 | +import { uniqBy } from "lodash"; | |
| 9 | 9 | // import numeral from "numeral"; |
| 10 | 10 | |
| 11 | 11 | /** |
| ... | ... | @@ -249,7 +249,7 @@ export class LineChart { |
| 249 | 249 | */ |
| 250 | 250 | getLegends(): string[] { |
| 251 | 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 | 253 | (item: uniqByResultType) => item[legendKey] |
| 254 | 254 | ); |
| 255 | 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 | 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 | 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 | 12 | // const title = str => str.slice(0, 1).toUpperCase() + str.slice(1) |
| 14 | 13 | |
| 15 | 14 | export default { | ... | ... |
front-end/h5/src/components/core/plugins/lbp-form-button.js
| 1 | 1 | // https://github.com/luban-h5-components/plugin-common-props |
| 2 | 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 | 6 | export default { |
| 5 | 7 | render () { |
| ... | ... | @@ -55,14 +57,13 @@ export default { |
| 55 | 57 | // #!zh: data-type=lbp-form-input 在 lbp-form-input 组件中定义 |
| 56 | 58 | let inputs = document.querySelectorAll("[data-type^='lbp-form-input']") |
| 57 | 59 | if (!inputs.length) return |
| 58 | - const self = this | |
| 59 | 60 | let formData = new FormData() |
| 60 | 61 | inputs.forEach(input => formData.append(input.dataset.uuid, input.value)) |
| 61 | 62 | const req = new XMLHttpRequest() |
| 62 | 63 | req.onreadystatechange = function () { |
| 63 | 64 | if (req.readyState === 4) { |
| 64 | 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 | 14 | */ |
| 15 | 15 | |
| 16 | 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 | 18 | import { pluginsList } from 'core/plugins/index.js' |
| 22 | 19 | import { PAGE_MODE } from 'core/constants/work.js' |
| ... | ... | @@ -25,7 +22,6 @@ import RenderPreview from 'core/editor/canvas/preview' |
| 25 | 22 | import NodeWrapper from 'core/preview/node-wrapper.js' |
| 26 | 23 | |
| 27 | 24 | Vue.config.productionTip = true |
| 28 | -Vue.prototype.$message = message | |
| 29 | 25 | |
| 30 | 26 | const Engine = { |
| 31 | 27 | name: 'engine', | ... | ... |