make raw skin downloading more convenient

This commit is contained in:
printempw 2016-07-27 18:52:46 +08:00
parent 320a11023f
commit acfc7c4478
3 changed files with 16 additions and 2 deletions

View File

@ -90,6 +90,16 @@ class TextureController extends BaseController
$this->preview($tid, $size);
}
public function raw($tid) {
if ($t = Texture::find($tid)) {
header('Content-Type: image/png');
echo \Storage::fread(BASE_DIR."/textures/".$t->hash);
} else {
\Http::abort(404, '材质不存在');
}
}
private function checkCache($player_name)
{
// Cache friendly

View File

@ -123,5 +123,7 @@ Route::group(['middleware' => 'App\Middlewares\CheckPlayerExis
Route::get('/avatar/{base64_email}.png', 'TextureController@avatar');
Route::get('/avatar/{size}/{base64_email}.png', 'TextureController@avatarWithSize')->where(['base64_email' => '[^\\/]+?']);
Route::get('/raw/{tid}.png', 'TextureController@raw');
Route::get('/preview/{tid}.png', 'TextureController@preview');
Route::get('/preview/{size}/{tid}.png', 'TextureController@previewWithSize');

View File

@ -72,9 +72,11 @@
<td>{{ $texture->type }}</td>
</tr>
<tr>
<td>Hash</td>
<td>Hash
<i class="fa fa-question-circle" title="右键另存为即可下载原始皮肤文件" data-toggle="tooltip" data-placement="top"></i>
</td>
<td>
<a href="../textures/{{ $texture->hash }}">{{ substr($texture->hash, 0, 15) }}...</a>
<a href="../raw/{{ $texture->tid }}.png" title="{{ $texture->hash }}">{{ substr($texture->hash, 0, 15) }}...</a>
</td>
</tr>
<tr>