main.js 2.7 KB

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