mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-09-05 23:57:19 +08:00
fix: URL format when generating links
This commit is contained in:
@@ -44,7 +44,12 @@ export const DirectLinkModal = memo(function DirectLinkModal({ entry, path, open
|
|||||||
try {
|
try {
|
||||||
const fullPath = (path === '/' ? '' : path) + '/' + entry.name;
|
const fullPath = (path === '/' ? '' : path) + '/' + entry.name;
|
||||||
const res = await vfsApi.getTempLinkToken(fullPath, expiresIn);
|
const res = await vfsApi.getTempLinkToken(fullPath, expiresIn);
|
||||||
setLink(res.url);
|
let url = res.url;
|
||||||
|
if (url && !url.startsWith('http://') && !url.startsWith('https://')) {
|
||||||
|
const origin = window.location.origin;
|
||||||
|
url = url.startsWith('/') ? origin + url : origin + '/' + url;
|
||||||
|
}
|
||||||
|
setLink(url);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
message.error(e.message || '生成链接失败');
|
message.error(e.message || '生成链接失败');
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user