main.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import Vue from 'vue';
  2. import App from './App';
  3. import uView from 'uview-ui';
  4. Vue.use(uView);
  5. import { myRequest } from './util/api.js';
  6. Vue.prototype.$myRequest = myRequest;
  7. Vue.config.productionTip = false;
  8. App.mpType = 'app';
  9. import config from './util/neutral.js';
  10. Vue.prototype.$isneutral = config.isneutral;
  11. Vue.prototype.$imageURL = config.imageURL; // 线上图片服务器路径常量
  12. import {
  13. QueryPermission,
  14. ensurePermissionLoaded,
  15. fetchPermissionList,
  16. resetPermissionList,
  17. } from './util/QueryPermission.js';
  18. Vue.prototype.$QueryPermission = QueryPermission;
  19. Vue.prototype.$ensurePermissionLoaded = ensurePermissionLoaded;
  20. Vue.prototype.$fetchPermissionList = fetchPermissionList;
  21. Vue.prototype.$resetPermissionList = resetPermissionList;
  22. // 自定义卡片
  23. import customCard from './components/customCard/customCard.vue';
  24. Vue.component('customCard', customCard);
  25. import cuCustom from './components/customCard/cu-custom.vue';
  26. Vue.component('cu-custom', cuCustom);
  27. Vue.filter('timeFormat', function (time, fmt = 'yyyy-MM-dd hh:mm:ss') {
  28. function fun(a) {
  29. return String(a).length == 1 ? '0' + a : a;
  30. }
  31. let $this = new Date(time * 1000);
  32. let o = {
  33. 'M+': $this.getMonth() + 1,
  34. 'd+': $this.getDate(),
  35. 'h+': $this.getHours(),
  36. 'm+': $this.getMinutes(),
  37. 's+': $this.getSeconds(),
  38. 'q+': Math.floor(($this.getMonth() + 3) / 3),
  39. S: $this.getMilliseconds(),
  40. };
  41. if (/(y+)/.test(fmt)) {
  42. fmt = fmt.replace(
  43. RegExp.$1,
  44. ($this.getFullYear() + '').substr(4 - RegExp.$1.length),
  45. );
  46. }
  47. for (var k in o) {
  48. if (new RegExp('(' + k + ')').test(fmt)) {
  49. fmt = fmt.replace(
  50. RegExp.$1,
  51. RegExp.$1.length === 1
  52. ? o[k]
  53. : ('00' + o[k]).substr(('' + o[k]).length),
  54. );
  55. }
  56. }
  57. return fmt;
  58. });
  59. Vue.prototype.formatTime = function (thistime, fmt = 'yyyy-MM-dd hh:mm:ss') {
  60. let $this = new Date(thistime);
  61. let o = {
  62. 'M+': $this.getMonth() + 1,
  63. 'd+': $this.getDate(),
  64. 'h+': $this.getHours(),
  65. 'm+': $this.getMinutes(),
  66. 's+': $this.getSeconds(),
  67. 'q+': Math.floor(($this.getMonth() + 3) / 3),
  68. S: $this.getMilliseconds(),
  69. };
  70. if (/(y+)/.test(fmt)) {
  71. fmt = fmt.replace(
  72. RegExp.$1,
  73. ($this.getFullYear() + '').substr(4 - RegExp.$1.length),
  74. );
  75. }
  76. for (var k in o) {
  77. if (new RegExp('(' + k + ')').test(fmt)) {
  78. fmt = fmt.replace(
  79. RegExp.$1,
  80. RegExp.$1.length === 1
  81. ? o[k]
  82. : ('00' + o[k]).substr(('' + o[k]).length),
  83. );
  84. }
  85. }
  86. return fmt;
  87. };
  88. const app = new Vue({
  89. ...App,
  90. });
  91. app.$mount();