From 4c19054b303627295c9678dbe7546c98cba2bdeb Mon Sep 17 00:00:00 2001 From: whyour Date: Fri, 29 Sep 2023 16:26:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20api=20=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/index.tsx | 6 +++--- src/pages/setting/other.tsx | 2 +- src/pages/setting/security.tsx | 8 +++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx index a1c764d8..fdf22349 100644 --- a/src/layouts/index.tsx +++ b/src/layouts/index.tsx @@ -178,7 +178,7 @@ export default function () { useEffect(() => { if (!user || !user.username) return; const ws = WebSocketManager.getInstance( - `${window.location.origin}${window.__ENV__QlBaseUrl || '/'}api/ws?token=${localStorage.getItem( + `${window.location.origin}${config.apiPrefix}ws?token=${localStorage.getItem( config.authKey, )}`, ); @@ -320,7 +320,7 @@ export default function () { shape="square" size="small" icon={} - src={user.avatar ? `/api/static/${user.avatar}` : ''} + src={user.avatar ? `${config.apiPrefix}static/${user.avatar}` : ''} /> {user.username} @@ -342,7 +342,7 @@ export default function () { shape="square" size="small" icon={} - src={user.avatar ? `/api/static/${user.avatar}` : ''} + src={user.avatar ? `${config.apiPrefix}static/${user.avatar}` : ''} /> {user.username} diff --git a/src/pages/setting/other.tsx b/src/pages/setting/other.tsx index c0804a19..52470f3a 100644 --- a/src/pages/setting/other.tsx +++ b/src/pages/setting/other.tsx @@ -253,7 +253,7 @@ const Other = ({ method="put" showUploadList={false} maxCount={1} - action="/api/system/data/import" + action={`${config.apiPrefix}system/data/import`} onChange={(e) => { if (e.event?.percent) { showUploadProgress(parseFloat(e.event?.percent.toFixed(1))); diff --git a/src/pages/setting/security.tsx b/src/pages/setting/security.tsx index 0a8174d3..19d98d09 100644 --- a/src/pages/setting/security.tsx +++ b/src/pages/setting/security.tsx @@ -97,14 +97,16 @@ const SecuritySettings = ({ user, userChange }: any) => { const onChange = (e) => { if (e.file && e.file.response) { - setAvatar(`/api/static/${e.file.response.data}`); + setAvatar( + `${config.apiPrefix}static/${e.file.response.data}`, + ); userChange(); } }; useEffect(() => { setTwoFactorActivated(user && user.twoFactorActivated); - setAvatar(user.avatar && `/api/static/${user.avatar}`); + setAvatar(user.avatar && `${config.apiPrefix}static/${user.avatar}`); }, [user]); return twoFactoring ? ( @@ -250,7 +252,7 @@ const SecuritySettings = ({ user, userChange }: any) => { method="put" showUploadList={false} maxCount={1} - action="/api/user/avatar" + action={`${config.apiPrefix}user/avatar`} onChange={onChange} name="avatar" headers={{