main.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import {
  2. createApp
  3. } from "vue";
  4. import App from "./App.vue";
  5. import router from "./router";
  6. import store from "./store";
  7. import "font-awesome/css/font-awesome.min.css";
  8. // 引入 element-ui
  9. import ElementPlus from "element-plus";
  10. import 'windi.css'
  11. // 引入element 自定义css
  12. import 'element-plus/dist/index.css'
  13. import "./element-theme/index.scss";
  14. import locale from "element-plus/lib/locale/lang/zh-cn";
  15. import * as ElementPlusIconsVue from '@element-plus/icons-vue'
  16. import axios from 'axios'
  17. //引入字体
  18. import '../public/css/font.css'
  19. import { ElMessage } from 'element-plus'
  20. import './permission'
  21. const app = createApp(App)
  22. /**阻止多次重复点击指令 延时暂定5秒 示例 v-prevdbclick:arg='func' */
  23. const messageToast = () => { //作为eventListener时, 必须使用外部定义函数
  24. ElMessage.error('5秒内请勿重复点击')
  25. }
  26. const funListener = (el, binding) => {
  27. let time = null
  28. el.removeEventListener('click', messageToast)
  29. el.addEventListener('click', () => {
  30. binding.value()
  31. el.addEventListener('click', messageToast, false)
  32. time = setTimeout(() => {
  33. clearTimeout(time)
  34. funListener(el, binding)
  35. }, Number(binding.arg) || 5000)
  36. }, {
  37. once: true
  38. })
  39. }
  40. Date.prototype.formatDate = function (fmt) {
  41. let o = {
  42. "M+": this.getMonth() + 1, //月份
  43. "d+": this.getDate(), //日
  44. "h+": this.getHours(), //小时
  45. "m+": this.getMinutes(), //分
  46. "s+": this.getSeconds(), //秒
  47. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  48. "S": this.getMilliseconds() //毫秒
  49. };
  50. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  51. for (let k in o)
  52. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  53. return fmt;
  54. }
  55. app.directive('prevdbclick', {
  56. mounted(el, binding) {
  57. funListener(el, binding)
  58. }
  59. })
  60. for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  61. app.component(key, component)
  62. }
  63. app.config.globalProperties.$axios = axios;
  64. window.__STATICVUE__ = app;
  65. window.__STATICVUE__.use(ElementPlus, {
  66. locale
  67. });
  68. window.__STATICVUE__.use(store);
  69. window.__STATICVUE__.use(router);
  70. window.__STATICVUE__.mount('#app');