Merge pull request 'version_1.1' (#16) from version_1.1 into main
Reviewed-on: https://git.wishpal.cn/wishpal_ironfan/tiefen_space_h5/pulls/16
This commit is contained in:
commit
ad1e9b2373
|
@ -227,6 +227,10 @@ const ImagesMaskContaint = forwardRef(
|
||||||
|
|
||||||
return newImages;
|
return newImages;
|
||||||
});
|
});
|
||||||
|
Toast.show({
|
||||||
|
content: "已切换至原图",
|
||||||
|
position: "top",
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -21,7 +21,7 @@ const WebSocketComponent = ({ getData, authInfo }) => {
|
||||||
if (!socketRef.current && account) {
|
if (!socketRef.current && account) {
|
||||||
retryInterval = Math.min(retryInterval * 2, maxInterval);
|
retryInterval = Math.min(retryInterval * 2, maxInterval);
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
if (socketRef.current?.readyState !== 1) {
|
if (socketRef.current?.readyState !== 1 && account) {
|
||||||
if (socketRef.current) {
|
if (socketRef.current) {
|
||||||
socketRef.current?.close();
|
socketRef.current?.close();
|
||||||
socketRef.current = null;
|
socketRef.current = null;
|
||||||
|
@ -47,7 +47,8 @@ const WebSocketComponent = ({ getData, authInfo }) => {
|
||||||
const connect_socket = () => {
|
const connect_socket = () => {
|
||||||
const base = baseRequest();
|
const base = baseRequest();
|
||||||
const account = get("account");
|
const account = get("account");
|
||||||
if (socketRef.current?.readyState === 1) return;
|
// console.log(account);
|
||||||
|
if (socketRef.current?.readyState === 1 || !account) return;
|
||||||
// 创建WebSocket连接
|
// 创建WebSocket连接
|
||||||
socketRef.current = new WebSocket(
|
socketRef.current = new WebSocket(
|
||||||
`${process.env.NEXT_PUBLIC_WEBSOCKET_URL}/ws?b_mid=${base.b_mid}&b_dt=1&b_token=${base.b_token}&b_ch=h5`
|
`${process.env.NEXT_PUBLIC_WEBSOCKET_URL}/ws?b_mid=${base.b_mid}&b_dt=1&b_token=${base.b_token}&b_ch=h5`
|
||||||
|
@ -69,7 +70,7 @@ const WebSocketComponent = ({ getData, authInfo }) => {
|
||||||
reader.readAsText(event.data, "utf-8");
|
reader.readAsText(event.data, "utf-8");
|
||||||
reader.onload = function (e) {
|
reader.onload = function (e) {
|
||||||
if (reader.result === "pong") {
|
if (reader.result === "pong") {
|
||||||
console.log("pong received");
|
// console.log("pong received");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const data = JSON.parse(reader.result);
|
const data = JSON.parse(reader.result);
|
||||||
|
@ -97,11 +98,11 @@ const WebSocketComponent = ({ getData, authInfo }) => {
|
||||||
|
|
||||||
// 连接关闭时触发
|
// 连接关闭时触发
|
||||||
socketRef.current.onclose = () => {
|
socketRef.current.onclose = () => {
|
||||||
console.log("WebSocket closed.", socketRef.current.readyState);
|
// console.log("WebSocket closed.", socketRef.current.readyState);
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
|
|
||||||
if (account) {
|
if (account) {
|
||||||
console.log("WebSocket closed--------.", account);
|
// console.log("WebSocket closed--------.", account);
|
||||||
setTimeout(connect_socket, 1000);
|
setTimeout(connect_socket, 1000);
|
||||||
// retryInterval = Math.min(retryInterval * 2, maxInterval);
|
// retryInterval = Math.min(retryInterval * 2, maxInterval);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue