Compare commits

..

1 Commits

Author SHA1 Message Date
xiaoxian521
c31f9245ed refactor: 重构API接口响应格式,带来简洁高效的接口设计 2025-12-17 11:03:45 +08:00
3 changed files with 12 additions and 8 deletions

View File

@@ -6,7 +6,8 @@ export default defineFakeRoute([
method: "post", method: "post",
response: () => { response: () => {
return { return {
success: true, code: 0,
message: "操作成功",
data: { data: {
list: [ list: [
{ {

View File

@@ -1,7 +1,8 @@
import { http } from "@/utils/http"; import { http } from "@/utils/http";
type Result = { type Result = {
success: boolean; code: number;
message: string;
data?: { data?: {
/** 列表数据 */ /** 列表数据 */
list: Array<any>; list: Array<any>;

View File

@@ -38,12 +38,14 @@ const dataLoading = ref(true);
const getCardListData = async () => { const getCardListData = async () => {
try { try {
const { data } = await getCardList(); const { code, data } = await getCardList();
productList.value = data.list; if (code === 0) {
pagination.value = { productList.value = data.list;
...pagination.value, pagination.value = {
total: data.list.length ...pagination.value,
}; total: data.list.length
};
}
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} finally { } finally {