fix: 修复系统一致性与安全问题
This commit is contained in:
1 parent
aaeec14733
commit
f158f906d5
19 files changed
+194
-34
No files matched your search
@@ -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") ?? ""}` }
|
||||
: {}),
|
||||
},
|
||||
|
||||
@@ -47,7 +47,6 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
const [miniAppSettingsForm] = Form.useForm<{
|
||||
appId: string;
|
||||
apiBaseUrl: string;
|
||||
artifactPath: string;
|
||||
privateKey?: string;
|
||||
}>();
|
||||
const brand = useQuery({
|
||||
@@ -92,7 +91,6 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
miniAppSettingsForm.setFieldsValue({
|
||||
appId: miniAppSettings.data.appId,
|
||||
apiBaseUrl: miniAppSettings.data.apiBaseUrl,
|
||||
artifactPath: miniAppSettings.data.artifactPath,
|
||||
privateKey: "",
|
||||
});
|
||||
}, [miniAppSettings.data, miniAppSettingsForm]);
|
||||
@@ -202,10 +200,10 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
},
|
||||
});
|
||||
const saveMiniAppSettings = useMutation({
|
||||
mutationFn: (values: { appId: string; artifactPath: string; privateKey?: string }) =>
|
||||
mutationFn: (values: { appId: string; apiBaseUrl: string; privateKey?: string }) =>
|
||||
client.updateAdminMiniAppSettings({
|
||||
appId: values.appId,
|
||||
artifactPath: values.artifactPath,
|
||||
apiBaseUrl: values.apiBaseUrl,
|
||||
...(values.privateKey ? { privateKey: values.privateKey } : {}),
|
||||
}),
|
||||
onSuccess: () => {
|
||||
|
||||
Reference in new issue
Block a user