feature: 面板
This commit is contained in:
parent
554b386fac
commit
5208dd3dcd
|
|
@ -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: `<video src="${fileUrl}" width="100%" height="100%" controls autoplay></video>`
|
||||
});
|
||||
} else {
|
||||
window.open(fileUrl, '_blank');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user