即时通信嵌入测试
This commit is contained in:
@@ -40,6 +40,8 @@ import VueMeta from 'vue-meta'
|
||||
// 字典数据组件
|
||||
import DictData from '@/components/DictData'
|
||||
|
||||
import webSocket from "./utils/websocket";
|
||||
|
||||
//打印组件 添加时间:2024年3月9日
|
||||
import Print from 'vue-print-nb'
|
||||
|
||||
@@ -55,6 +57,7 @@ Vue.prototype.selectDictLabel = selectDictLabel
|
||||
Vue.prototype.selectDictLabels = selectDictLabels
|
||||
Vue.prototype.download = download
|
||||
Vue.prototype.handleTree = handleTree
|
||||
Vue.prototype.$webSocket = webSocket
|
||||
|
||||
// 全局组件挂载
|
||||
Vue.component('DictTag', DictTag)
|
||||
@@ -91,9 +94,32 @@ Vue.use(Element, {
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
new Vue({
|
||||
let newVue = new Vue({
|
||||
el: '#app',
|
||||
created() {
|
||||
//监听用户窗口是否关闭
|
||||
window.addEventListener('beforeunload', this.closeSocket);
|
||||
},
|
||||
destroyed() {
|
||||
window.removeEventListener('beforeunload', this.closeSocket);
|
||||
},
|
||||
methods: {
|
||||
onBeforeUnload(event) {
|
||||
// 在这里编写你想要执行的代码
|
||||
// 例如:发送数据到服务器或者显示警告信息
|
||||
// 设置event.returnValue以显示浏览器默认的警告信息
|
||||
event.returnValue = '您可能有未保存的更改!';
|
||||
},
|
||||
closeSocket() {
|
||||
//关闭websocket连接
|
||||
this.$websocket.close();
|
||||
}
|
||||
},
|
||||
router,
|
||||
store,
|
||||
render: h => h(App)
|
||||
})
|
||||
|
||||
|
||||
|
||||
export default newVue
|
||||
|
||||
Reference in New Issue
Block a user