修改oss 路径

This commit is contained in:
张成
2026-02-07 18:07:33 +08:00
parent b08f3325e6
commit f131c9896d
18 changed files with 195 additions and 111 deletions

View File

@@ -68,6 +68,7 @@ const OtherUserPage: React.FC = () => {
);
const [collapseProfile, setCollapseProfile] = useState(false);
const [refreshing, setRefreshing] = useState(false);
// 进入页面时检查 user_id只在组件挂载时执行一次
useEffect(() => {
@@ -82,56 +83,52 @@ const OtherUserPage: React.FC = () => {
}
}, []); // 空依赖数组,确保只在进入时执行一次
// 页面加载时获取用户信息
useEffect(() => {
const load_user_data = async () => {
if (user_id) {
try {
// const user_data = await UserService.get_user_info(user_id);
const res = await LoginService.getUserInfoById(user_id);
const { data: userData } = res;
// setUserInfo({...res.data as UserInfo, avatar: data.avatar_url || require("@/static/userInfo/default_avatar.svg")});
setUserInfo({
id: parseInt(user_id || "") || 0,
nickname: userData.nickname || "",
avatar_url: userData.avatar_url || "",
join_date: userData.subscribe_time
? `${new Date(userData.subscribe_time).getFullYear()}${
new Date(userData.subscribe_time).getMonth() + 1
}月加入`
: "",
stats: {
following_count: userData.stats?.following_count || 0,
followers_count: userData.stats?.followers_count || 0,
hosted_games_count: userData.stats?.hosted_games_count || 0,
participated_games_count:
userData.stats?.participated_games_count || 0,
},
personal_profile: userData.personal_profile || "",
province: userData.province || "",
city: userData.city || "",
district: userData.district || "",
occupation: userData.occupation || "",
ntrp_level: "",
phone: userData.phone || "",
gender: userData.gender || "",
birthday: userData.birthday || "",
});
setIsFollowing(userData.is_following || false);
} catch (error) {
console.error("加载用户数据失败:", error);
Taro.showToast({
title: "加载失败",
icon: "none",
});
}
}
};
load_user_data();
// 加载用户信息(使用 useCallback 便于下拉刷新复用)
const load_user_data = useCallback(async () => {
if (!user_id) return;
try {
const res = await LoginService.getUserInfoById(user_id);
const { data: userData } = res;
setUserInfo({
id: parseInt(user_id || "") || 0,
nickname: userData.nickname || "",
avatar_url: userData.avatar_url || "",
join_date: userData.subscribe_time
? `${new Date(userData.subscribe_time).getFullYear()}${
new Date(userData.subscribe_time).getMonth() + 1
}月加入`
: "",
stats: {
following_count: userData.stats?.following_count || 0,
followers_count: userData.stats?.followers_count || 0,
hosted_games_count: userData.stats?.hosted_games_count || 0,
participated_games_count:
userData.stats?.participated_games_count || 0,
},
personal_profile: userData.personal_profile || "",
province: userData.province || "",
city: userData.city || "",
district: userData.district || "",
occupation: userData.occupation || "",
ntrp_level: "",
phone: userData.phone || "",
gender: userData.gender || "",
birthday: userData.birthday || "",
});
setIsFollowing(userData.is_following || false);
} catch (error) {
console.error("加载用户数据失败:", error);
Taro.showToast({
title: "加载失败",
icon: "none",
});
}
}, [user_id]);
useEffect(() => {
load_user_data();
}, [load_user_data]);
// 分类球局数据(使用 useCallback 包装,避免每次渲染都创建新函数)
const classifyGameRecords = useCallback(
(
@@ -232,6 +229,18 @@ const OtherUserPage: React.FC = () => {
setCollapseProfile(scrollData.scrollTop > 1);
}, []);
// 下拉刷新:刷新用户信息和球局数据
const handle_refresh = useCallback(async () => {
setRefreshing(true);
try {
await Promise.all([load_user_data(), load_game_data()]);
} catch (error) {
console.error("刷新失败:", error);
} finally {
setRefreshing(false);
}
}, [load_user_data, load_game_data]);
// 处理球局详情
// const handle_game_detail = (game_id: string) => {
// Taro.navigateTo({
@@ -244,6 +253,9 @@ const OtherUserPage: React.FC = () => {
scrollY
className="other_user_page"
refresherBackground="#FAFAFA"
refresherEnabled
refresherTriggered={refreshing}
onRefresherRefresh={handle_refresh}
>
{/* <CustomNavbar>
<View className="navbar_content">