- 修复win的协议支持

This commit is contained in:
Pine
2026-05-13 01:49:19 +08:00
parent c9a3ef92a1
commit ba737e18bd
+6 -5
View File
@@ -1,8 +1,9 @@
// API 基地址:Tauri 生产环境使用绝对路径,浏览器环境使用相对路径 // API 基地址:Tauri 生产环境使用绝对路径,浏览器/开发环境使用相对路径
// 导出供 SSE、媒体文件等非 fetch 场景使用 // 判断依据:Tauri v2 在 Windows 上使用 https://tauri.localhostprotocol=https:),
const BASE = window.location.protocol === 'http:' || window.location.protocol === 'https:' // 在 macOS 上使用 tauri://localhostprotocol=tauri:),因此用 hostname 而非 protocol 判断
? '' // 浏览器环境 — 同源请求 const BASE = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'
: 'http://localhost:10801'; // Tauri 生产环境 (tauri://) ? '' // 同源请求(开发模式 localhost:1420 或浏览器)
: 'http://localhost:10801'; // Tauri 生产环境 (tauri://localhost / https://tauri.localhost)
export const API_BASE = BASE; export const API_BASE = BASE;
async function request(url, options = {}) { async function request(url, options = {}) {