diff --git a/README.md b/README.md index 44e6662..1281cbc 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ 计划实现的功能 ------------------- -文件预览 +文件预览(图像,视频ok) 文件收集 diff --git a/controllers/HomeController.php b/controllers/HomeController.php index 348bc66..db2e70e 100644 --- a/controllers/HomeController.php +++ b/controllers/HomeController.php @@ -84,7 +84,8 @@ class HomeController extends Controller $type = FileTypeDetector::detect($absolutePath); $lastModified = filemtime($absolutePath); $size = is_file($absolutePath) ? filesize($absolutePath) : null; - $directoryContents[$key] = ['name' => $item, 'type' => $type, 'lastModified' => $lastModified, 'size' => $size]; + $rawType = is_file($absolutePath) ? mime_content_type($absolutePath) : null; + $directoryContents[$key] = ['name' => $item, 'type' => $type, 'lastModified' => $lastModified, 'size' => $size, 'rawType' => $rawType]; } return $this->render('index', [ 'directoryContents' => $directoryContents, diff --git a/views/home/index.php b/views/home/index.php index f173d45..4afc39f 100644 --- a/views/home/index.php +++ b/views/home/index.php @@ -6,6 +6,7 @@ /* @var $directory string 当前路径 */ +use app\assets\PlyrAsset; use app\assets\ViewerJsAsset; use app\models\NewFolderForm; use app\models\RenameForm; @@ -26,6 +27,7 @@ $this->params['breadcrumbs'][] = $this->title; FontAwesomeAsset::register($this); JqueryAsset::register($this); ViewerJsAsset::register($this); +PlyrAsset::register($this); $this->registerCssFile('@web/css/home_style.css'); ?>
+ | 名称 | 最近修改时间 | 大小 | @@ -113,7 +116,10 @@ $this->registerCssFile('@web/css/home_style.css'); user->id . '/' . $relativePath; ?>|
---|---|---|---|---|
+ | + | = Html::tag('i', '', ['class' => $item['type'] . ' file_icon']) ?> @@ -141,8 +147,9 @@ $this->registerCssFile('@web/css/home_style.css'); | = Html::tag('i', '', ['class' => $item['type'] . ' file_icon']) ?> - = Html::a($item['name'], ['home/preview', 'relativePath' => $relativePath], ['class' => 'file_name', 'onclick' => 'previewImage(this, event)']) ?> + + = Html::a($item['name'], ['home/download', 'relativePath' => $relativePath, 'type' => $item['rawType']], ['class' => 'file_name', 'onclick' => 'previewVideo(this, event)']) ?> = Html::a($item['name'], ['home/download', 'relativePath' => $relativePath], ['class' => 'file_name']) ?> @@ -171,6 +178,14 @@ $this->registerCssFile('@web/css/home_style.css'); |