mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +08:00
feat: add Vite proxy, change terminal to other channel
This commit is contained in:
1 parent
c3e735b627
commit
c248004484
5 files changed
+11
-8
No files matched your search
@@ -19,6 +19,7 @@ onMounted(async () => {
|
|||||||
socket.on('disconnect', function close() {
|
socket.on('disconnect', function close() {
|
||||||
console.log('Disconnected from the server.')
|
console.log('Disconnected from the server.')
|
||||||
})
|
})
|
||||||
|
socket.on('message', console.log)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -55,11 +55,11 @@ onMounted(() => {
|
|||||||
term.open(terminal.value)
|
term.open(terminal.value)
|
||||||
term.focus()
|
term.focus()
|
||||||
resizeScreen()
|
resizeScreen()
|
||||||
socket.on('message', (message) => {
|
socket.on('terminal', (message) => {
|
||||||
term.write(message)
|
term.write(message)
|
||||||
})
|
})
|
||||||
term.onData((key) => {
|
term.onData((key) => {
|
||||||
socket.send(key)
|
socket.emit('terminal', key)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
const api = axios.create({
|
const api = axios.create({
|
||||||
baseURL: 'https://odyssey.wancat.cc/api/v1',
|
baseURL: '/api',
|
||||||
})
|
})
|
||||||
|
|
||||||
export default api
|
export default api
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
import io from 'socket.io-client'
|
import io from 'socket.io-client'
|
||||||
|
|
||||||
const host = 'wss://odyssey.wancat.cc'
|
|
||||||
|
|
||||||
class SocketWrapper {
|
class SocketWrapper {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.socket = null
|
this.socket = null
|
||||||
@@ -14,7 +12,7 @@ class SocketWrapper {
|
|||||||
this.socket.disconnect()
|
this.socket.disconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.socket = io(host, {
|
this.socket = io('', {
|
||||||
query: {
|
query: {
|
||||||
session_id: session._id,
|
session_id: session._id,
|
||||||
},
|
},
|
||||||
|
|||||||
+6
-2
@@ -7,8 +7,12 @@ export default defineConfig({
|
|||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
// target: 'http://localhost:3000', // the server url
|
target: 'http://localhost:3000/api/v1',
|
||||||
target: 'http://odyssey.wancat.cc ',
|
rewrite: (path) => path.replace(/^\/api/, ''), // Optional: remove "/api" prefix from the path
|
||||||
|
},
|
||||||
|
'/socket.io': {
|
||||||
|
target: 'ws://localhost:3000',
|
||||||
|
// target: 'wss://odyssey.wancat.cc',
|
||||||
ws: true,
|
ws: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user