mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
fix(plugin-file-manager): fix image url (#6459)
* fix(plugin-file-manager): fix image url * fix(plugin-file-manager): fix url with search part * fix(plugin-file-manager): fix lightbox preview url * fix(plugin-file-manager): encode link url
This commit is contained in:
parent
3d8c27ff1b
commit
78455c1a5d
@ -43,10 +43,10 @@ attachmentFileTypes.add({
|
||||
},
|
||||
getThumbnailURL(file) {
|
||||
if (file.preview) {
|
||||
return file.preview;
|
||||
return encodeFileURL(file.preview);
|
||||
}
|
||||
if (file.url) {
|
||||
return `${file.url}${file.thumbnailRule || ''}`;
|
||||
return encodeFileURL(`${file.url}${file.thumbnailRule || ''}`);
|
||||
}
|
||||
if (file.originFileObj) {
|
||||
return URL.createObjectURL(file.originFileObj);
|
||||
@ -65,9 +65,9 @@ attachmentFileTypes.add({
|
||||
return (
|
||||
<LightBox
|
||||
// discourageDownloads={true}
|
||||
mainSrc={list[index]?.url}
|
||||
nextSrc={list[(index + 1) % list.length]?.url}
|
||||
prevSrc={list[(index + list.length - 1) % list.length]?.url}
|
||||
mainSrc={encodeFileURL(list[index]?.url)}
|
||||
nextSrc={encodeFileURL(list[(index + 1) % list.length]?.url)}
|
||||
prevSrc={encodeFileURL(list[(index + list.length - 1) % list.length]?.url)}
|
||||
onCloseRequest={() => onSwitchIndex(null)}
|
||||
onMovePrevRequest={() => onSwitchIndex((index + list.length - 1) % list.length)}
|
||||
onMoveNextRequest={() => onSwitchIndex((index + 1) % list.length)}
|
||||
@ -264,7 +264,7 @@ function AttachmentListItem(props) {
|
||||
) : null,
|
||||
];
|
||||
const wrappedItem = file.url ? (
|
||||
<a target="_blank" rel="noopener noreferrer" href={file.url} onClick={handleClick}>
|
||||
<a target="_blank" rel="noopener noreferrer" href={encodeFileURL(file.url)} onClick={handleClick}>
|
||||
{item}
|
||||
</a>
|
||||
) : (
|
||||
|
@ -7,7 +7,7 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
export { attachmentFileTypes } from './shared';
|
||||
export { attachmentFileTypes, encodeFileURL } from './shared';
|
||||
export { useUploadStyles } from './style';
|
||||
|
||||
export * from './Upload';
|
||||
|
@ -273,9 +273,10 @@ export function encodeFileURL(url: string): string {
|
||||
return url;
|
||||
}
|
||||
|
||||
const parts = url.split('/');
|
||||
const [base, search = ''] = url.split('?');
|
||||
const parts = base.split('/');
|
||||
const filename = parts.pop();
|
||||
parts.push(encodeURIComponent(filename));
|
||||
const encodedURL = parts.join('/');
|
||||
const encodedURL = `${parts.join('/')}${search ? `?${search}` : ''}`;
|
||||
return encodedURL;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { useAPIClient, useApp, withDynamicSchemaProps } from '@nocobase/client';
|
||||
import { encodeFileURL, useAPIClient, useApp, withDynamicSchemaProps } from '@nocobase/client';
|
||||
import React, { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
||||
import Vditor from 'vditor';
|
||||
import { defaultToolbar } from '../interfaces/markdown-vditor';
|
||||
@ -81,7 +81,7 @@ export const Edit = withDynamicSchemaProps((props) => {
|
||||
data: {
|
||||
errFiles: [],
|
||||
succMap: {
|
||||
[response.data.filename]: response.data.url,
|
||||
[response.data.filename]: encodeFileURL(response.data.url),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user