xiangpei
2024-04-07 b2ef755893a694ea07b7ca2f46e4571bbc8e9cb9
src/main.js
@@ -1,7 +1,7 @@
import Vue from 'vue'
import Cookies from 'js-cookie'
import { getToken } from "@/utils/auth";
import Element from 'element-ui'
import './assets/styles/element-variables.scss'
@@ -38,6 +38,15 @@
// 字典数据组件
import DictData from '@/components/DictData'
// 大屏
import VScaleScreen from 'v-scale-screen'
import dataV from '@jiaminghi/data-view'
import gsap from 'gsap';
import { formatNumber } from './utils/format';
// 全局方法挂载
Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey
@@ -48,6 +57,7 @@
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree
Vue.prototype.getToken = getToken
// 全局组件挂载
Vue.component('DictTag', DictTag)
@@ -61,6 +71,8 @@
Vue.use(directive)
Vue.use(plugins)
Vue.use(VueMeta)
Vue.use(VScaleScreen)
Vue.use(dataV)
DictData.install()
/**
@@ -78,6 +90,41 @@
Vue.config.productionTip = true
// 全局指令
Vue.directive('roll', {
  inserted: (el, binding) => {
    let target = {
      count: 0
    };
    let finalNumber = el.innerText;
    gsap.to(target, {
      count: finalNumber,
      duration: 1,
      ease: "power2.out",
      onUpdate: () => {
        el.innerText = formatNumber(target.count.toFixed(0));
      }
    })
  },
  update: (el, binding) => {
    let target = {
      count: el.innerText
    };
    let finalNumber = el.getAttribute('value');
    gsap.to(target, {
      count: finalNumber,
      duration: 1,
      ease: "power2.out",
      onUpdate: () => {
        el.innerText = formatNumber(target.count.toFixed(0));
      }
    })
  }
})
new Vue({
  el: '#app',
  router,