mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-12 13:24:52 +00:00
add pdf thumbnail (#6157)
Co-authored-by: 孙永强 <11704063+s-yongqiang@user.noreply.gitee.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
||||
import cookie from 'react-cookies';
|
||||
import moment from 'moment';
|
||||
import { navigate } from '@gatsbyjs/reach-router';
|
||||
import { gettext, siteRoot, username, enableVideoThumbnail } from '../../utils/constants';
|
||||
import { gettext, siteRoot, username, enableVideoThumbnail, enablePDFThumbnail } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import collabServer from '../../utils/collab-server';
|
||||
@@ -538,7 +538,7 @@ class LibContentView extends React.Component {
|
||||
|
||||
getThumbnails = (repoID, path, direntList) => {
|
||||
let items = direntList.filter((item) => {
|
||||
return (Utils.imageCheck(item.name) || (enableVideoThumbnail && Utils.videoCheck(item.name))) && !item.encoded_thumbnail_src;
|
||||
return (Utils.imageCheck(item.name) || (enableVideoThumbnail && Utils.videoCheck(item.name)) || (enablePDFThumbnail && Utils.pdfCheck(item.name))) && !item.encoded_thumbnail_src;
|
||||
});
|
||||
if (items.length == 0) {
|
||||
return ;
|
||||
|
@@ -5,7 +5,7 @@ import { Link, navigate } from '@gatsbyjs/reach-router';
|
||||
import moment from 'moment';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import { gettext, siteRoot, enableVideoThumbnail } from '../../utils/constants';
|
||||
import { gettext, siteRoot, enableVideoThumbnail, enablePDFThumbnail } from '../../utils/constants';
|
||||
import EmptyTip from '../../components/empty-tip';
|
||||
import Loading from '../../components/loading';
|
||||
import toaster from '../../components/toast';
|
||||
@@ -79,7 +79,10 @@ class TableBody extends Component {
|
||||
|
||||
getThumbnails() {
|
||||
let items = this.state.items.filter((item) => {
|
||||
return (Utils.imageCheck(item.obj_name) || (enableVideoThumbnail && Utils.videoCheck(item.obj_name))) && !item.repo_encrypted && !item.encoded_thumbnail_src && !item.deleted;
|
||||
return (Utils.imageCheck(item.obj_name) ||
|
||||
(enableVideoThumbnail && Utils.videoCheck(item.obj_name)) ||
|
||||
(enablePDFThumbnail && Utils.pdfCheck(item.obj_name))) &&
|
||||
!item.repo_encrypted && !item.encoded_thumbnail_src && !item.deleted;
|
||||
});
|
||||
if (items.length == 0) {
|
||||
return ;
|
||||
|
@@ -30,7 +30,7 @@ let {
|
||||
repoID, relativePath,
|
||||
mode, thumbnailSize, zipped,
|
||||
trafficOverLimit, canDownload,
|
||||
noQuota, canUpload, enableVideoThumbnail
|
||||
noQuota, canUpload, enableVideoThumbnail, enablePDFThumbnail
|
||||
} = window.shared.pageOptions;
|
||||
|
||||
const showDownloadIcon = !trafficOverLimit && canDownload;
|
||||
@@ -111,7 +111,8 @@ class SharedDirView extends React.Component {
|
||||
let items = this.state.items.filter((item) => {
|
||||
return !item.is_dir &&
|
||||
(Utils.imageCheck(item.file_name) ||
|
||||
(enableVideoThumbnail && Utils.videoCheck(item.file_name))) &&
|
||||
(enableVideoThumbnail && Utils.videoCheck(item.file_name)) ||
|
||||
(enablePDFThumbnail && Utils.pdfCheck(item.file_name))) &&
|
||||
!item.encoded_thumbnail_src;
|
||||
});
|
||||
if (items.length == 0) {
|
||||
|
@@ -91,6 +91,7 @@ export const curNoteID = window.app.pageOptions.curNoteID;
|
||||
export const enableTC = window.app.pageOptions.enableTC;
|
||||
|
||||
export const enableVideoThumbnail = window.app.pageOptions.enableVideoThumbnail;
|
||||
export const enablePDFThumbnail = window.app.pageOptions.enablePDFThumbnail;
|
||||
|
||||
export const enableOnlyoffice = window.app.pageOptions.enableOnlyoffice || false;
|
||||
export const onlyofficeConverterExtensions = window.app.pageOptions.onlyofficeConverterExtensions || [];
|
||||
|
@@ -124,6 +124,19 @@ export const Utils = {
|
||||
}
|
||||
},
|
||||
|
||||
pdfCheck: function(filename) {
|
||||
if (filename.lastIndexOf('.') == -1) {
|
||||
return false;
|
||||
}
|
||||
var file_ext = filename.substr(filename.lastIndexOf('.') + 1).toLowerCase();
|
||||
var image_exts = ['pdf'];
|
||||
if (image_exts.indexOf(file_ext) != -1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
getShareLinkPermissionList: function(itemType, permission, path, canEdit) {
|
||||
// itemType: library, dir, file
|
||||
// permission: rw, r, admin, cloud-edit, preview, custom-*
|
||||
|
Reference in New Issue
Block a user