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

36
components.d.ts vendored
View File

@@ -15,22 +15,13 @@ declare module 'vue' {
IIcBaselineDataSaverOff: typeof import('~icons/ic/baseline-data-saver-off')['default'] IIcBaselineDataSaverOff: typeof import('~icons/ic/baseline-data-saver-off')['default']
IIcBaselineDownloading: typeof import('~icons/ic/baseline-downloading')['default'] IIcBaselineDownloading: typeof import('~icons/ic/baseline-downloading')['default']
IIcBaselineInfo: typeof import('~icons/ic/baseline-info')['default'] IIcBaselineInfo: typeof import('~icons/ic/baseline-info')['default']
IIcBaselineLightbulbOutline: typeof import('~icons/ic/baseline-lightbulb-outline')['default']
IIcBaselineReceiptLong: typeof import('~icons/ic/baseline-receipt-long')['default']
IIcOutlineAccessTime: typeof import('~icons/ic/outline-access-time')['default'] IIcOutlineAccessTime: typeof import('~icons/ic/outline-access-time')['default']
IIcRoundArrowForwardIos: typeof import('~icons/ic/round-arrow-forward-ios')['default'] IIcRoundArrowForwardIos: typeof import('~icons/ic/round-arrow-forward-ios')['default']
IonApp: typeof import('@ionic/vue')['IonApp'] IonApp: typeof import('@ionic/vue')['IonApp']
IonAvatar: typeof import('@ionic/vue')['IonAvatar'] IonAvatar: typeof import('@ionic/vue')['IonAvatar']
IonBackButton: typeof import('@ionic/vue')['IonBackButton']
IonBadge: typeof import('@ionic/vue')['IonBadge'] IonBadge: typeof import('@ionic/vue')['IonBadge']
IonButton: typeof import('@ionic/vue')['IonButton'] IonButton: typeof import('@ionic/vue')['IonButton']
IonButtons: typeof import('@ionic/vue')['IonButtons'] IonButtons: typeof import('@ionic/vue')['IonButtons']
IonCard: typeof import('@ionic/vue')['IonCard']
IonCardContent: typeof import('@ionic/vue')['IonCardContent']
IonCardHeader: typeof import('@ionic/vue')['IonCardHeader']
IonCardSubtitle: typeof import('@ionic/vue')['IonCardSubtitle']
IonCardTitle: typeof import('@ionic/vue')['IonCardTitle']
IonChip: typeof import('@ionic/vue')['IonChip']
IonCol: typeof import('@ionic/vue')['IonCol'] IonCol: typeof import('@ionic/vue')['IonCol']
IonContent: typeof import('@ionic/vue')['IonContent'] IonContent: typeof import('@ionic/vue')['IonContent']
IonDatetime: typeof import('@ionic/vue')['IonDatetime'] IonDatetime: typeof import('@ionic/vue')['IonDatetime']
@@ -43,15 +34,9 @@ declare module 'vue' {
IonInfiniteScrollContent: typeof import('@ionic/vue')['IonInfiniteScrollContent'] IonInfiniteScrollContent: typeof import('@ionic/vue')['IonInfiniteScrollContent']
IonInput: typeof import('@ionic/vue')['IonInput'] IonInput: typeof import('@ionic/vue')['IonInput']
IonItem: typeof import('@ionic/vue')['IonItem'] IonItem: typeof import('@ionic/vue')['IonItem']
IonItemOption: typeof import('@ionic/vue')['IonItemOption']
IonItemOptions: typeof import('@ionic/vue')['IonItemOptions']
IonItemSliding: typeof import('@ionic/vue')['IonItemSliding']
IonLabel: typeof import('@ionic/vue')['IonLabel'] IonLabel: typeof import('@ionic/vue')['IonLabel']
IonList: typeof import('@ionic/vue')['IonList'] IonList: typeof import('@ionic/vue')['IonList']
IonListHeader: typeof import('@ionic/vue')['IonListHeader'] IonListHeader: typeof import('@ionic/vue')['IonListHeader']
IonMenu: typeof import('@ionic/vue')['IonMenu']
IonMenuButton: typeof import('@ionic/vue')['IonMenuButton']
IonMenuToggle: typeof import('@ionic/vue')['IonMenuToggle']
IonModal: typeof import('@ionic/vue')['IonModal'] IonModal: typeof import('@ionic/vue')['IonModal']
IonNote: typeof import('@ionic/vue')['IonNote'] IonNote: typeof import('@ionic/vue')['IonNote']
IonPage: typeof import('@ionic/vue')['IonPage'] IonPage: typeof import('@ionic/vue')['IonPage']
@@ -62,11 +47,8 @@ declare module 'vue' {
IonRouterOutlet: typeof import('@ionic/vue')['IonRouterOutlet'] IonRouterOutlet: typeof import('@ionic/vue')['IonRouterOutlet']
IonRow: typeof import('@ionic/vue')['IonRow'] IonRow: typeof import('@ionic/vue')['IonRow']
IonSearchbar: typeof import('@ionic/vue')['IonSearchbar'] IonSearchbar: typeof import('@ionic/vue')['IonSearchbar']
IonSegment: typeof import('@ionic/vue')['IonSegment']
IonSegmentButton: typeof import('@ionic/vue')['IonSegmentButton']
IonSelect: typeof import('@ionic/vue')['IonSelect'] IonSelect: typeof import('@ionic/vue')['IonSelect']
IonSelectOption: typeof import('@ionic/vue')['IonSelectOption'] IonSelectOption: typeof import('@ionic/vue')['IonSelectOption']
IonSpinner: typeof import('@ionic/vue')['IonSpinner']
IonTabBar: typeof import('@ionic/vue')['IonTabBar'] IonTabBar: typeof import('@ionic/vue')['IonTabBar']
IonTabButton: typeof import('@ionic/vue')['IonTabButton'] IonTabButton: typeof import('@ionic/vue')['IonTabButton']
IonTabs: typeof import('@ionic/vue')['IonTabs'] IonTabs: typeof import('@ionic/vue')['IonTabs']
@@ -86,22 +68,13 @@ declare global {
const IIcBaselineDataSaverOff: typeof import('~icons/ic/baseline-data-saver-off')['default'] const IIcBaselineDataSaverOff: typeof import('~icons/ic/baseline-data-saver-off')['default']
const IIcBaselineDownloading: typeof import('~icons/ic/baseline-downloading')['default'] const IIcBaselineDownloading: typeof import('~icons/ic/baseline-downloading')['default']
const IIcBaselineInfo: typeof import('~icons/ic/baseline-info')['default'] const IIcBaselineInfo: typeof import('~icons/ic/baseline-info')['default']
const IIcBaselineLightbulbOutline: typeof import('~icons/ic/baseline-lightbulb-outline')['default']
const IIcBaselineReceiptLong: typeof import('~icons/ic/baseline-receipt-long')['default']
const IIcOutlineAccessTime: typeof import('~icons/ic/outline-access-time')['default'] const IIcOutlineAccessTime: typeof import('~icons/ic/outline-access-time')['default']
const IIcRoundArrowForwardIos: typeof import('~icons/ic/round-arrow-forward-ios')['default'] const IIcRoundArrowForwardIos: typeof import('~icons/ic/round-arrow-forward-ios')['default']
const IonApp: typeof import('@ionic/vue')['IonApp'] const IonApp: typeof import('@ionic/vue')['IonApp']
const IonAvatar: typeof import('@ionic/vue')['IonAvatar'] const IonAvatar: typeof import('@ionic/vue')['IonAvatar']
const IonBackButton: typeof import('@ionic/vue')['IonBackButton']
const IonBadge: typeof import('@ionic/vue')['IonBadge'] const IonBadge: typeof import('@ionic/vue')['IonBadge']
const IonButton: typeof import('@ionic/vue')['IonButton'] const IonButton: typeof import('@ionic/vue')['IonButton']
const IonButtons: typeof import('@ionic/vue')['IonButtons'] const IonButtons: typeof import('@ionic/vue')['IonButtons']
const IonCard: typeof import('@ionic/vue')['IonCard']
const IonCardContent: typeof import('@ionic/vue')['IonCardContent']
const IonCardHeader: typeof import('@ionic/vue')['IonCardHeader']
const IonCardSubtitle: typeof import('@ionic/vue')['IonCardSubtitle']
const IonCardTitle: typeof import('@ionic/vue')['IonCardTitle']
const IonChip: typeof import('@ionic/vue')['IonChip']
const IonCol: typeof import('@ionic/vue')['IonCol'] const IonCol: typeof import('@ionic/vue')['IonCol']
const IonContent: typeof import('@ionic/vue')['IonContent'] const IonContent: typeof import('@ionic/vue')['IonContent']
const IonDatetime: typeof import('@ionic/vue')['IonDatetime'] const IonDatetime: typeof import('@ionic/vue')['IonDatetime']
@@ -114,15 +87,9 @@ declare global {
const IonInfiniteScrollContent: typeof import('@ionic/vue')['IonInfiniteScrollContent'] const IonInfiniteScrollContent: typeof import('@ionic/vue')['IonInfiniteScrollContent']
const IonInput: typeof import('@ionic/vue')['IonInput'] const IonInput: typeof import('@ionic/vue')['IonInput']
const IonItem: typeof import('@ionic/vue')['IonItem'] const IonItem: typeof import('@ionic/vue')['IonItem']
const IonItemOption: typeof import('@ionic/vue')['IonItemOption']
const IonItemOptions: typeof import('@ionic/vue')['IonItemOptions']
const IonItemSliding: typeof import('@ionic/vue')['IonItemSliding']
const IonLabel: typeof import('@ionic/vue')['IonLabel'] const IonLabel: typeof import('@ionic/vue')['IonLabel']
const IonList: typeof import('@ionic/vue')['IonList'] const IonList: typeof import('@ionic/vue')['IonList']
const IonListHeader: typeof import('@ionic/vue')['IonListHeader'] const IonListHeader: typeof import('@ionic/vue')['IonListHeader']
const IonMenu: typeof import('@ionic/vue')['IonMenu']
const IonMenuButton: typeof import('@ionic/vue')['IonMenuButton']
const IonMenuToggle: typeof import('@ionic/vue')['IonMenuToggle']
const IonModal: typeof import('@ionic/vue')['IonModal'] const IonModal: typeof import('@ionic/vue')['IonModal']
const IonNote: typeof import('@ionic/vue')['IonNote'] const IonNote: typeof import('@ionic/vue')['IonNote']
const IonPage: typeof import('@ionic/vue')['IonPage'] const IonPage: typeof import('@ionic/vue')['IonPage']
@@ -133,11 +100,8 @@ declare global {
const IonRouterOutlet: typeof import('@ionic/vue')['IonRouterOutlet'] const IonRouterOutlet: typeof import('@ionic/vue')['IonRouterOutlet']
const IonRow: typeof import('@ionic/vue')['IonRow'] const IonRow: typeof import('@ionic/vue')['IonRow']
const IonSearchbar: typeof import('@ionic/vue')['IonSearchbar'] const IonSearchbar: typeof import('@ionic/vue')['IonSearchbar']
const IonSegment: typeof import('@ionic/vue')['IonSegment']
const IonSegmentButton: typeof import('@ionic/vue')['IonSegmentButton']
const IonSelect: typeof import('@ionic/vue')['IonSelect'] const IonSelect: typeof import('@ionic/vue')['IonSelect']
const IonSelectOption: typeof import('@ionic/vue')['IonSelectOption'] const IonSelectOption: typeof import('@ionic/vue')['IonSelectOption']
const IonSpinner: typeof import('@ionic/vue')['IonSpinner']
const IonTabBar: typeof import('@ionic/vue')['IonTabBar'] const IonTabBar: typeof import('@ionic/vue')['IonTabBar']
const IonTabButton: typeof import('@ionic/vue')['IonTabButton'] const IonTabButton: typeof import('@ionic/vue')['IonTabButton']
const IonTabs: typeof import('@ionic/vue')['IonTabs'] const IonTabs: typeof import('@ionic/vue')['IonTabs']

View File

@@ -5,16 +5,18 @@ import { toastController } from "@ionic/vue";
import { i18n } from "@/locales"; import { i18n } from "@/locales";
import { useMocks } from "@/mocks"; 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: { fetch: {
credentials: "include", credentials: "include",
}, },
headers() { headers() {
const token = localStorage.getItem("user-token") || ""; const token = localStorage.getItem("user-token") || "";
return { const headers = new Headers();
"Content-Type": "application/json", headers.append("Content-Type", "application/json");
"Authorization": token ? `Bearer ${token}` : "", headers.append("Authorization", token ? `Bearer ${token}` : "");
}; return headers;
}, },
}); });

View File

@@ -9,7 +9,10 @@ import CircleFlagsTw from "~icons/circle-flags/tw";
import CircleFlagsZh from "~icons/circle-flags/zh"; import CircleFlagsZh from "~icons/circle-flags/zh";
import { i18n } from "@/locales"; import { i18n } from "@/locales";
const baseURL = import.meta.env.DEV ? window.location.origin : import.meta.env.VITE_API_URL;
export const authClient = createAuthClient({ export const authClient = createAuthClient({
baseURL,
fetchOptions: { fetchOptions: {
credentials: "include", credentials: "include",
}, },

View File

@@ -24,6 +24,6 @@ ion-avatar {
--padding: 10px; --padding: 10px;
background-color: #e7f6e1; background-color: #e7f6e1;
padding: var(--padding); padding: var(--padding);
border: 2px solid #e3e3e3; border: 2px solid #e3ffcb;
} }
</style> </style>