mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-03 15:56:22 +00:00
✨ feat: 更新标签列表获取逻辑,支持空数据处理
This commit is contained in:
@ -3,8 +3,8 @@ import type { BaseResponse } from "@/models/resp";
|
||||
import axiosClient from "./client";
|
||||
|
||||
|
||||
export async function listLabels(): Promise<BaseResponse<Label[]>> {
|
||||
const res = await axiosClient.get<BaseResponse<Label[]>>("/label/list", {
|
||||
export async function listLabels(): Promise<BaseResponse<Label[] | null>> {
|
||||
const res = await axiosClient.get<BaseResponse<Label[] | null>>("/label/list", {
|
||||
});
|
||||
return res.data;
|
||||
}
|
@ -68,7 +68,7 @@ export default function BlogHome() {
|
||||
// 获取标签
|
||||
useEffect(() => {
|
||||
listLabels().then(data => {
|
||||
setLabels(data.data);
|
||||
setLabels(data.data || []);
|
||||
console.log("Labels:", data.data);
|
||||
}).catch(error => {
|
||||
console.error("Failed to fetch labels:", error);
|
||||
|
Reference in New Issue
Block a user