新增优化websocket重连后刷新项目、对话、仪表盘数据
This commit is contained in:
parent
e730875db3
commit
79c1484288
@ -211,7 +211,7 @@ export default {
|
|||||||
}, this.releases.tag_name)
|
}, this.releases.tag_name)
|
||||||
]),
|
]),
|
||||||
h('MarkdownPreview', {
|
h('MarkdownPreview', {
|
||||||
class: 'notification-body overlay-y',
|
class: 'notification-body',
|
||||||
props: {
|
props: {
|
||||||
initialValue: this.releases.body
|
initialValue: this.releases.body
|
||||||
}
|
}
|
||||||
|
@ -231,6 +231,8 @@ export default {
|
|||||||
|
|
||||||
dialogMsgSubscribe: null,
|
dialogMsgSubscribe: null,
|
||||||
|
|
||||||
|
websocketOpenSubscribe: null,
|
||||||
|
|
||||||
columns: [],
|
columns: [],
|
||||||
|
|
||||||
projectKeyValue: '',
|
projectKeyValue: '',
|
||||||
@ -264,12 +266,9 @@ export default {
|
|||||||
this.notificationInit();
|
this.notificationInit();
|
||||||
this.onVisibilityChange();
|
this.onVisibilityChange();
|
||||||
//
|
//
|
||||||
this.addTaskSubscribe = Store.subscribe('addTask', (data) => {
|
this.addTaskSubscribe = Store.subscribe('addTask', this.onAddTask);
|
||||||
this.onAddTask(data)
|
this.dialogMsgSubscribe = Store.subscribe('dialogMsgPush', this.addDialogMsg);
|
||||||
});
|
this.websocketOpenSubscribe = Store.subscribe('websocketOpen', this.refreshBasic);
|
||||||
this.dialogMsgSubscribe = Store.subscribe('dialogMsgPush', (data) => {
|
|
||||||
this.addDialogMsg(data)
|
|
||||||
});
|
|
||||||
//
|
//
|
||||||
document.addEventListener('keydown', this.shortcutEvent);
|
document.addEventListener('keydown', this.shortcutEvent);
|
||||||
window.addEventListener('resize', this.innerHeightListener);
|
window.addEventListener('resize', this.innerHeightListener);
|
||||||
@ -288,6 +287,10 @@ export default {
|
|||||||
this.dialogMsgSubscribe.unsubscribe();
|
this.dialogMsgSubscribe.unsubscribe();
|
||||||
this.dialogMsgSubscribe = null;
|
this.dialogMsgSubscribe = null;
|
||||||
}
|
}
|
||||||
|
if (this.websocketOpenSubscribe) {
|
||||||
|
this.websocketOpenSubscribe.unsubscribe();
|
||||||
|
this.websocketOpenSubscribe = null;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
document.removeEventListener('keydown', this.shortcutEvent);
|
document.removeEventListener('keydown', this.shortcutEvent);
|
||||||
window.removeEventListener('resize', this.innerHeightListener);
|
window.removeEventListener('resize', this.innerHeightListener);
|
||||||
@ -619,6 +622,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
refreshBasic(num) {
|
||||||
|
if (num > 1) {
|
||||||
|
this.$store.dispatch("refreshBasicData")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
notificationInit() {
|
notificationInit() {
|
||||||
this.notificationClass = new notificationKoro(this.$L("打开通知成功"));
|
this.notificationClass = new notificationKoro(this.$L("打开通知成功"));
|
||||||
if (this.notificationClass.support) {
|
if (this.notificationClass.support) {
|
||||||
|
@ -126,9 +126,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.dialogMsgSubscribe = Store.subscribe('dialogMsgPush', (data) => {
|
this.dialogMsgSubscribe = Store.subscribe('dialogMsgPush', this.addDialogMsg);
|
||||||
this.addDialogMsg(data)
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
21
resources/assets/js/store/actions.js
vendored
21
resources/assets/js/store/actions.js
vendored
@ -166,6 +166,16 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新基本数据(项目、对话、仪表盘任务)
|
||||||
|
* @param dispatch
|
||||||
|
*/
|
||||||
|
refreshBasicData({dispatch}) {
|
||||||
|
dispatch("getProjects");
|
||||||
|
dispatch("getDialogs");
|
||||||
|
dispatch("getTaskForDashboard");
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取/更新会员信息
|
* 获取/更新会员信息
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
@ -202,9 +212,7 @@ export default {
|
|||||||
state.userToken = userInfo.token;
|
state.userToken = userInfo.token;
|
||||||
state.userIsAdmin = $A.inArray('admin', userInfo.identity);
|
state.userIsAdmin = $A.inArray('admin', userInfo.identity);
|
||||||
$A.setStorage("userInfo", state.userInfo);
|
$A.setStorage("userInfo", state.userInfo);
|
||||||
dispatch("getProjects");
|
dispatch("refreshBasicData");
|
||||||
dispatch("getDialogs");
|
|
||||||
dispatch("getTaskForDashboard");
|
|
||||||
dispatch("websocketConnection");
|
dispatch("websocketConnection");
|
||||||
resolve()
|
resolve()
|
||||||
});
|
});
|
||||||
@ -1688,7 +1696,7 @@ export default {
|
|||||||
dispatch("call", {
|
dispatch("call", {
|
||||||
url: 'dialog/lists',
|
url: 'dialog/lists',
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
dispatch("saveDialog", result.data.data.reverse());
|
dispatch("saveDialog", result.data.data);
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
console.warn(e);
|
console.warn(e);
|
||||||
});
|
});
|
||||||
@ -1959,6 +1967,7 @@ export default {
|
|||||||
state.ws = new WebSocket(url);
|
state.ws = new WebSocket(url);
|
||||||
state.ws.onopen = (e) => {
|
state.ws.onopen = (e) => {
|
||||||
// console.log("[WS] Open", e)
|
// console.log("[WS] Open", e)
|
||||||
|
Store.set('websocketOpen', ++state.wsOpenNum);
|
||||||
};
|
};
|
||||||
state.ws.onclose = (e) => {
|
state.ws.onclose = (e) => {
|
||||||
// console.log("[WS] Close", e);
|
// console.log("[WS] Close", e);
|
||||||
@ -1980,7 +1989,7 @@ export default {
|
|||||||
};
|
};
|
||||||
state.ws.onmessage = (e) => {
|
state.ws.onmessage = (e) => {
|
||||||
// console.log("[WS] Message", e);
|
// console.log("[WS] Message", e);
|
||||||
const msgDetail = $A.jsonParse(event.data);
|
const msgDetail = $A.jsonParse(e.data);
|
||||||
const {type, msgId} = msgDetail;
|
const {type, msgId} = msgDetail;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "open":
|
case "open":
|
||||||
@ -2004,7 +2013,7 @@ export default {
|
|||||||
try {
|
try {
|
||||||
call(msgDetail);
|
call(msgDetail);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// console.log("[WS] Callerr", err);
|
console.log("[WS] Callerr", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
1
resources/assets/js/store/state.js
vendored
1
resources/assets/js/store/state.js
vendored
@ -39,6 +39,7 @@ state.ws = null;
|
|||||||
state.wsMsg = {};
|
state.wsMsg = {};
|
||||||
state.wsCall = {};
|
state.wsCall = {};
|
||||||
state.wsTimeout = null;
|
state.wsTimeout = null;
|
||||||
|
state.wsOpenNum = 0;
|
||||||
state.wsListener = {};
|
state.wsListener = {};
|
||||||
state.wsReadTimeout = null;
|
state.wsReadTimeout = null;
|
||||||
state.wsReadWaitList = [];
|
state.wsReadWaitList = [];
|
||||||
|
56
resources/assets/sass/components/app-down.scss
vendored
56
resources/assets/sass/components/app-down.scss
vendored
@ -14,30 +14,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.common-app-down-notification {
|
.common-app-down-notification {
|
||||||
.el-notification__group {
|
.notification-head {
|
||||||
width: 100%;
|
display: flex;
|
||||||
}
|
align-items: center;
|
||||||
}
|
.notification-title {
|
||||||
|
|
||||||
.common-app-down-link {
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
cursor: pointer;
|
vertical-align: middle;
|
||||||
line-height: 32px;
|
font-size: 18px;
|
||||||
height: 32px;
|
color: #17233d;
|
||||||
padding: 0 15px;
|
font-weight: 500;
|
||||||
font-size: 14px;
|
margin-right: 6px;
|
||||||
border-radius: 4px;
|
|
||||||
color: #fff;
|
|
||||||
background-color: #8bcf70;
|
|
||||||
border-color: #8bcf70;
|
|
||||||
&:hover {
|
|
||||||
color: #fff;
|
|
||||||
opacity: 0.9;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.notification-body {
|
||||||
.common-app-down-body {
|
max-height: 210px;
|
||||||
max-height: 175px;
|
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
margin: 18px 0;
|
margin: 18px 0;
|
||||||
.markdown-preview {
|
.markdown-preview {
|
||||||
@ -58,3 +48,27 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.notification-link {
|
||||||
|
margin-top: 20px;
|
||||||
|
text-align: right;
|
||||||
|
> button + button {
|
||||||
|
margin-left: 6px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.common-app-down-link {
|
||||||
|
display: inline-block;
|
||||||
|
cursor: pointer;
|
||||||
|
line-height: 32px;
|
||||||
|
height: 32px;
|
||||||
|
padding: 0 15px;
|
||||||
|
font-size: 14px;
|
||||||
|
border-radius: 4px;
|
||||||
|
color: #fff;
|
||||||
|
background-color: #8bcf70;
|
||||||
|
border-color: #8bcf70;
|
||||||
|
&:hover {
|
||||||
|
color: #fff;
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user