Kaynağa Gözat

fix: admin 前端 VITE_API_BASE 使用 ?? 替代 || 支持空字符串

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
mengboxin137-blip 7 saat önce
ebeveyn
işleme
183bbeefd6

+ 1 - 1
admin-frontend/src/components/Layout/Sidebar.tsx

@@ -11,7 +11,7 @@ import {
   Cpu,
 } from 'lucide-react'
 
-const API_BASE = import.meta.env.VITE_API_BASE || 'http://localhost:8000'
+const API_BASE = import.meta.env.VITE_API_BASE ?? 'http://localhost:8000'
 
 function useBranding() {
   const [branding, setBranding] = useState({ system_name: '', system_logo: '' })

+ 1 - 1
admin-frontend/src/pages/Login.tsx

@@ -106,7 +106,7 @@ const Login: React.FC = () => {
             type="button"
             onClick={async () => {
               try {
-                const API_BASE = import.meta.env.VITE_API_BASE || 'http://localhost:8000'
+                const API_BASE = import.meta.env.VITE_API_BASE ?? 'http://localhost:8000'
                 const resp = await fetch(`${API_BASE}/api/admin/sso/config`)
                 const data = await resp.json()
                 if (data.sso_enabled && data.authorize_url) {

+ 1 - 1
admin-frontend/src/pages/SSOCallback.tsx

@@ -3,7 +3,7 @@ import { useNavigate, useSearchParams } from 'react-router-dom'
 import { useAuthStore } from '../store/authStore'
 import { Loader2 } from 'lucide-react'
 
-const API_BASE = import.meta.env.VITE_API_BASE || 'http://localhost:8000'
+const API_BASE = import.meta.env.VITE_API_BASE ?? 'http://localhost:8000'
 
 const SSOCallback: React.FC = () => {
   const navigate = useNavigate()

+ 1 - 1
admin-frontend/src/services/api.ts

@@ -1,6 +1,6 @@
 import CryptoJS from 'crypto-js'
 
-const API_BASE = import.meta.env.VITE_API_BASE || 'http://localhost:8000'
+const API_BASE = import.meta.env.VITE_API_BASE ?? 'http://localhost:8000'
 
 // SHA256哈希函数(使用 crypto-js)
 async function sha256(message: string): Promise<string> {