From 547e235db264a1356a42a0840449a7286b0ad538 Mon Sep 17 00:00:00 2001 From: 12975 <1297598740@qq.com> Date: Sat, 31 Jan 2026 00:16:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E6=9C=8D=E5=8A=A1=E5=92=8C=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=AE=A1=E7=90=86=E4=B8=8A=E4=B8=8B=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/contexts/SettingsContext.tsx | 6 ++++++ src/services/authService.ts | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/contexts/SettingsContext.tsx b/src/contexts/SettingsContext.tsx index d3f37ce..db9976d 100644 --- a/src/contexts/SettingsContext.tsx +++ b/src/contexts/SettingsContext.tsx @@ -2,6 +2,8 @@ import React, { createContext, useContext, useState, useEffect, useCallback } fr import type { UserSettings } from '../types'; import { getSettings, updateSettings as apiUpdateSettings } from '../services/settingsService'; +import { isAuthenticated } from '../services/authService'; + interface SettingsContextType { settings: UserSettings | null; loading: boolean; @@ -18,6 +20,10 @@ export const SettingsProvider: React.FC<{ children: React.ReactNode }> = ({ chil const [error, setError] = useState(null); const fetchSettings = useCallback(async () => { + if (!isAuthenticated()) { + setLoading(false); + return; + } try { const data = await getSettings(); setSettings(data); diff --git a/src/services/authService.ts b/src/services/authService.ts index 655b519..7ea3369 100644 --- a/src/services/authService.ts +++ b/src/services/authService.ts @@ -140,7 +140,7 @@ export function getGitHubLoginUrl(state?: string): string { ? (import.meta.env.VITE_API_BASE_URL || 'http://localhost:2612/api/v1') : '/api/v1'; - console.log('[Auth] Generating GitHub URL with base:', baseUrl); + // 处理相对路径问题:URL构造函数依然需要完整的 base 才能处理相对路径 let fullUrlString; @@ -187,7 +187,7 @@ export function getGiteeLoginUrl(state?: string): string { ? (import.meta.env.VITE_API_BASE_URL || 'http://localhost:2612/api/v1') : '/api/v1'; - console.log('[Auth] Generating Gitee URL with base:', baseUrl); + let fullUrlString; if (baseUrl.startsWith('/')) {