mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-04 08:28:11 +00:00
Change view image in encrypted libraries (#6952)
* change-view-image-in-encrypted-libraries * fix warnings
This commit is contained in:
@@ -251,27 +251,25 @@ class DirColumnNav extends React.Component {
|
|||||||
return Utils.imageCheck(item.object.name);
|
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) => {
|
let prepareItem = (item) => {
|
||||||
const name = item.object.name;
|
const name = item.object.name;
|
||||||
|
|
||||||
const path = Utils.encodePath(Utils.joinPath(node.parentNode.path, name));
|
const path = Utils.encodePath(Utils.joinPath(node.parentNode.path, name));
|
||||||
const fileExt = name.substr(name.lastIndexOf('.') + 1).toLowerCase();
|
const fileExt = name.substr(name.lastIndexOf('.') + 1).toLowerCase();
|
||||||
const isGIF = fileExt === 'gif';
|
const isGIF = fileExt === 'gif';
|
||||||
|
const src = `${siteRoot}repo/${repoID}/raw${path}`;
|
||||||
const repoID = this.props.repoID;
|
let thumbnail = '';
|
||||||
let src = '';
|
if (repoEncrypted || isGIF) {
|
||||||
if (useThumbnail && !isGIF) {
|
thumbnail = src;
|
||||||
src = `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`;
|
|
||||||
} else {
|
} else {
|
||||||
src = `${siteRoot}repo/${repoID}/raw${path}`;
|
thumbnail = `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'name': name,
|
name,
|
||||||
|
src,
|
||||||
|
thumbnail,
|
||||||
'url': `${siteRoot}lib/${repoID}/file${path}`,
|
'url': `${siteRoot}lib/${repoID}/file${path}`,
|
||||||
'src': src,
|
|
||||||
'thumbnail': `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`,
|
|
||||||
'node': items.find(item => item.path.split('/').pop() === name),
|
'node': items.find(item => item.path.split('/').pop() === name),
|
||||||
'downloadURL': `${fileServerRoot}repos/${repoID}/files${path}/?op=download`,
|
'downloadURL': `${fileServerRoot}repos/${repoID}/files${path}/?op=download`,
|
||||||
};
|
};
|
||||||
|
@@ -583,14 +583,24 @@ class DirentGridView extends React.Component {
|
|||||||
prepareImageItem = (item) => {
|
prepareImageItem = (item) => {
|
||||||
const name = item.name;
|
const name = item.name;
|
||||||
const repoID = this.props.repoID;
|
const repoID = this.props.repoID;
|
||||||
|
const repoEncrypted = this.props.currentRepoInfo.encrypted;
|
||||||
const path = Utils.encodePath(Utils.joinPath(this.props.path, name));
|
const path = Utils.encodePath(Utils.joinPath(this.props.path, name));
|
||||||
const cacheBuster = new Date().getTime();
|
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 {
|
return {
|
||||||
'name': name,
|
name,
|
||||||
|
thumbnail,
|
||||||
|
src,
|
||||||
'url': `${siteRoot}lib/${repoID}/file${path}`,
|
'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`,
|
'downloadURL': `${fileServerRoot}repos/${repoID}/files${path}?op=download`,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@@ -184,14 +184,24 @@ class DirentListView extends React.Component {
|
|||||||
prepareImageItem = (item) => {
|
prepareImageItem = (item) => {
|
||||||
const name = item.name;
|
const name = item.name;
|
||||||
const repoID = this.props.repoID;
|
const repoID = this.props.repoID;
|
||||||
|
const repoEncrypted = this.props.currentRepoInfo.encrypted;
|
||||||
const path = Utils.encodePath(Utils.joinPath(this.props.path, name));
|
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 {
|
return {
|
||||||
'name': name,
|
name,
|
||||||
|
thumbnail,
|
||||||
|
src,
|
||||||
'url': `${siteRoot}lib/${repoID}/file${path}`,
|
'url': `${siteRoot}lib/${repoID}/file${path}`,
|
||||||
'thumbnail': `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`,
|
'downloadURL': `${fileServerRoot}repos/${repoID}/files${path}/?op=download`
|
||||||
'src': `${siteRoot}repo/${repoID}/raw${path}`,
|
|
||||||
'downloadURL': `${fileServerRoot}repos/${repoID}/files${path}/?op=download`,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user