anln_0000001_superFanPrices #25

Merged
yezian merged 48 commits from anln_0000001_superFanPrices into main 2025-01-21 14:34:00 +08:00
7 changed files with 80 additions and 64 deletions
Showing only changes of commit 4ceeb3fd83 - Show all commits

View File

@ -1,77 +1,84 @@
import React, { useEffect, useState } from "react";
import { View, Text, FlatList } from "react-native";
import { View } from "react-native";
import baseRequest from "../../utils/baseRequest";
import { get } from "../../utils/storeInfo";
import "text-encoding";
const WebSocketComponent = ({ getData }) => {
const [messages, setMessages] = useState([]);
useEffect(() => {
let socket = null;
async function fn() {
let interval = null;
async function connect_socket() {
const appInfo = await get("app_info");
const base = await baseRequest();
if (socket && socket.readyState === 1) return;
// WebSocket
socket = new WebSocket(
`${process.env.EXPO_PUBLIC_WEBSOCKET_URL}/ws?b_mid=${base.b_mid}&b_did=${base.b_did}&b_dt=1&b_token=${base.b_token}&b_ch${appInfo.b_ch}`
);
// 使wss
//
socket.onopen = () => {
// console.log("WebSocket connected.");
// socket.send('Hello Server!');
socket.send(JSON.stringify({ t: 1 }));
};
if (!socket) {
socket = new WebSocket(
`${process.env.EXPO_PUBLIC_WEBSOCKET_URL}/ws?b_mid=${base.b_mid}&b_did=${base.b_did}&b_dt=1&b_token=${base.b_token}&b_ch${appInfo.b_ch}`
);
// console.log("------------++++++++++++++++", socket);
socket.onopen = () => {
console.log("WebSocket connected.");
// socket.send('Hello Server!');
socket.send(JSON.stringify({ t: 1 }));
};
//
socket.onmessage = (event) => {
if (
Object.prototype.toString.call(event.data) === "[object ArrayBuffer]"
) {
const view = new Uint8Array(event.data);
const str = String.fromCharCode.apply(null, view);
// console.log(str);
try {
const data = JSON.parse(str);
if (data.t === 2 && data.msg.ping_interval) {
socket.send("ping");
setInterval(() => {
// ping
//
socket.onmessage = (event) => {
if (
Object.prototype.toString.call(event.data) ===
"[object ArrayBuffer]"
) {
let enc = new TextDecoder("utf-8");
const view = new Uint8Array(event.data);
let temp = enc.decode(view);
try {
const data = JSON.parse(temp);
if (data.t === 2 && data.msg.ping_interval) {
socket.send("ping");
// ping
// socket.on("ping", () => {
// socket.senrd("pong");
// });
}, data.msg.ping_interval * 1000);
}
if (data.t === 3) {
getData(data.msg);
setMessages((prevMessages) => [...prevMessages, data]);
}
} catch (error) {}
}
};
interval = setInterval(() => {
// ping
socket.send("ping");
// ping
// socket.on("ping", () => {
// socket.senrd("pong");
// });
}, data.msg.ping_interval * 1000);
}
if (data.t === 3) {
getData(data.msg);
setMessages((prevMessages) => [...prevMessages, data]);
}
} catch (error) {}
}
};
//
socket.onclose = () => {
console.log("WebSocket disconnected.");
};
//
socket.onerror = (error) => {
console.error("WebSocket error:", error);
};
//
socket.onclose = () => {
clearInterval(interval);
// connect_socket();
console.log("WebSocket disconnected.");
};
//
socket.onerror = (error) => {
console.error("WebSocket error:", error);
};
}
// ping
// socket.on("ping", () => {
// socket.send("pong");
// });
}
fn();
connect_socket();
// WebSocket
return () => {
socket.close();
socket?.readyState === WebSocket.OPEN && socket?.close();
clearInterval(interval);
};
}, []); // effect

View File

@ -81,7 +81,8 @@
"react-native-webview": "13.8.6",
"react-redux": "^9.1.2",
"redux-thunk": "^3.1.0",
"tailwind-rn": "^4.2.0"
"tailwind-rn": "^4.2.0",
"text-encoding": "^0.7.0"
},
"devDependencies": {
"@babel/core": "^7.24.0",

View File

@ -12,11 +12,14 @@ import systemIcon from "../../../assets/icon/others/m_system.png";
import payIcon from "../../../assets/icon/others/m_pay.png";
import activeIcon from "../../../assets/icon/others/m_active.png";
import examIcon from "../../../assets/icon/others/m_exam.png";
import { useDispatch } from "react-redux";
import { getNoticeCount } from "../../../store/reducer";
export default function SystemNotice({ navigation, route, ...props }) {
const { type } = route.params;
const tailwind = useTailwind();
const insets = useSafeAreaInsets();
const [data, setData] = useState([]);
const dispatch = useDispatch();
useEffect(() => {
getData();
}, []);
@ -80,6 +83,7 @@ export default function SystemNotice({ navigation, route, ...props }) {
});
return;
}
dispatch(getNoticeCount(0));
} catch (error) {
console.error(error);
}

View File

@ -141,8 +141,9 @@ const MessageList = forwardRef(({ navigation }, ref) => {
Object.keys(noticeObj).forEach((it) => {
newInfoItems[parseInt(it)]["count"] = noticeObj[it].unread_cnt;
if (noticeObj[it]["most_recent_notif"]) {
const time = noticeObj[it]["most_recent_notif"]["push_time"];
newInfoItems[parseInt(it)]["time"] = formatDate(
noticeObj[it]["most_recent_notif"]["push_time"]
time ? time : noticeObj[it]["most_recent_notif"]["ct"]
);
newInfoItems[parseInt(it)]["subtitle"] =
noticeObj[it].most_recent_notif.title;
@ -201,11 +202,11 @@ const MessageList = forwardRef(({ navigation }, ref) => {
navigation?.navigate("SystemNotice", { type: index, total: count })
}
style={{
...tailwind("flex flex-row items-center py-4 mb-2 rounded-xl"),
...tailwind("flex flex-row items-center p-4 mb-2 rounded-xl"),
backgroundColor: "#ffffff1a",
}}
>
<View style={tailwind("px-4")}>
<View style={tailwind("mr-4")}>
<NativeImage source={icon} />
</View>
<View
@ -221,7 +222,9 @@ const MessageList = forwardRef(({ navigation }, ref) => {
{subtitle}
</Text>
</View>
<View style={{ ...tailwind("w-12"), width: 60 }}>
<View
style={{ ...tailwind("w-12 justify-end items-end"), width: 60 }}
>
<Text style={{ ...tailwind("text-xs mb-2"), color: "#FFFFFF80" }}>
{time}
</Text>
@ -237,7 +240,7 @@ const MessageList = forwardRef(({ navigation }, ref) => {
<Badge
status="error"
value={count > 99 ? "+99" : count}
containerStyle={{ position: "absolute", top: 0, right: 40 }}
// containerStyle={{ position: "absolute", top: 0, right: 40 }}
badgeStyle={{ borderWidth: 0, backgroundColor: "#FF669E" }}
/>
</View>

View File

@ -54,7 +54,6 @@ export default function Reviewed({ navigation, zid }) {
});
return;
}
setData((old) => ({
...old,
list: [...old.list, ..._data.data.list],

View File

@ -84,16 +84,14 @@ export default function JoinEntrance({ navigation, route }) {
onPress={() =>
(streamerState?.basic_status === 2 ||
streamerState?.basic_status === 4) &&
(streamerState?.details_status === 2 ||
streamerState?.details_status === 4) &&
navigation.navigate("JoinStreamer")
}
>
<Image
style={tailwind("h-32")}
source={
streamerState?.basic_status === 1 &&
streamerState?.details_status === 1
streamerState?.basic_status === 2 ||
streamerState?.basic_status === 4
? require("../../../assets/images/streamerJoined.png")
: require("../../../assets/images/streamerJoin.png")
}
@ -109,8 +107,7 @@ export default function JoinEntrance({ navigation, route }) {
<Image
style={tailwind("h-32")}
source={
streamerState?.basic_status === 1 &&
streamerState?.details_status === 1
guildState !== 0
? require("../../../assets/images/guildJoined.png")
: require("../../../assets/images/guildJoin.png")
}

View File

@ -7602,6 +7602,11 @@ terser@^5.15.0:
commander "^2.20.0"
source-map-support "~0.5.20"
text-encoding@^0.7.0:
version "0.7.0"
resolved "https://registry.npmjs.org/text-encoding/-/text-encoding-0.7.0.tgz#f895e836e45990624086601798ea98e8f36ee643"
integrity sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA==
text-table@^0.2.0:
version "0.2.0"
resolved "https://registry.npmmirror.com/text-table/-/text-table-0.2.0.tgz"