1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 16:31:13 +00:00

Change view image in encrypted libraries (#6952)

* change-view-image-in-encrypted-libraries

* fix warnings
This commit is contained in:
Michael An
2024-10-28 11:53:44 +08:00
committed by GitHub
parent 0d877b2287
commit f8a0ad52a6
3 changed files with 37 additions and 19 deletions

View File

@@ -251,27 +251,25 @@ class DirColumnNav extends React.Component {
return Utils.imageCheck(item.object.name);
});
const useThumbnail = !this.props.currentRepoInfo.encrypted;
const repoEncrypted = this.props.currentRepoInfo.encrypted;
const repoID = this.props.repoID;
let prepareItem = (item) => {
const name = item.object.name;
const path = Utils.encodePath(Utils.joinPath(node.parentNode.path, name));
const fileExt = name.substr(name.lastIndexOf('.') + 1).toLowerCase();
const isGIF = fileExt === 'gif';
const repoID = this.props.repoID;
let src = '';
if (useThumbnail && !isGIF) {
src = `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`;
const src = `${siteRoot}repo/${repoID}/raw${path}`;
let thumbnail = '';
if (repoEncrypted || isGIF) {
thumbnail = src;
} else {
src = `${siteRoot}repo/${repoID}/raw${path}`;
thumbnail = `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`;
}
return {
'name': name,
name,
src,
thumbnail,
'url': `${siteRoot}lib/${repoID}/file${path}`,
'src': src,
'thumbnail': `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`,
'node': items.find(item => item.path.split('/').pop() === name),
'downloadURL': `${fileServerRoot}repos/${repoID}/files${path}/?op=download`,
};

View File

@@ -583,14 +583,24 @@ class DirentGridView extends React.Component {
prepareImageItem = (item) => {
const name = item.name;
const repoID = this.props.repoID;
const repoEncrypted = this.props.currentRepoInfo.encrypted;
const path = Utils.encodePath(Utils.joinPath(this.props.path, name));
const cacheBuster = new Date().getTime();
const fileExt = name.substr(name.lastIndexOf('.') + 1).toLowerCase();
const isGIF = fileExt === 'gif';
const src = `${siteRoot}repo/${repoID}/raw${path}?t=${cacheBuster}`;
let thumbnail = '';
if (repoEncrypted || isGIF) {
thumbnail = src;
} else {
thumbnail = `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`;
}
return {
'name': name,
name,
thumbnail,
src,
'url': `${siteRoot}lib/${repoID}/file${path}`,
'thumbnail': `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`,
'src': `${siteRoot}repo/${repoID}/raw${path}?t=${cacheBuster}`,
'downloadURL': `${fileServerRoot}repos/${repoID}/files${path}?op=download`,
};
};

View File

@@ -184,14 +184,24 @@ class DirentListView extends React.Component {
prepareImageItem = (item) => {
const name = item.name;
const repoID = this.props.repoID;
const repoEncrypted = this.props.currentRepoInfo.encrypted;
const path = Utils.encodePath(Utils.joinPath(this.props.path, name));
const fileExt = name.substr(name.lastIndexOf('.') + 1).toLowerCase();
const isGIF = fileExt === 'gif';
const src = `${siteRoot}repo/${repoID}/raw${path}`;
let thumbnail = '';
if (repoEncrypted || isGIF) {
thumbnail = src;
} else {
thumbnail = `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`;
}
return {
'name': name,
name,
thumbnail,
src,
'url': `${siteRoot}lib/${repoID}/file${path}`,
'thumbnail': `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`,
'src': `${siteRoot}repo/${repoID}/raw${path}`,
'downloadURL': `${fileServerRoot}repos/${repoID}/files${path}/?op=download`,
'downloadURL': `${fileServerRoot}repos/${repoID}/files${path}/?op=download`
};
};