Преглед изворни кода

fix: 增加全局获取重置的方法

leo пре 1 недеља
родитељ
комит
fca72ddcb3
1 измењених фајлова са 51 додато и 39 уклоњено
  1. 51 39
      main.js

+ 51 - 39
main.js

@@ -10,12 +10,20 @@ Vue.config.productionTip = false;
 App.mpType = 'app';
 
 import config from './util/neutral.js';
-Vue.prototype.$imageHost = config.imageHost;// 线上图片服务器路径常量 58003
+Vue.prototype.$imageHost = config.imageHost; // 线上图片服务器路径常量 58003
 Vue.prototype.$imageURL = config.imageURL;
-console.log(Vue.prototype)
-import { QueryPermission } from './util/QueryPermission.js';
+console.log(Vue.prototype);
+import {
+  QueryPermission,
+  ensurePermissionLoaded,
+  fetchPermissionList,
+  resetPermissionList,
+} from './util/QueryPermission.js';
 // Vue.use(QueryPermission)
 Vue.prototype.$QueryPermission = QueryPermission;
+Vue.prototype.$ensurePermissionLoaded = ensurePermissionLoaded;
+Vue.prototype.$fetchPermissionList = fetchPermissionList;
+Vue.prototype.$resetPermissionList = resetPermissionList;
 
 import customCard from './components/customCard/customCard.vue';
 Vue.component('customCard', customCard);
@@ -23,12 +31,12 @@ Vue.component('customCard', customCard);
 import cuCustom from './components/customCard/cu-custom.vue';
 Vue.component('cu-custom', cuCustom);
 
-Vue.filter('timeFormat', function (time,fmt = 'yyyy-MM-dd hh:mm:ss') {
-  if(!time)return '';
+Vue.filter('timeFormat', function (time, fmt = 'yyyy-MM-dd hh:mm:ss') {
+  if (!time) return '';
   function fun(a) {
     return String(a).length == 1 ? '0' + a : a;
   }
-  let $this = new Date(time*1000);
+  let $this = new Date(time * 1000);
   let o = {
     'M+': $this.getMonth() + 1,
     'd+': $this.getDate(),
@@ -41,14 +49,16 @@ Vue.filter('timeFormat', function (time,fmt = 'yyyy-MM-dd hh:mm:ss') {
   if (/(y+)/.test(fmt)) {
     fmt = fmt.replace(
       RegExp.$1,
-      ($this.getFullYear() + '').substr(4 - RegExp.$1.length)
+      ($this.getFullYear() + '').substr(4 - RegExp.$1.length),
     );
   }
   for (var k in o) {
     if (new RegExp('(' + k + ')').test(fmt)) {
       fmt = fmt.replace(
         RegExp.$1,
-        RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)
+        RegExp.$1.length === 1
+          ? o[k]
+          : ('00' + o[k]).substr(('' + o[k]).length),
       );
     }
   }
@@ -69,14 +79,16 @@ Vue.prototype.formatTime = function (thistime, fmt = 'yyyy-MM-dd hh:mm:ss') {
   if (/(y+)/.test(fmt)) {
     fmt = fmt.replace(
       RegExp.$1,
-      ($this.getFullYear() + '').substr(4 - RegExp.$1.length)
+      ($this.getFullYear() + '').substr(4 - RegExp.$1.length),
     );
   }
   for (var k in o) {
     if (new RegExp('(' + k + ')').test(fmt)) {
       fmt = fmt.replace(
         RegExp.$1,
-        RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)
+        RegExp.$1.length === 1
+          ? o[k]
+          : ('00' + o[k]).substr(('' + o[k]).length),
       );
     }
   }
@@ -88,37 +100,37 @@ Vue.mixin({
       $imageURL: Vue.prototype.$imageURL,
       $imageHost: Vue.prototype.$imageHost,
       // 其他需要混入的全局变量
-	  shareTitle: '',
-	        sharePath: '',
-	        shareImage: '',
-	        timelineTitle: '',
-	        timelineQuery: '',
-	        timelineImage: ''
+      shareTitle: '',
+      sharePath: '',
+      shareImage: '',
+      timelineTitle: '',
+      timelineQuery: '',
+      timelineImage: '',
+    };
+  },
+  onLoad() {
+    // 开启分享功能
+    uni.showShareMenu({
+      withShareTicket: true,
+      menus: ['shareAppMessage', 'shareTimeline'],
+    });
+  },
+
+  onShareAppMessage() {
+    return {
+      title: this.shareTitle || 'AI 诊病虫,智控赋新农~',
+      path: this.sharePath || '/pages/index/index',
+      imageUrl: this.shareImage || '',
+    };
+  },
+
+  onShareTimeline() {
+    return {
+      title: this.timelineTitle || 'AI 诊病虫,智控赋新农~',
+      query: this.timelineQuery || '',
+      imageUrl: this.timelineImage || '',
     };
   },
-    onLoad() {
-      // 开启分享功能
-      uni.showShareMenu({
-        withShareTicket: true,
-        menus: ['shareAppMessage', 'shareTimeline']
-      })
-    },
-    
-    onShareAppMessage() {
-      return {
-        title: this.shareTitle || 'AI 诊病虫,智控赋新农~',
-        path: this.sharePath || '/pages/index/index',
-        imageUrl: this.shareImage || ''
-      }
-    },
-    
-    onShareTimeline() {
-      return {
-        title: this.timelineTitle || 'AI 诊病虫,智控赋新农~',
-        query: this.timelineQuery || '',
-        imageUrl: this.timelineImage || ''
-      }
-    },
   // 如果需要,也可以在created中赋值,但上面这样直接赋值也可以,因为mixin的data会在每个组件创建时合并
   // 但是注意,如果这些值在运行时改变,那么这种方式可能不会更新,因为data只初始化一次。如果需要在运行时响应变化,可以使用计算属性。
   // 另一种方式是用计算属性: