second commit
This commit is contained in:
parent
1b50066e33
commit
37afebf1d0
|
@ -0,0 +1,74 @@
|
|||
<!--
|
||||
* @Author: Robin.lau
|
||||
* @Email: 329080237@qq.com
|
||||
* @Wechat: 15618110227
|
||||
-->
|
||||
<template>
|
||||
<div id="app">
|
||||
<router-view v-if="isRouterAlive" :key="key"></router-view>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'App',
|
||||
provide() {
|
||||
return {
|
||||
reload: this.reload,
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isRouterAlive: true,
|
||||
userInfo: JSON.parse(localStorage.getItem("userInfo")),
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if(this.userInfo){
|
||||
this.initSocket()
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
key() {
|
||||
return this.$route.path
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
reload() {
|
||||
this.isRouterAlive = false
|
||||
this.$nextTick(function() {
|
||||
this.isRouterAlive = true
|
||||
})
|
||||
},
|
||||
|
||||
//初始化 websocket连接
|
||||
initSocket() {
|
||||
let that = this;
|
||||
if ("WebSocket" in window) {
|
||||
//线上环境
|
||||
//that.ws = new WebSocket("ws://wb-web.traumwork.com/ws/client/"+that.userInfo.id+"/");
|
||||
//本地环境
|
||||
that.ws = new WebSocket("ws://127.0.0.1:8000/ws/client/"+that.userInfo.id+"/");
|
||||
that.wsGlobal.setWs(that.ws);
|
||||
that.ws.onopen = function () {
|
||||
console.log('websocket连接成功');
|
||||
};
|
||||
|
||||
that.ws.onclose = function () {
|
||||
// 关闭 websocket
|
||||
console.log("连接已关闭...");
|
||||
//断线重新连接
|
||||
// setTimeout(() => {
|
||||
// that.initSocket();
|
||||
// }, 3000);
|
||||
};
|
||||
} else {
|
||||
// 浏览器不支持 WebSocket
|
||||
console.log("您的浏览器不支持 WebSocket!");
|
||||
this.openNotificationWithIcon('error', '浏览器', '您的浏览器不支持显示消息请更换', 1,1)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "apiset.settings")
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError:
|
||||
# The above import may fail for some other reason. Ensure that the
|
||||
# issue is really that Django is missing to avoid masking other
|
||||
# exceptions on Python 2.
|
||||
try:
|
||||
import django
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
)
|
||||
raise
|
||||
execute_from_command_line(sys.argv)
|
Loading…
Reference in New Issue