mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 03:52:50 +00:00
perf: 文件查看图片直接弹窗浏览
This commit is contained in:
parent
ce03296078
commit
dde28136e1
@ -90,6 +90,10 @@ class FileController extends AbstractController
|
||||
}
|
||||
}
|
||||
}
|
||||
// 图片直接返回预览地址
|
||||
foreach ($array as &$item) {
|
||||
File::handleImageUrl($item);
|
||||
}
|
||||
return Base::retSuccess('success', $array);
|
||||
}
|
||||
|
||||
@ -757,6 +761,7 @@ class FileController extends AbstractController
|
||||
//
|
||||
$data = $tmpRow->toArray();
|
||||
$data['full_name'] = $webkitRelativePath ?: $data['name'];
|
||||
File::handleImageUrl($data);
|
||||
return Base::retSuccess($data['name'] . ' 上传成功', $data);
|
||||
});
|
||||
}
|
||||
|
||||
@ -75,6 +75,13 @@ class File extends AbstractModel
|
||||
'ppt', 'pptx',
|
||||
];
|
||||
|
||||
/**
|
||||
* 图片文件
|
||||
*/
|
||||
const imageExt = [
|
||||
'jpg', 'jpeg', 'png', 'gif', 'bmp'
|
||||
];
|
||||
|
||||
/**
|
||||
* 本地媒体文件
|
||||
*/
|
||||
@ -285,6 +292,21 @@ class File extends AbstractModel
|
||||
Task::deliver($task);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理返回图片地址
|
||||
* @param $item
|
||||
* @return void
|
||||
*/
|
||||
public static function handleImageUrl(&$item)
|
||||
{
|
||||
if (in_array($item['ext'], self::imageExt) ) {
|
||||
$content = Base::json2array(FileContent::whereFid($item['id'])->orderByDesc('id')->value('content'));
|
||||
if ($content) {
|
||||
$item['image_url'] = Base::fillUrl($content['url']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件并检测权限
|
||||
* @param $id
|
||||
|
||||
@ -880,12 +880,23 @@ export default {
|
||||
this.searchKey = '';
|
||||
this.pid = item.id;
|
||||
} else {
|
||||
// 图片直接浏览
|
||||
if (item.image_url) {
|
||||
const list = this.fileList.filter(({image_url}) => !!image_url)
|
||||
if (list.length > 0) {
|
||||
this.$store.state.previewImageIndex = list.findIndex(({id}) => item.id === id);
|
||||
this.$store.state.previewImageList = list.map(item => item.image_url);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 客户端打开独立窗口
|
||||
if (this.$Electron) {
|
||||
this.openSingle(item);
|
||||
} else {
|
||||
this.fileInfo = item;
|
||||
this.fileShow = true;
|
||||
return;
|
||||
}
|
||||
// 正常显示弹窗
|
||||
this.fileInfo = item;
|
||||
this.fileShow = true;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user