Skip to content

Commit

Permalink
整理下载文件跳转
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Mar 31, 2022
1 parent 457efa1 commit ce03296
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 34 deletions.
33 changes: 0 additions & 33 deletions app/Http/Controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
use App\Tasks\DeleteTmpTask;
use App\Tasks\OverdueRemindEmailTask;
use Arr;
use Cache;
use Carbon\Carbon;
use Hhxsv5\LaravelS\Swoole\Task\Task;
use Redirect;
use Request;
use Route;


/**
Expand Down Expand Up @@ -77,36 +74,6 @@ public function version()
return $array;
}

/**
* 下载链接
* @return array|\Illuminate\Http\RedirectResponse|string
*/
public function download()
{
$id = Request::input('id');
if ($id) {
$url = Cache::get("Download::" . $id);
if ($url) {
sleep(1);
return Redirect::to($url, 301);
}
}
//
$action = Route::input('action');
if ($action) {
$url = Base::fillUrl('download?id=' . $action);
return "<script>setTimeout(function() { window.location.href = '{$url}'; }, 0)</script>";
}
//
$key = Request::input('key');
if ($key) {
$id = md5($key);
Cache::put("Download::" . $id, $key, Carbon::now()->addDay());
return Redirect::to(Base::fillUrl('download/' . $id), 301);
}
return Base::ajaxError("Timeout", [], 0, 403);
}

/**
* 接口文档
* @return \Illuminate\Http\RedirectResponse
Expand Down
1 change: 0 additions & 1 deletion resources/assets/js/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ export default {
params = data.params || {};
}
url = $A.urlAddParams(url, params);
url = $A.apiUrl(`../download?key=${encodeURIComponent(url)}`)
if ($A.Electron) {
$A.Electron.request({action: 'openExternal', url}, () => {
// 成功
Expand Down

0 comments on commit ce03296

Please sign in to comment.