|
|
@ -194,6 +194,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
</el-tab-pane>
|
|
|
|
</el-tab-pane>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-tab-pane label="消息推送">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-card class="box-card" style="width: 600px;margin: 20px">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-button type="primary" @click="doPush">开始推送</el-button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-button type="danger" @click="doUnPush">停止推送</el-button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-divider></el-divider>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<p>var evtSource = new EventSource('http://localhost:8080/sse/1');</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<p>evtSource.addEventListener('message', function (e) {</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<p style="text-indent: 2em;">console.log(e.data);</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<p>});</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
</el-tab-pane>
|
|
|
|
|
|
|
|
|
|
|
|
<el-tab-pane label="自定义工具">
|
|
|
|
<el-tab-pane label="自定义工具">
|
|
|
|
<el-card class="box-card" style="width: 600px;margin: 20px">
|
|
|
|
<el-card class="box-card" style="width: 600px;margin: 20px">
|
|
|
|
<el-button type="primary" @click="this.nav.i('消息')">普通消息</el-button>
|
|
|
|
<el-button type="primary" @click="this.nav.i('消息')">普通消息</el-button>
|
|
|
@ -1003,6 +1024,23 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
doPush: function () {
|
|
|
|
|
|
|
|
if (window.EventSource) {
|
|
|
|
|
|
|
|
window.evtSource = new EventSource('http://localhost:8080/sse/1');
|
|
|
|
|
|
|
|
window.evtSource.addEventListener('message', function (e) {
|
|
|
|
|
|
|
|
console.log(e.data);
|
|
|
|
|
|
|
|
this.$notify.info({
|
|
|
|
|
|
|
|
title: '消息',
|
|
|
|
|
|
|
|
message: "收到一条新的消息:" + e.data
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
doUnPush: function () {
|
|
|
|
|
|
|
|
if (typeof window.evtSource !== "undefined") {
|
|
|
|
|
|
|
|
window.evtSource.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
handleUpload: function (req) {
|
|
|
|
handleUpload: function (req) {
|
|
|
|
ajax.fileUpload(req.file).then(function (response) {
|
|
|
|
ajax.fileUpload(req.file).then(function (response) {
|
|
|
|
if (response.errors.length > 0) {
|
|
|
|
if (response.errors.length > 0) {
|
|
|
|