You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.7 KiB

8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
7 months ago
  1. import Vue from 'vue'
  2. import App from '@/App'
  3. import router from '@/router' // api: https://github.com/vuejs/vue-router
  4. import store from '@/store' // api: https://github.com/vuejs/vuex
  5. import VueCookie from 'vue-cookie' // api: https://github.com/alfhen/vue-cookie // 时间处理
  6. import dayjs from 'dayjs';
  7. import '@/element-ui' // api: https://github.com/ElemeFE/element
  8. import '@/icons' // api: http://www.iconfont.cn/
  9. import '@/element-ui-theme'
  10. import '@/assets/scss/index.scss'
  11. import httpRequest from '@/utils/httpRequest' // api: https://github.com/axios/axios
  12. import { isAuth } from '@/utils'
  13. import cloneDeep from 'lodash/cloneDeep'
  14. //import JsonExcel from 'vue-json-excel'
  15. import i18n from '@/i18n/i18n'
  16. import './utils/directives'
  17. import decimalUtil from '@/utils/decimalUtil.js'
  18. //import getLodop from '@/utils/LodopFuncs.js'
  19. //import pdf from 'vue-pdf'
  20. import { debounce,throttle} from '@/utils/common.js'
  21. import Vant from 'vant'
  22. import 'vant/lib/index.css'
  23. //Vue.component('downloadExcel', JsonExcel)
  24. //Vue.component('pdf', pdf)
  25. Vue.use(Vant)
  26. Vue.use(VueCookie)
  27. Vue.config.productionTip = false
  28. // 非生产环境, 适配mockjs模拟数据 // api: https://github.com/nuysoft/Mock
  29. if (process.env.NODE_ENV !== 'production') {
  30. require('@/mock')
  31. }
  32. // 挂载全局
  33. Vue.prototype.$http = httpRequest // ajax请求方法
  34. Vue.prototype.isAuth = isAuth // 权限方法
  35. //Vue.prototype.getLodop = getLodop // 打印
  36. Vue.prototype.decimalUtil = decimalUtil // 计算
  37. Vue.prototype.dayjs = dayjs //时间格式化插件 2021-11-02
  38. Vue.prototype.debounce = debounce // 防抖
  39. Vue.prototype.throttle = throttle // 限流
  40. // 组件预加载
  41. router.beforeResolve((to, from, next) => {
  42. const matched = router.getMatchedComponents(to)
  43. Promise.all(matched.map(c => {
  44. if (typeof c === 'function') return c()
  45. return Promise.resolve()
  46. })).then(next)
  47. })
  48. // 保存整站vuex本地储存初始状态
  49. window.SITE_CONFIG['storeState'] = cloneDeep(store.state)
  50. /* eslint-disable no-new */
  51. new Vue({
  52. el: '#app',
  53. router,
  54. i18n,
  55. store,
  56. template: '<App/>',
  57. components: { App }
  58. })
  59. // 防止按钮连续点击,则在el-button加上v-prevent-re-click
  60. // 例如: <el-button v-prevent-re-click @click="searchTable()" type="primary">{{'查询'}}</el-button>
  61. Vue.directive('prevent-re-click', {
  62. inserted (el, binding) {
  63. el.addEventListener('click', () => {
  64. if (!el.disabled) {
  65. el.disabled = true; // 禁用按钮
  66. setTimeout(() => {
  67. el.disabled = false; // 恢复按钮
  68. }, binding.value || 1000); // 默认1秒,可自定义
  69. }
  70. });
  71. }
  72. });