44 lines
1.6 KiB
PHP
44 lines
1.6 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
|
// +----------------------------------------------------------------------
|
|
// | Author: liu21st <liu21st@gmail.com>
|
|
// +----------------------------------------------------------------------
|
|
use think\facade\Console;
|
|
use think\facade\Route;
|
|
|
|
// 短链接跳转:302到PC主页,由前端解析并上报指纹
|
|
Route::get('s/:code', function ($code) {
|
|
$link = \app\common\model\ShortLink::where('code', $code)->findOrEmpty();
|
|
if ($link->isEmpty()) {
|
|
return response('链接不存在或已失效', 404);
|
|
}
|
|
|
|
$targetUrl = request()->domain() . '/pc?slc=' . $code;
|
|
return redirect($targetUrl, 302);
|
|
})->pattern(['code' => '[A-Za-z0-9]{6,16}']);
|
|
|
|
// 管理后台
|
|
Route::rule('admin/:any', function () {
|
|
return view(app()->getRootPath() . 'public/admin/index.html');
|
|
})->pattern(['any' => '\w+']);
|
|
|
|
// 手机端
|
|
Route::rule('mobile/:any', function () {
|
|
return view(app()->getRootPath() . 'public/mobile/index.html');
|
|
})->pattern(['any' => '\w+']);
|
|
|
|
// PC端
|
|
Route::rule('pc/:any', function () {
|
|
return view(app()->getRootPath() . 'public/pc/index.html');
|
|
})->pattern(['any' => '\w+']);
|
|
|
|
//定时任务
|
|
Route::rule('crontab', function () {
|
|
Console::call('crontab');
|
|
});
|