feat(性能测试): 性能测试报告页面数据自动更新时间可动态调整

This commit is contained in:
Captain.B 2021-04-15 11:57:35 +08:00 committed by 刘瑞斌
parent f8822370ad
commit 034b464a65
2 changed files with 7 additions and 5 deletions

View File

@ -65,7 +65,7 @@ public class ReportWebSocket {
} }
refreshTimes.put(session, refreshTime); refreshTimes.put(session, refreshTime);
try { try {
session.getBasicRemote().sendText("refresh-" + 0); session.getBasicRemote().sendText("refresh-" + Math.random());
} catch (IOException e) { } catch (IOException e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
} }

View File

@ -159,7 +159,7 @@ export default {
dialogFormVisible: false, dialogFormVisible: false,
reportExportVisible: false, reportExportVisible: false,
testPlan: {testResourcePoolId: null}, testPlan: {testResourcePoolId: null},
refreshTime: '20', refreshTime: localStorage.getItem("reportRefreshTime") || "20",
refreshTimes: [ refreshTimes: [
{value: '1', label: '1s'}, {value: '1', label: '1s'},
{value: '3', label: '3s'}, {value: '3', label: '3s'},
@ -273,6 +273,7 @@ export default {
}); });
}, },
onOpen() { onOpen() {
this.refresh();
// window.console.log("socket opening."); // window.console.log("socket opening.");
}, },
onError(e) { onError(e) {
@ -375,8 +376,11 @@ export default {
}, },
refresh() { refresh() {
if (this.status === 'Running') { if (this.status === 'Running') {
this.websocket.send(this.refreshTime); if (this.websocket && this.websocket.readyState === 1) {
this.websocket.send(this.refreshTime);
}
} }
localStorage.setItem("reportRefreshTime", this.refreshTime);
} }
}, },
created() { created() {
@ -397,8 +401,6 @@ export default {
this.reportId = to.path.split('/')[4]; this.reportId = to.path.split('/')[4];
this.getReport(this.reportId); this.getReport(this.reportId);
this.initBreadcrumb((response) => { this.initBreadcrumb((response) => {
let data = response.data;
this.checkReportStatus(data.status);
this.initReportTimeInfo(); this.initReportTimeInfo();
}); });
this.initWebSocket(); this.initWebSocket();