fix: 修复系统一致性与安全问题

This commit is contained in:
que01 committed 2026-10-14 17:36:46 +08:00
1 parent aaeec14733
commit f158f906d5
19 files changed
+194 -34

No files matched your search

+7 -3
View File
@@ -1,7 +1,7 @@
import { CloudUploadOutlined, DeleteOutlined, PictureOutlined } from "@ant-design/icons";
import { Alert, Button, Image, Popconfirm, Spin, Upload, message } from "antd";
import { useEffect, useMemo, useState } from "react";
import { createApiClient } from "../lib/api.js";
import { apiBaseUrl, createApiClient } from "../lib/api.js";
interface ImageUrlFieldProps {
id?: string;
@@ -50,11 +50,15 @@ export function ImageUrlField({ id, value, onChange, placeholder, scope }: Image
contentType: file.type,
...(scope ? { scope } : {}),
});
const response = await fetch(presign.uploadUrl, {
const isLocalUpload = presign.mode === "local";
const uploadUrl = isLocalUpload
? `${apiBaseUrl.replace(/\/$/, "")}${presign.uploadUrl}`
: presign.uploadUrl;
const response = await fetch(uploadUrl, {
method: "PUT",
headers: {
"content-type": file.type,
...(presign.uploadUrl.startsWith("/api/")
...(isLocalUpload
? { authorization: `Bearer ${localStorage.getItem("adminToken") ?? ""}` }
: {}),
},