Merge pull request 'fix : websocket代理' (#363) from de into dev
Reviewed-on: http://git.feashow.cn/clay/tunnel-cloud-web/pulls/363
This commit is contained in:
@@ -3,4 +3,5 @@
|
|||||||
VITE_BASE_URL='/api'
|
VITE_BASE_URL='/api'
|
||||||
# VITE_BASE_URL='http://192.168.101.7:8000'
|
# VITE_BASE_URL='http://192.168.101.7:8000'
|
||||||
|
|
||||||
VITE_BASE_WSURL='ws://web-tunnel.feashow.com/api'
|
#VITE_BASE_WSURL='ws://web-tunnel.feashow.com/api'
|
||||||
|
VITE_BASE_WSURL='/websocket'
|
||||||
|
|||||||
@@ -4,4 +4,5 @@ VITE_TITLE='fateverse'
|
|||||||
|
|
||||||
VITE_BASE_URL='/api'
|
VITE_BASE_URL='/api'
|
||||||
|
|
||||||
VITE_BASE_WSURL='ws://web-tunnel.feashow.com/api'
|
#VITE_BASE_WSURL='ws://web-tunnel.feashow.com/api'
|
||||||
|
VITE_BASE_WSURL='/websocket'
|
||||||
|
|||||||
@@ -74,8 +74,9 @@ const handleSend = () => {
|
|||||||
dataList.value.push(data)
|
dataList.value.push(data)
|
||||||
}
|
}
|
||||||
const initWebSocket = () => {
|
const initWebSocket = () => {
|
||||||
// let wsUrl = `ws://192.168.31.175:9000/websocket/debug/${token}/${serialNumber.value}`
|
// let wsUrl = `ws://192.168.31.176:9000/websocket/debug/${token}/${serialNumber.value}`
|
||||||
let wsUrl = `ws://web-tunnel.feashow.com/api/wstunnel/websocket/debug/${token}/${serialNumber.value}`
|
let wsUrl = import.meta.env.VITE_BASE_WSURL+`/${token}/${serialNumber.value}`;
|
||||||
|
// let wsUrl = `ws://web-tunnel.feashow.com/api/wstunnel/websocket/debug/${token}/${serialNumber.value}`
|
||||||
console.log(wsUrl)
|
console.log(wsUrl)
|
||||||
socket = new WebSocket(wsUrl)
|
socket = new WebSocket(wsUrl)
|
||||||
//连接发生错误的回调方法
|
//连接发生错误的回调方法
|
||||||
|
|||||||
@@ -565,7 +565,8 @@ const nextBtn = () => {
|
|||||||
|
|
||||||
const initWebSocket = () => {
|
const initWebSocket = () => {
|
||||||
// let wsUrl = `ws://192.168.31.176:9000/websocket/equipment/${token}/${serialNumber.value}`
|
// let wsUrl = `ws://192.168.31.176:9000/websocket/equipment/${token}/${serialNumber.value}`
|
||||||
let wsUrl = `ws://web-tunnel.feashow.com/api/wstunnel/websocket/equipment/${token}/${serialNumber.value}`;
|
// let wsUrl = `ws://web-tunnel.feashow.com/api/wstunnel/websocket/equipment/${token}/${serialNumber.value}`;
|
||||||
|
let wsUrl = import.meta.env.VITE_BASE_WSURL+`/${token}/${serialNumber.value}`;
|
||||||
// let wsUrl = `ws://clay.frp.feashow.cn/wstunnel/websocket/equipment/${token}/${serialNumber.value}`;
|
// let wsUrl = `ws://clay.frp.feashow.cn/wstunnel/websocket/equipment/${token}/${serialNumber.value}`;
|
||||||
socket = new WebSocket(wsUrl);
|
socket = new WebSocket(wsUrl);
|
||||||
//连接发生错误的回调方法
|
//连接发生错误的回调方法
|
||||||
@@ -578,7 +579,7 @@ const initWebSocket = () => {
|
|||||||
};
|
};
|
||||||
//接收到消息的回调方法
|
//接收到消息的回调方法
|
||||||
socket.onmessage = function (event) {
|
socket.onmessage = function (event) {
|
||||||
// console.log("服务器返回的信息: ", JSON.parse(event.data));
|
console.log("服务器返回的信息: ", JSON.parse(event.data));
|
||||||
const type = JSON.parse(event.data).type;
|
const type = JSON.parse(event.data).type;
|
||||||
const data = JSON.parse(event.data).data;
|
const data = JSON.parse(event.data).data;
|
||||||
if (type === "equipment") {
|
if (type === "equipment") {
|
||||||
|
|||||||
@@ -58,9 +58,12 @@ export default defineConfig({
|
|||||||
strictPort: false,
|
strictPort: false,
|
||||||
open: true,
|
open: true,
|
||||||
proxy: {
|
proxy: {
|
||||||
// '/api/tunnel': {
|
// // '/api/tunnel': {
|
||||||
// // target: 'http://gateway.feashow.cn',
|
// '/tunnel': {
|
||||||
// target: 'http://192.168.31.175:8000',
|
//
|
||||||
|
// // // target: 'http://gateway.feashow.cn',
|
||||||
|
// target: 'http://frp.feashow.cn:31800/',
|
||||||
|
// // target: 'http://clay.frp.feashow.cn',
|
||||||
// changeOrigin: true,
|
// changeOrigin: true,
|
||||||
// rewrite: (path) => path.replace(/^\/api/, ''),
|
// rewrite: (path) => path.replace(/^\/api/, ''),
|
||||||
// },
|
// },
|
||||||
@@ -72,13 +75,20 @@ export default defineConfig({
|
|||||||
// },
|
// },
|
||||||
'/api': {
|
'/api': {
|
||||||
target: 'http://web-tunnel.feashow.com/api',
|
target: 'http://web-tunnel.feashow.com/api',
|
||||||
// target: 'http://192.168.31.175:8000',
|
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||||
},
|
},
|
||||||
'/socket': {
|
'/socket': {
|
||||||
target: 'ws://web-tunnel.feashow.com/api/notice-ws/notice',
|
target: 'ws://web-tunnel.feashow.com/api/notice-ws/notice',
|
||||||
ws: true
|
ws: true
|
||||||
|
},
|
||||||
|
'/websocket': {
|
||||||
|
target: 'ws://web-tunnel.feashow.com/api/wstunnel/websocket/equipment',
|
||||||
|
// target: 'ws://192.168.31.176:9000/websocket/debug',
|
||||||
|
changeOrigin: true,
|
||||||
|
ws: true,
|
||||||
|
|
||||||
|
rewrite: (path) => path.replace(/^\/websocket/, '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user