Commit a4419cbf authored by wanli's avatar wanli

修复若干bug

parent 7edb84c9
''' '''
Author: your name Author: your name
Date: 2021-06-29 19:33:41 Date: 2021-06-29 19:33:41
LastEditTime: 2021-07-05 16:53:48 LastEditTime: 2021-07-05 18:56:38
LastEditors: Please set LastEditors LastEditors: Please set LastEditors
Description: In User Settings Edit Description: In User Settings Edit
FilePath: \evm-store\backend\view\monitor.py FilePath: \evm-store\backend\view\monitor.py
...@@ -32,7 +32,8 @@ def secs2datetime(ts): ...@@ -32,7 +32,8 @@ def secs2datetime(ts):
return datetime.fromtimestamp(ts) return datetime.fromtimestamp(ts)
class ObjectDict(dict): class ObjectDict(dict):
"""Makes a dictionary behave like an object, with attribute-style access. """
Makes a dictionary behave like an object, with attribute-style access.
""" """
def __getattr__(self, name): def __getattr__(self, name):
try: try:
...@@ -80,7 +81,7 @@ def pushmessage(func): ...@@ -80,7 +81,7 @@ def pushmessage(func):
try: try:
if isinstance(msg, WebsocketResponse) or isinstance(msg, dict): if isinstance(msg, WebsocketResponse) or isinstance(msg, dict):
self.write_message(json.dumps(msg), binary) self.write_message(json.dumps(msg), binary)
elif isinstance(msg, str) or isinstance(msg, str): elif isinstance(msg, str):
self.write_message(msg, binary) self.write_message(msg, binary)
else: else:
self.write_message(repr(msg), binary) self.write_message(repr(msg), binary)
...@@ -120,25 +121,26 @@ class BaseWebsocket(WebSocketHandler): ...@@ -120,25 +121,26 @@ class BaseWebsocket(WebSocketHandler):
logger.warning("websocket of %s is closed" % className) logger.warning("websocket of %s is closed" % className)
if className in self.handlers and self in self.handlers[className]: if className in self.handlers and self in self.handlers[className]:
# 更加健壮的处理是,这里需要增加一个self是否存在的判断 # 更加健壮的处理是,这里需要增加一个self是否存在的判断
# logger.info(self.handlers[className])
# logger.info(id(self))
self.handlers[className].remove(self) self.handlers[className].remove(self)
for i, c in enumerate(self._clients):
if id(self) == id(c.get("context")):
del self._clients[i]
def check_origin(self, origin): def check_origin(self, origin):
logger.info(origin) logger.info(origin)
return True return True
@classmethod @classmethod
def broadcastMessage(cls, message, binary=False): def broadcastMessage(cls, message):
pprint.pprint(cls.handlers) # pprint.pprint(cls.handlers)
# pprint.pprint(message)
if not message.get("imei"): if not message.get("imei"):
return False return False
for item in cls._clients: for item in cls._clients:
if message.get("imei") in item.get("devices", []): if message.get("imei") in item.get("devices", []):
item.get("context").send(json.dumps(message), binary) item.get("context").write_message(json.dumps(message))
# item.get("context").write_message(json.dumps(message))
# className = cls.__name__ # className = cls.__name__
# message = json.dumps(message) # message = json.dumps(message)
...@@ -162,7 +164,6 @@ class NotifyHandler(BaseWebsocket): ...@@ -162,7 +164,6 @@ class NotifyHandler(BaseWebsocket):
def on_message(self, message): def on_message(self, message):
try: try:
className = self.__class__.__name__ className = self.__class__.__name__
logger.info(message)
message = json.loads(message) message = json.loads(message)
# 判断消息类型 # 判断消息类型
if message.get("type"): if message.get("type"):
...@@ -220,7 +221,6 @@ class NotifyHandler(BaseWebsocket): ...@@ -220,7 +221,6 @@ class NotifyHandler(BaseWebsocket):
del self._clients[i] del self._clients[i]
className = self.__class__.__name__ className = self.__class__.__name__
if self.handlers.get(className, None) and self in self.handlers[className]: if self.handlers.get(className, None) and self in self.handlers[className]:
logger.info(self.handlers[className])
self.handlers[className].remove(self) self.handlers[className].remove(self)
self._timer = Timer(1, self.on_heartbeat) self._timer = Timer(1, self.on_heartbeat)
......
...@@ -433,7 +433,7 @@ ...@@ -433,7 +433,7 @@
<div class="dropdown" v-show="userShow" style="right: 20px;"> <div class="dropdown" v-show="userShow" style="right: 20px;">
<ul> <ul>
<li @click="redirectTo('/profile')"> <li @click="redirectTo('/profile/index')">
<i aria-label="图标: user" class="webicon"> <i aria-label="图标: user" class="webicon">
<svg viewBox="64 64 896 896" data-icon="user" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false"><path d="M858.5 763.6a374 374 0 0 0-80.6-119.5 375.63 375.63 0 0 0-119.5-80.6c-.4-.2-.8-.3-1.2-.5C719.5 518 760 444.7 760 362c0-137-111-248-248-248S264 225 264 362c0 82.7 40.5 156 102.8 201.1-.4.2-.8.3-1.2.5-44.8 18.9-85 46-119.5 80.6a375.63 375.63 0 0 0-80.6 119.5A371.7 371.7 0 0 0 136 901.8a8 8 0 0 0 8 8.2h60c4.4 0 7.9-3.5 8-7.8 2-77.2 33-149.5 87.8-204.3 56.7-56.7 132-87.9 212.2-87.9s155.5 31.2 212.2 87.9C779 752.7 810 825 812 902.2c.1 4.4 3.6 7.8 8 7.8h60a8 8 0 0 0 8-8.2c-1-47.8-10.9-94.3-29.5-138.2zM512 534c-45.9 0-89.1-17.9-121.6-50.4S340 407.9 340 362c0-45.9 17.9-89.1 50.4-121.6S466.1 190 512 190s89.1 17.9 121.6 50.4S684 316.1 684 362c0 45.9-17.9 89.1-50.4 121.6S557.9 534 512 534z"></path></svg> <svg viewBox="64 64 896 896" data-icon="user" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false"><path d="M858.5 763.6a374 374 0 0 0-80.6-119.5 375.63 375.63 0 0 0-119.5-80.6c-.4-.2-.8-.3-1.2-.5C719.5 518 760 444.7 760 362c0-137-111-248-248-248S264 225 264 362c0 82.7 40.5 156 102.8 201.1-.4.2-.8.3-1.2.5-44.8 18.9-85 46-119.5 80.6a375.63 375.63 0 0 0-80.6 119.5A371.7 371.7 0 0 0 136 901.8a8 8 0 0 0 8 8.2h60c4.4 0 7.9-3.5 8-7.8 2-77.2 33-149.5 87.8-204.3 56.7-56.7 132-87.9 212.2-87.9s155.5 31.2 212.2 87.9C779 752.7 810 825 812 902.2c.1 4.4 3.6 7.8 8 7.8h60a8 8 0 0 0 8-8.2c-1-47.8-10.9-94.3-29.5-138.2zM512 534c-45.9 0-89.1-17.9-121.6-50.4S340 407.9 340 362c0-45.9 17.9-89.1 50.4-121.6S466.1 190 512 190s89.1 17.9 121.6 50.4S684 316.1 684 362c0 45.9-17.9 89.1-50.4 121.6S557.9 534 512 534z"></path></svg>
</i>个人中心 </i>个人中心
...@@ -507,6 +507,8 @@ export default { ...@@ -507,6 +507,8 @@ export default {
if (path == "/login") { if (path == "/login") {
this.$store.dispatch("user/removeRole") this.$store.dispatch("user/removeRole")
this.$store.dispatch("user/removeToken") this.$store.dispatch("user/removeToken")
} else if (path == "/profile/index" && this.$route.path == "/profile/index") {
return false;
} }
this.$router.push(path) this.$router.push(path)
}, },
......
/* /*
* @Author: your name * @Author: your name
* @Date: 2021-04-14 14:12:19 * @Date: 2021-04-14 14:12:19
* @LastEditTime: 2021-07-01 11:26:51 * @LastEditTime: 2021-07-05 18:58:33
* @LastEditors: Please set LastEditors * @LastEditors: Please set LastEditors
* @Description: In User Settings Edit * @Description: In User Settings Edit
* @FilePath: \evm-store\frontend\src\settings.js * @FilePath: \evm-store\frontend\src\settings.js
...@@ -57,13 +57,6 @@ export default { ...@@ -57,13 +57,6 @@ export default {
icon: "gongzuotai", icon: "gongzuotai",
path: "device/index", path: "device/index",
}, },
{
vue: "profile/docs.vue",
title: "个人中心",
name: "Profile",
icon: "gongzuotai",
path: "profile/index",
},
{ {
vue: "system/monitor.vue", vue: "system/monitor.vue",
title: "资源监视", title: "资源监视",
...@@ -71,20 +64,20 @@ export default { ...@@ -71,20 +64,20 @@ export default {
icon: "gongzuotai", icon: "gongzuotai",
path: "monitor/index", path: "monitor/index",
}, },
{ // {
vue: "system/chart.vue", // vue: "system/chart.vue",
title: "实时曲线", // title: "实时曲线",
name: "AppChart", // name: "AppChart",
icon: "gongzuotai", // icon: "gongzuotai",
path: "chart/index", // path: "chart/index",
}, // },
{ // {
vue: "system/history.vue", // vue: "system/history.vue",
title: "历史曲线", // title: "历史曲线",
name: "AppHistoryChart", // name: "AppHistoryChart",
icon: "gongzuotai", // icon: "gongzuotai",
path: "history/index", // path: "history/index",
}, // },
{ {
vue: "system/tool.vue", vue: "system/tool.vue",
title: "工具", title: "工具",
......
...@@ -121,7 +121,7 @@ export default { ...@@ -121,7 +121,7 @@ export default {
focus: "series", focus: "series",
blurScope: "coordinateSystem", blurScope: "coordinateSystem",
}, },
data: seriesData.used_pctused_pct, data: seriesData.used_pct,
}, },
], ],
legendData: [ legendData: [
...@@ -131,7 +131,7 @@ export default { ...@@ -131,7 +131,7 @@ export default {
"free_size", "free_size",
"total_size", "total_size",
"used_cnt", "used_cnt",
"used_pctused_pct", "used_pct",
], ],
}; };
}, },
......
...@@ -501,13 +501,16 @@ export default { ...@@ -501,13 +501,16 @@ export default {
this.socket.send(message); this.socket.send(message);
}, },
handleMessage(msg) { handleMessage(msg) {
if (msg.type !== "report") return false; if (msg.type !== "report" || !msg.imei) return false;
if (this.deviceList && !this.deviceList.includes(msg.imei)) { if (!this.deviceList) {
this.deviceList.push(msg.imei); this.deviceList = []
}
if (!this.deviceList.includes(msg.imei)) {
this.deviceList.push(msg.imei)
} }
if (!this.device && this.deviceList) { if (!this.device && this.deviceList) {
this.device = this.deviceList[0]; this.device = this.deviceList[0]
} else { } else {
this.device = msg.imei this.device = msg.imei
} }
...@@ -517,7 +520,6 @@ export default { ...@@ -517,7 +520,6 @@ export default {
this.resetData(); this.resetData();
}, },
processData(msg) { processData(msg) {
console.log(msg)
if (!msg) return null; if (!msg) return null;
Object.keys(msg).forEach((item) => { Object.keys(msg).forEach((item) => {
if (this.form[item]) { if (this.form[item]) {
...@@ -535,8 +537,6 @@ export default { ...@@ -535,8 +537,6 @@ export default {
} }
}); });
console.log(msg)
this.evmList = [{ ...msg.evm }]; this.evmList = [{ ...msg.evm }];
this.lvglList = [{ ...msg.lvgl }]; this.lvglList = [{ ...msg.lvgl }];
this.system = [{ imei: msg.imei, ...msg.system, ...msg.request }]; this.system = [{ imei: msg.imei, ...msg.system, ...msg.request }];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment