main.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 { QueryPermission } from './util/QueryPermission.js';
  13. Vue.prototype.$QueryPermission = QueryPermission;
  14. // 自定义卡片
  15. import customCard from './components/customCard/customCard.vue';
  16. Vue.component('customCard', customCard);
  17. import cuCustom from './components/customCard/cu-custom.vue';
  18. Vue.component('cu-custom', cuCustom);
  19. Vue.filter('timeFormat', function (time, fmt = 'yyyy-MM-dd hh:mm:ss') {
  20. function fun(a) {
  21. return String(a).length == 1 ? '0' + a : a;
  22. }
  23. let $this = new Date(time * 1000);
  24. let o = {
  25. 'M+': $this.getMonth() + 1,
  26. 'd+': $this.getDate(),
  27. 'h+': $this.getHours(),
  28. 'm+': $this.getMinutes(),
  29. 's+': $this.getSeconds(),
  30. 'q+': Math.floor(($this.getMonth() + 3) / 3),
  31. S: $this.getMilliseconds(),
  32. };
  33. if (/(y+)/.test(fmt)) {
  34. fmt = fmt.replace(
  35. RegExp.$1,
  36. ($this.getFullYear() + '').substr(4 - RegExp.$1.length),
  37. );
  38. }
  39. for (var k in o) {
  40. if (new RegExp('(' + k + ')').test(fmt)) {
  41. fmt = fmt.replace(
  42. RegExp.$1,
  43. RegExp.$1.length === 1
  44. ? o[k]
  45. : ('00' + o[k]).substr(('' + o[k]).length),
  46. );
  47. }
  48. }
  49. return fmt;
  50. });
  51. Vue.prototype.formatTime = function (thistime, fmt = 'yyyy-MM-dd hh:mm:ss') {
  52. let $this = new Date(thistime);
  53. let o = {
  54. 'M+': $this.getMonth() + 1,
  55. 'd+': $this.getDate(),
  56. 'h+': $this.getHours(),
  57. 'm+': $this.getMinutes(),
  58. 's+': $this.getSeconds(),
  59. 'q+': Math.floor(($this.getMonth() + 3) / 3),
  60. S: $this.getMilliseconds(),
  61. };
  62. if (/(y+)/.test(fmt)) {
  63. fmt = fmt.replace(
  64. RegExp.$1,
  65. ($this.getFullYear() + '').substr(4 - RegExp.$1.length),
  66. );
  67. }
  68. for (var k in o) {
  69. if (new RegExp('(' + k + ')').test(fmt)) {
  70. fmt = fmt.replace(
  71. RegExp.$1,
  72. RegExp.$1.length === 1
  73. ? o[k]
  74. : ('00' + o[k]).substr(('' + o[k]).length),
  75. );
  76. }
  77. }
  78. return fmt;
  79. };
  80. const app = new Vue({
  81. ...App,
  82. });
  83. app.$mount();