feat: 本次提交更新内容如下
微信号详情先接上
This commit is contained in:
@@ -2,7 +2,12 @@ import request from "@/api/request";
|
|||||||
|
|
||||||
// 获取微信号详情
|
// 获取微信号详情
|
||||||
export function getWechatAccountDetail(id: string) {
|
export function getWechatAccountDetail(id: string) {
|
||||||
return request("/api/WechatAccount/detail", { id }, "GET");
|
return request("/WechatAccount/detail", { id }, "GET");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取微信号summary
|
||||||
|
export function getWechatAccountSummary(id: string) {
|
||||||
|
return request(`/v1/wechats/${id}/summary`, {}, "GET");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取微信号好友列表
|
// 获取微信号好友列表
|
||||||
@@ -12,10 +17,10 @@ export function getWechatFriends(params: {
|
|||||||
pageSize: number;
|
pageSize: number;
|
||||||
friendKeyword?: string;
|
friendKeyword?: string;
|
||||||
}) {
|
}) {
|
||||||
return request("/api/WechatFriend/friendlistData", params, "POST");
|
return request("/WechatFriend/friendlistData", params, "POST");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取微信好友详情
|
// 获取微信好友详情
|
||||||
export function getWechatFriendDetail(id: string) {
|
export function getWechatFriendDetail(id: string) {
|
||||||
return request("/api/WechatFriend/detail", { id }, "GET");
|
return request("/v1/WechatFriend/detail", { id }, "GET");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import Layout from "@/components/Layout/Layout";
|
|||||||
import style from "./detail.module.scss";
|
import style from "./detail.module.scss";
|
||||||
import {
|
import {
|
||||||
getWechatAccountDetail,
|
getWechatAccountDetail,
|
||||||
|
getWechatAccountSummary,
|
||||||
getWechatFriends,
|
getWechatFriends,
|
||||||
getWechatFriendDetail,
|
getWechatFriendDetail,
|
||||||
} from "./api";
|
} from "./api";
|
||||||
@@ -108,6 +109,8 @@ const WechatAccountDetail: React.FC = () => {
|
|||||||
const [searchQuery, setSearchQuery] = useState("");
|
const [searchQuery, setSearchQuery] = useState("");
|
||||||
const [activeTab, setActiveTab] = useState("overview");
|
const [activeTab, setActiveTab] = useState("overview");
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [loadingInfo, setLoadingInfo] = useState(true);
|
||||||
|
const [loadingSummary, setLoadingSummary] = useState(true);
|
||||||
|
|
||||||
// 好友列表相关状态
|
// 好友列表相关状态
|
||||||
const [friends, setFriends] = useState<Friend[]>([]);
|
const [friends, setFriends] = useState<Friend[]>([]);
|
||||||
@@ -120,31 +123,45 @@ const WechatAccountDetail: React.FC = () => {
|
|||||||
const friendsObserver = useRef<IntersectionObserver | null>(null);
|
const friendsObserver = useRef<IntersectionObserver | null>(null);
|
||||||
const friendsLoadingRef = useRef<HTMLDivElement | null>(null);
|
const friendsLoadingRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
// 获取账号概览信息
|
// 获取基础信息
|
||||||
|
const fetchAccountInfo = useCallback(async () => {
|
||||||
|
if (!id) return;
|
||||||
|
setLoadingInfo(true);
|
||||||
|
try {
|
||||||
|
const response = await getWechatAccountDetail(id);
|
||||||
|
if (response && response.data) {
|
||||||
|
setAccountInfo(response.data);
|
||||||
|
} else {
|
||||||
|
Toast.show({
|
||||||
|
content: response?.msg || "获取账号信息失败",
|
||||||
|
position: "top",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
Toast.show({ content: "获取账号信息失败", position: "top" });
|
||||||
|
} finally {
|
||||||
|
setLoadingInfo(false);
|
||||||
|
}
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
// 获取summary
|
||||||
const fetchAccountSummary = useCallback(async () => {
|
const fetchAccountSummary = useCallback(async () => {
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
|
setLoadingSummary(true);
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
const response = await getWechatAccountSummary(id);
|
||||||
const response = await getWechatAccountDetail(id);
|
|
||||||
|
|
||||||
if (response && response.data) {
|
if (response && response.data) {
|
||||||
setAccountSummary(response.data);
|
setAccountSummary(response.data);
|
||||||
setAccountInfo(response.data);
|
|
||||||
} else {
|
} else {
|
||||||
Toast.show({
|
Toast.show({
|
||||||
content: response?.msg || "获取账号概览失败",
|
content: response?.msg || "获取账号概览失败",
|
||||||
position: "top",
|
position: "top",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (e) {
|
||||||
console.error("获取账号概览失败:", error);
|
Toast.show({ content: "获取账号概览失败", position: "top" });
|
||||||
Toast.show({
|
|
||||||
content: "获取账号概览失败,请检查网络连接",
|
|
||||||
position: "top",
|
|
||||||
});
|
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setLoadingSummary(false);
|
||||||
}
|
}
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
@@ -236,12 +253,14 @@ const WechatAccountDetail: React.FC = () => {
|
|||||||
// 初始化数据
|
// 初始化数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (id) {
|
if (id) {
|
||||||
|
fetchAccountInfo();
|
||||||
fetchAccountSummary();
|
fetchAccountSummary();
|
||||||
if (activeTab === "friends") {
|
if (activeTab === "friends") {
|
||||||
fetchFriends(1, true);
|
fetchFriends(1, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [id, fetchAccountSummary]);
|
// eslint-disable-next-line
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
// 监听标签切换
|
// 监听标签切换
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -403,7 +422,7 @@ const WechatAccountDetail: React.FC = () => {
|
|||||||
setActiveTab(value);
|
setActiveTab(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isLoading) {
|
if (loadingInfo || loadingSummary) {
|
||||||
return (
|
return (
|
||||||
<Layout
|
<Layout
|
||||||
header={
|
header={
|
||||||
|
|||||||
Reference in New Issue
Block a user