add publish page

This commit is contained in:
AceDataCloud committed 2021-09-21 00:59:44 +08:00
1 parent 64c925ab67
commit 125baa2710
2 files changed
+12 -1

No files matched your search

+7 -1
View File
@@ -12,17 +12,23 @@ interface IData {
socket: WebSocket | undefined;
inputValue: string;
chatValue: string;
id: string;
}
export default defineComponent({
data(): IData {
return {
id: this.$route.params.id.toString(),
socket: undefined,
inputValue: '',
chatValue: ''
};
},
mounted() {
this.socket = new WebSocket('ws://localhost:8000/ws/chat/1');
this.socket = new WebSocket(
`${window.location.protocol === 'https:' ? 'wss://' : 'ws://'}/${window.location.host}/ws/publish/${
this.id
}?access_token=${this.$store.getters.accessToken}`
);
this.socket.onmessage = this.onMessage;
},
methods: {
+5
View File
@@ -11,6 +11,11 @@ export default defineConfig({
'/api': {
target: 'http://localhost:8000',
changeOrigin: true
},
'/ws': {
target: 'ws://localhost:8000',
changeOrigin: true,
ws: true
}
}
},