refactor(mobile): 优化页面交互和移除未使用代码

移除未使用的导入和状态变量
将点击事件移至容器元素提升交互体验
减少好友列表每页显示数量为5条
This commit is contained in:
超级老白兔
2025-09-13 15:08:42 +08:00
parent cb05b5beb3
commit fb362a56af
3 changed files with 15 additions and 46 deletions

View File

@@ -291,7 +291,10 @@ const Devices: React.FC = () => {
</div>
{/* 主要内容区域:头像和详细信息 */}
<div className={styles.mainContent}>
<div
className={styles.mainContent}
onClick={() => goDetail(device.id!)}
>
{/* 头像 */}
<div className={styles.avatar}>
{device.avatar ? (
@@ -339,12 +342,6 @@ const Devices: React.FC = () => {
</div>
</div>
</div>
{/* 箭头图标 */}
<RightOutlined
className={styles.arrowIcon}
onClick={() => goDetail(device.id!)}
/>
</div>
</div>
))}

View File

@@ -1,5 +1,5 @@
import React, { useEffect, useState } from "react";
import { useParams, useNavigate } from "react-router-dom";
import { useParams } from "react-router-dom";
import { Card, Button, Avatar, Tag, List, SpinLoading } from "antd-mobile";
import {
UserOutlined,
@@ -24,7 +24,6 @@ import styles from "./index.module.scss";
const TrafficPoolDetail: React.FC = () => {
const { wxid, userId } = useParams();
const navigate = useNavigate();
const [loading, setLoading] = useState(true);
const [user, setUser] = useState<ExtendedUserDetail | null>(null);
const [activeTab, setActiveTab] = useState("basic");

View File

@@ -17,10 +17,6 @@ import {
SearchOutlined,
ReloadOutlined,
UserOutlined,
ClockCircleOutlined,
MessageOutlined,
StarOutlined,
ExclamationCircleOutlined,
} from "@ant-design/icons";
import Layout from "@/components/Layout/Layout";
import style from "./detail.module.scss";
@@ -39,7 +35,6 @@ const WechatAccountDetail: React.FC = () => {
const [showTransferConfirm, setShowTransferConfirm] = useState(false);
const [searchQuery, setSearchQuery] = useState("");
const [activeTab, setActiveTab] = useState("overview");
const [isLoading, setIsLoading] = useState(false);
const [loadingInfo, setLoadingInfo] = useState(true);
// 好友列表相关状态
@@ -91,7 +86,7 @@ const WechatAccountDetail: React.FC = () => {
const response = await getWechatFriends({
wechatAccount: id,
page: page,
limit: 20,
limit: 5,
keyword: keyword,
});
@@ -185,35 +180,6 @@ const WechatAccountDetail: React.FC = () => {
return colors[Math.floor(Math.random() * colors.length)];
};
const calculateAccountAge = (registerTime: string) => {
const registerDate = new Date(registerTime);
const now = new Date();
const diffTime = Math.abs(now.getTime() - registerDate.getTime());
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
const years = Math.floor(diffDays / 365);
const months = Math.floor((diffDays % 365) / 30);
return { years, months };
};
const formatAccountAge = (age: { years: number; months: number }) => {
if (age.years > 0) {
return `${age.years}${age.months}个月`;
}
return `${age.months}个月`;
};
const getWeightColor = (weight: number) => {
if (weight >= 80) return "text-green-600";
if (weight >= 60) return "text-yellow-600";
return "text-red-600";
};
const getWeightDescription = (weight: number) => {
if (weight >= 80) return "账号质量优秀,可以正常使用";
if (weight >= 60) return "账号质量良好,需要注意使用频率";
return "账号质量较差,建议谨慎使用";
};
const handleTransferFriends = () => {
setShowTransferConfirm(true);
};
@@ -257,6 +223,10 @@ const WechatAccountDetail: React.FC = () => {
setActiveTab(value);
};
const handleFriendClick = (friend: Friend) => {
navigate(`/mine/traffic-pool/detail/${friend.wechatId}/${friend.id}`);
};
return (
<Layout header={<NavCommon title="微信号详情" />} loading={loadingInfo}>
<div className={style["wechat-account-detail-page"]}>
@@ -415,7 +385,11 @@ const WechatAccountDetail: React.FC = () => {
) : (
<>
{friends.map(friend => (
<div key={friend.id} className={style["friend-item"]}>
<div
key={friend.id}
className={style["friend-item"]}
onClick={() => handleFriendClick(friend)}
>
<Avatar
src={friend.avatar}
className={style["friend-avatar"]}
@@ -460,7 +434,6 @@ const WechatAccountDetail: React.FC = () => {
total={Math.ceil(friendsTotal / 20)}
current={friendsPage}
onChange={handlePageChange}
showText={true}
/>
</div>
)}