更新
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller;
|
||||
|
||||
use app\BaseController;
|
||||
|
||||
class Index extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return $this->serveSpa('index.html');
|
||||
}
|
||||
|
||||
private function serveSpa(string $file)
|
||||
{
|
||||
$path = rtrim(public_path($file), '/\\');
|
||||
if (!is_file($path)) {
|
||||
return response('前端尚未编译,请在项目根目录执行 npm run build', 503, [
|
||||
'Content-Type' => 'text/plain; charset=utf-8',
|
||||
]);
|
||||
}
|
||||
|
||||
return response(file_get_contents($path), 200, [
|
||||
'Content-Type' => 'text/html; charset=utf-8',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user