Skip to content
Permalink
Browse files

fix #208

  • Loading branch information...
WangNingkai committed Aug 13, 2019
1 parent 0ff0e5f commit 782d0d245134befe4df5d9c7a73a18f80d070329
@@ -287,7 +287,7 @@ public function show(Request $request)
}
$file['download'] = $file['@microsoft.graph.downloadUrl'];
foreach ($this->show as $key => $suffix) {
if (in_array($file['ext'], $suffix, false)) {
if (in_array($file['ext'] ?? '', $suffix, false)) {
$view = 'show.' . $key;
// 处理文本文件
if (in_array($key, ['stream', 'code'])) {
@@ -299,9 +299,9 @@ public function show(Request $request)
$file['content'] = Tool::getFileContent($file['@microsoft.graph.downloadUrl'], false);
if ($key === 'stream') {
$fileType
= empty(Extension::FILE_STREAM[$file['ext']])
= empty(Extension::FILE_STREAM[$file['ext'] ?? 'file'])
? 'application/octet-stream'
: Extension::FILE_STREAM[$file['ext']];
: Extension::FILE_STREAM[$file['ext'] ?? 'file'];
return response($file['content'], 200, ['Content-type' => $fileType,]);
}
@@ -84,6 +84,7 @@ class Extension
];
const FILE_STREAM = [
'file' => 'application/octet-stream',
'chm' => 'application/octet-stream',
'ppt' => 'application/vnd.ms-powerpoint',
'xls' => 'application/vnd.ms-excel',
@@ -33,7 +33,7 @@
style="text-overflow:ellipsis;overflow:hidden;white-space:nowrap;">
<a href="{{ route('search.show',$item['id']) }}"
title="{{ $item['name'] }}">
<i class="fa {{\App\Utils\Tool::getExtIcon($item['ext'])}}"></i> {{ $item['name'] }}
<i class="fa {{\App\Utils\Tool::getExtIcon($item['ext'] ?? '')}}"></i> {{ $item['name'] }}
</a>
</div>
<div class="col-sm-2 d-none d-md-block d-md-none">
@@ -115,7 +115,7 @@ class="mdui-col-sm-2 mdui-text-right">{{ \Illuminate\Support\Arr::has($item,'fo
<a href="{{ route('show',\App\Utils\Tool::encodeUrl($originPath ? $originPath.'/'.$item['name'] : $item['name'])) }}"
target="_blank">
<div class="mdui-col-xs-12 mdui-col-sm-7 mdui-text-truncate">
<i class="mdui-icon material-icons">{{ \App\Utils\Extension::getFileIcon($item['ext']) }}</i>
<i class="mdui-icon material-icons">{{ \App\Utils\Extension::getFileIcon($item['ext']??'') }}</i>
{{ $item['name'] }}
</div>
<div
@@ -178,13 +178,13 @@ class="mdui-m-t-3 thumb-view mdui-row-xs-3 mdui-row-sm-4 mdui-row-md-5 mdui-row-
<a target="_blank"
href="{{ route('show',\App\Utils\Tool::encodeUrl($originPath ? $originPath.'/'.$item['name'] : $item['name'])) }}">
<div class="col-icon">
@if(in_array($item['ext'],explode(' ',setting('image')),false))
@if(in_array($item['ext']??'',explode(' ',setting('image')),false))
<img class="lazy"
data-original="{{ \Illuminate\Support\Arr::get($item,'thumbnails.0.small.url','') }}"
src="{{ asset('img/loading.gif') }}" alt="">
@else
<img
src="{{ asset('img/'.\App\Utils\Tool::getExtIcon($item['ext'],true).'.png') }}"
src="{{ asset('img/'.\App\Utils\Tool::getExtIcon($item['ext']??'',true).'.png') }}"
alt="">
@endif
</div>
@@ -94,7 +94,7 @@ class="thumb-view mdui-row-xs-3 mdui-row-sm-4 mdui-row-md-5 mdui-row-lg-6 mdui-r
<a target="_blank"
href="{{ route('search.show',$item['id']) }}">
<div class="col-icon">
@if(in_array($item['ext'],['bmp','jpg','jpeg','png','gif']))
@if(in_array($item['ext']??'',['bmp','jpg','jpeg','png','gif']))
<img class="lazy"
data-original="{{ route('thumb',['id'=>$item['id'],'size'=>'small']) }}"
src="https://i.loli.net/2018/12/04/5c0625755d6ce.gif" alt="">

0 comments on commit 782d0d2

Please sign in to comment.
You can’t perform that action at this time.