diff --git a/public/assets/js/backend/oa/doc.js b/public/assets/js/backend/oa/doc.js index 609c08a..d28accd 100644 --- a/public/assets/js/backend/oa/doc.js +++ b/public/assets/js/backend/oa/doc.js @@ -86,6 +86,40 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin Controller.api.bindevent(); }, edit: function () { + + $(document).on('click', '.btn-preview', function (e) { + e.preventDefault(); + var fileType = $(this).data('filetype'); // 自动从 data-type 获取,比如 pdf, jpg, doc + var fileUrl = $(this).data('fileurl'); + + if (fileType === 'pdf') { + Layer.open({ + type: 2, + title: '预览PDF文件', + area: ['80%', '80%'], + content: fileUrl + }); + } else if (['jpg', 'jpeg', 'png', 'gif', 'webp'].includes(fileType)) { + Layer.photos({ + photos: { + "title": "图片预览", + "data": [{"src": fileUrl}] + }, + anim: 5 + }); + } else if (['mp4', 'webm', 'ogg'].includes(fileType)) { + Layer.open({ + type: 1, + title: '视频预览', + area: ['800px', '500px'], + content: `` + }); + } else { + window.open(fileUrl, '_blank'); + } + }); + + Controller.api.bindevent(); }, api: {