Selaa lähdekoodia

feat:兼容登录按钮

jinx 4 vuotta sitten
vanhempi
commit
866485259a
3 muutettua tiedostoa jossa 139 lisäystä ja 1 poistoa
  1. 5 0
      IndoorViewerAPI.js
  2. 125 0
      bus/bus.js
  3. 9 1
      js/popindoorAPI2.7.1.js

+ 5 - 0
IndoorViewerAPI.js

@@ -61686,6 +61686,8 @@ and limitations under the License.
                     return r(this, (function(e) {
                         switch (e.label) {
                         case 0:
+							//window.eventBus.emit('my-event');
+							$('sidebar-menu-item li').has('span[data-original-title="控制点"]').show()
                             return this.JWTTokenService.saveJwt(t.token),
                             this.currentUser = this.UserRepository.create(),
                             this.currentUser.fillFromData(t.principal),
@@ -61777,6 +61779,8 @@ and limitations under the License.
             this.loggedInWithToken = !1,
             this.clearRefreshTimers(),
             this.fetchCurrentUser().then((function() {
+				$('sidebar-menu-item li').has('span[data-original-title="控制点"]').hide()
+			
                 return t.sendAuthenticationChanged()
             }
             ))
@@ -61808,6 +61812,7 @@ and limitations under the License.
             var t = this;
             this.isDataAccessible().then((function(e) {
                 t.onAuthenticationChanged.emit(t.currentUser, e)
+			
             }
             )).catch(s.handleWarning)
         }

+ 125 - 0
bus/bus.js

@@ -0,0 +1,125 @@
+(function(caller, bus) {
+    if (typeof exports === "object" && typeof module === "object") {
+        module.exports = bus();
+        module.exports.default = module.exports
+    } else if (typeof exports === "object") {
+        exports.EventBus = bus()
+    } else {
+        caller.EventBus = bus()
+    }
+})(this, function() {
+    var EventBus = function() {
+        this.listeners = {};
+        this.registerListener = function(event, callback, number) {
+            var type = event.constructor.name;
+            number = this.validateNumber(number || "any");
+            if (type !== "Array") {
+                event = [event]
+            }
+            event.forEach(function(e) {
+                if (e.constructor.name !== "String") {
+                    throw new Error("Only `String` and array of `String` are accepted for the event names!")
+                }
+                that.listeners[e] = that.listeners[e] || [];
+                that.listeners[e].push({
+                    callback: callback,
+                    number: number
+                })
+            })
+        };
+        this.validateNumber = function(n) {
+            var type = n.constructor.name;
+            if (type === "Number") {
+                return n
+            } else if (type === "String" && n.toLowerCase() === "any") {
+                return "any"
+            }
+            throw new Error("Only `Number` and `any` are accepted in the number of possible executions!")
+        };
+        this.toBeRemoved = function(info) {
+            var number = info.number;
+            info.execution = info.execution || 0;
+            info.execution++;
+            if (number === "any" || info.execution < number) {
+                return false
+            }
+            return true
+        };
+        var that = this;
+        return {
+            on: function(eventName, callback) {
+                that.registerListener.bind(that)(eventName, callback, "any")
+            },
+            once: function(eventName, callback) {
+                that.registerListener.bind(that)(eventName, callback, 1)
+            },
+            exactly: function(number, eventName, callback) {
+                that.registerListener.bind(that)(eventName, callback, number)
+            },
+            die: function(eventName) {
+                delete that.listeners[eventName]
+            },
+            off: function(eventName) {
+                this.die(eventName)
+            },
+            detach: function(eventName, callback) {
+                if (callback === undefined) {
+                    that.listeners[eventName] = [];
+                    return true
+                }
+                for (var k in that.listeners[eventName]) {
+                    if (that.listeners[eventName].hasOwnProperty(k) && that.listeners[eventName][k].callback === callback) {
+                        that.listeners[eventName].splice(k, 1);
+                        return this.detach(eventName, callback)
+                    }
+                }
+                return true
+            },
+            detachAll: function() {
+                for (var eventName in that.listeners) {
+                    if (that.listeners.hasOwnProperty(eventName)) {
+                        this.detach(eventName)
+                    }
+                }
+            },
+            emit: function(eventName, context) {
+                var listeners = [];
+                for (var name in that.listeners) {
+                    if (that.listeners.hasOwnProperty(name)) {
+                        if (name === eventName) {
+                            Array.prototype.push.apply(listeners, that.listeners[name])
+                        }
+                        if (name.indexOf("*") >= 0) {
+                            var newName = name.replace(/\*\*/, "([^.]+.?)+");
+                            newName = newName.replace(/\*/g, "[^.]+");
+                            var match = eventName.match(newName);
+                            if (match && eventName === match[0]) {
+                                Array.prototype.push.apply(listeners, that.listeners[name])
+                            }
+                        }
+                    }
+                }
+                var parentArgs = arguments;
+                context = context || this;
+                listeners.forEach(function(info, index) {
+                    var callback = info.callback;
+                    var number = info.number;
+                    if (context) {
+                        callback = callback.bind(context)
+                    }
+                    var args = [];
+                    Object.keys(parentArgs).map(function(i) {
+                        if (i > 1) {
+                            args.push(parentArgs[i])
+                        }
+                    });
+                    if (that.toBeRemoved(info)) {
+                        that.listeners[eventName].splice(index, 1)
+                    }
+                    callback.apply(null, args)
+                })
+            }
+        }
+    };
+    return EventBus
+});

+ 9 - 1
js/popindoorAPI2.7.1.js

@@ -934,6 +934,8 @@ var Setting = function() {
     var userService = IV.injector.get("UserService");
     var general_setting = null;
     var main_view = IV.getMainView();
+    console.log('!!!!!!!!!!!!!!!!!!!!!!!')
+    console.log(main_view)
     var main_scene = main_view.scene;
     var map_view = IV.getMapView();
     var map_scene = map_view.scene;
@@ -980,7 +982,11 @@ var Setting = function() {
         }
 
         load_menu();
-
+        window.eventBus = new EventBus();
+        // window.eventBus.on('my-event', function() {
+        //     alert(1)
+        //     load_menu();
+        // });
     }
 
     IV.custom.settingOnload = function() { //这个方法每次打开侧边菜单栏执行
@@ -1039,4 +1045,6 @@ var Setting = function() {
 
     };
 
+
+
 };