mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(view) add support of pdf
This commit is contained in:
parent
1f07a199db
commit
dda32c3a40
1 changed files with 29 additions and 0 deletions
|
|
@ -123,9 +123,33 @@ async function show(data, options) {
|
|||
|
||||
case 'media':
|
||||
return viewMedia(path);
|
||||
|
||||
case 'pdf':
|
||||
return viewPDF(path);
|
||||
}
|
||||
}
|
||||
|
||||
async function viewPDF(src) {
|
||||
const element = createElement('iframe', {
|
||||
src,
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
});
|
||||
|
||||
element.addEventListener('load', () => {
|
||||
element.contentWindow.addEventListener('keydown', listener);
|
||||
});
|
||||
|
||||
const options = {
|
||||
...Config,
|
||||
};
|
||||
|
||||
if (CloudCmd.config('showFileName'))
|
||||
options.title = Info.name;
|
||||
|
||||
modal.open(element, options);
|
||||
}
|
||||
|
||||
async function viewMedia(path) {
|
||||
const [e, element] = await getMediaElement(path);
|
||||
|
||||
|
|
@ -259,7 +283,12 @@ function isVideo(name) {
|
|||
return /\.(mp4|avi)$/i.test(name);
|
||||
}
|
||||
|
||||
const isPDF = (name) => /\.(pdf)$/i.test(name);
|
||||
|
||||
function getType(name) {
|
||||
if (isPDF(name))
|
||||
return 'pdf';
|
||||
|
||||
if (isImage(name))
|
||||
return 'image';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue