diff --git a/assets/ViewerJsAsset.php b/assets/ViewerJsAsset.php index 5186b0e..577398b 100644 --- a/assets/ViewerJsAsset.php +++ b/assets/ViewerJsAsset.php @@ -10,4 +10,7 @@ class ViewerJsAsset extends AssetBundle public $js = [ 'viewer.min.js', ]; + public $css = [ + 'viewer.min.css' + ]; } \ No newline at end of file diff --git a/views/home/index.php b/views/home/index.php index ec02da8..f173d45 100644 --- a/views/home/index.php +++ b/views/home/index.php @@ -97,7 +97,7 @@ $this->registerCssFile('@web/css/home_style.css'); - + @@ -140,7 +140,12 @@ $this->registerCssFile('@web/css/home_style.css');
$item['type'] . ' file_icon']) ?> - $relativePath], ['class' => 'file_name']) ?> + + + $relativePath], ['class' => 'file_name', 'onclick' => 'previewImage(this, event)']) ?> + + $relativePath], ['class' => 'file_name']) ?> + diff --git a/web/js/home_script.js b/web/js/home_script.js index 4556286..5c660f7 100644 --- a/web/js/home_script.js +++ b/web/js/home_script.js @@ -391,8 +391,34 @@ function updateButtons() { $('.batch-delete-btn').toggle(count >= 1); } -// 在页面加载时调用updateButtons函数 -$(document).ready(updateButtons); - // 当checkbox的状态改变时,调用updateButtons函数 -$(document).on('change', '.select-item', updateButtons); \ No newline at end of file +$(document).on('change', '.select-item', updateButtons); + +$(document).ready(function() { + updateButtons(); +}); + +// image preview +function previewImage(element, event) { + event.preventDefault(); // 阻止默认的点击事件 + var hiddenImage = document.getElementById('hidden-image'); + hiddenImage.src = element.href; // 设置图像的URL + + // 创建一个新的 Viewer.js 实例 + var viewer = new Viewer(hiddenImage, { + toolbar: { + zoomIn: 1, + zoomOut: 1, + oneToOne: 1, + reset: 1, + rotateLeft: 1, + rotateRight: 1, + flipHorizontal: 1, + flipVertical: 1, + }, + hidden: function() { + viewer.destroy(); + } + }); + viewer.show(); +}