success integrated with chat system
This commit is contained in:
1 parent
82e101fc86
commit
64c925ab67
4 files changed
+67
-1
No files matched your search
@@ -26,6 +26,9 @@
|
||||
<el-button @click="onEdit(scope.row)" round type="primary" size="mini">
|
||||
{{ $t('common.button.edit') }}
|
||||
</el-button>
|
||||
<el-button @click="onPublish(scope.row)" round type="success" size="mini">
|
||||
{{ $t('common.button.publish') }}
|
||||
</el-button>
|
||||
<el-button @click="onDelete(scope.row)" round type="danger" size="mini">
|
||||
{{ $t('common.button.delete') }}
|
||||
</el-button>
|
||||
@@ -90,6 +93,14 @@ export default defineComponent({
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
onPublish(row: IArticle) {
|
||||
this.$router.push({
|
||||
name: 'article-publish',
|
||||
params: {
|
||||
id: row.id
|
||||
}
|
||||
});
|
||||
},
|
||||
onEdit(row: IArticle) {
|
||||
this.$router.push({
|
||||
name: 'article-detail',
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<template>
|
||||
<p>
|
||||
{{ chatValue }}
|
||||
</p>
|
||||
<el-input v-model="inputValue"> </el-input>
|
||||
<el-button @click="onSend"> Send </el-button>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
interface IData {
|
||||
socket: WebSocket | undefined;
|
||||
inputValue: string;
|
||||
chatValue: string;
|
||||
}
|
||||
export default defineComponent({
|
||||
data(): IData {
|
||||
return {
|
||||
socket: undefined,
|
||||
inputValue: '',
|
||||
chatValue: ''
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.socket = new WebSocket('ws://localhost:8000/ws/chat/1');
|
||||
this.socket.onmessage = this.onMessage;
|
||||
},
|
||||
methods: {
|
||||
onMessage(e) {
|
||||
console.log('e');
|
||||
const data = JSON.parse(e.data);
|
||||
this.chatValue += data.message;
|
||||
},
|
||||
onSend() {
|
||||
if (!this.socket) {
|
||||
return;
|
||||
}
|
||||
this.socket.send(
|
||||
JSON.stringify({
|
||||
message: this.inputValue
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in new issue
Block a user