main.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import Vue from 'vue'
  2. import Cookies from 'js-cookie'
  3. import 'normalize.css/normalize.css'
  4. import Element from 'element-ui'
  5. import 'element-ui/lib/theme-chalk/display.css'
  6. import './styles/element-variables.scss'
  7. import '@/styles/index.scss'
  8. import App from './App'
  9. import store from './store'
  10. import router from './router'
  11. import './icons'
  12. import './permission'
  13. import './utils/error-log'
  14. // 窗口切换检测
  15. import visibility from 'vue-visibility-change'
  16. Vue.use(visibility)
  17. // 全局过滤器
  18. import * as filters from './filters'
  19. // 引入公共方法
  20. import common from './utils/common'
  21. Vue.use(common)
  22. // 引入vue-UUID组件
  23. import UUID from 'vue-uuid'
  24. Vue.use(UUID)
  25. // 浮点计算
  26. import calc from './utils/calc'
  27. Vue.prototype.$calc = calc
  28. // 页面打印
  29. import Print from 'vue-print-nb'
  30. Vue.use(Print)
  31. // 视频播放
  32. import Video from 'video.js'
  33. import 'video.js/dist/video-js.css'
  34. Vue.prototype.$video = Video
  35. // UI默认尺寸
  36. Vue.use(Element, {
  37. size: Cookies.get('size') || 'medium'
  38. })
  39. // 全局过滤器
  40. Object.keys(filters).forEach(key => {
  41. Vue.filter(key, filters[key])
  42. })
  43. // 禁止右键指令
  44. Vue.directive('preventright', {
  45. bind: function (el, binding, vnode) {
  46. el.oncontextmenu = function () { return false }
  47. }
  48. })
  49. Vue.config.productionTip = false
  50. /**
  51. * 对 Date 的扩展,将 Date 转化为指定格式的字符串
  52. * @param {String} fmt 传入一个字符串,根据所传字符串的格式返回转换后特定格式的日期。
  53. * 调用姿势:new Date().formatDate("yyyy-MM-dd hh:mm:ss");
  54. */
  55. Date.prototype.formatDate = function (fmt) {
  56. let o = {
  57. "M+": this.getMonth() + 1, //月份
  58. "d+": this.getDate(), //日
  59. "h+": this.getHours(), //小时
  60. "m+": this.getMinutes(), //分
  61. "s+": this.getSeconds(), //秒
  62. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  63. "S": this.getMilliseconds() //毫秒
  64. };
  65. if (/(y+)/.test(fmt)) {
  66. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  67. }
  68. for (let k in o) {
  69. if (new RegExp("(" + k + ")").test(fmt)) {
  70. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  71. }
  72. }
  73. return fmt;
  74. }
  75. new Vue({
  76. el: '#app',
  77. router,
  78. store,
  79. render: h => h(App)
  80. })