feat: 更新 API 客户端配置,使用环境变量设置 baseURL;优化头像组件样式

This commit is contained in:
2025-12-29 14:26:38 +07:00
parent d2c438f3d4
commit e0d64261e1
4 changed files with 11 additions and 42 deletions

View File

@@ -5,16 +5,18 @@ import { toastController } from "@ionic/vue";
import { i18n } from "@/locales";
import { useMocks } from "@/mocks";
const client = treaty<App>(window.location.origin, {
const baseURL = import.meta.env.DEV ? window.location.origin : import.meta.env.VITE_API_URL;
const client = treaty<App>(baseURL, {
fetch: {
credentials: "include",
},
headers() {
const token = localStorage.getItem("user-token") || "";
return {
"Content-Type": "application/json",
"Authorization": token ? `Bearer ${token}` : "",
};
const headers = new Headers();
headers.append("Content-Type", "application/json");
headers.append("Authorization", token ? `Bearer ${token}` : "");
return headers;
},
});