mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-29 22:10:49 +00:00
增加后台接口打包
This commit is contained in:
parent
e391bcba98
commit
3fc5695579
@ -18,8 +18,11 @@ use app\adminapi\controller\AuthController;
|
||||
use app\services\system\SystemCrudServices;
|
||||
use app\services\system\SystemMenusServices;
|
||||
use crmeb\services\crud\Make;
|
||||
use crmeb\services\FileService;
|
||||
use crmeb\utils\Terminal;
|
||||
use think\facade\App;
|
||||
use think\helper\Str;
|
||||
use think\Response;
|
||||
|
||||
/**
|
||||
* Class SystemCrud
|
||||
@ -286,4 +289,41 @@ class SystemCrud extends AuthController
|
||||
|
||||
return app('json')->success('删除成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2023/4/14
|
||||
*/
|
||||
public function npm()
|
||||
{
|
||||
$terminal = new Terminal();
|
||||
|
||||
$adminPath = $terminal->adminTemplatePath();
|
||||
|
||||
$adminPath = dirname($adminPath);
|
||||
|
||||
$dir = $adminPath . DS . 'node_modules';
|
||||
if (!is_dir($dir)) {
|
||||
$terminal->run('npm-install');
|
||||
}
|
||||
|
||||
$terminal->run('npm-build');
|
||||
|
||||
if (!is_dir($adminPath . DS . 'dist')) {
|
||||
return Response::create([
|
||||
'message' => '打包失败',
|
||||
], 'json')->getContent();
|
||||
}
|
||||
|
||||
$build = public_path() . config('app.admin_prefix');
|
||||
|
||||
$this->app->make(FileService::class)->copyDir($adminPath . DS . 'dist', $build);
|
||||
|
||||
return Response::create([
|
||||
'message' => '打包成功',
|
||||
'success' => 'ok'
|
||||
], 'json')->getContent();
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,6 +39,9 @@ class AdminAuthTokenMiddleware implements MiddlewareInterface
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$token = trim(ltrim($request->header(Config::get('cookie.token_name', 'Authori-zation')), 'Bearer'));
|
||||
if (!$token) {
|
||||
$token = trim(ltrim($request->get('token')));
|
||||
}
|
||||
/** @var AdminAuthServices $service */
|
||||
$service = app()->make(AdminAuthServices::class);
|
||||
$adminInfo = $service->parseToken($token);
|
||||
|
||||
@ -133,6 +133,8 @@ Route::group('system', function () {
|
||||
'delete' => '删除路由分类'
|
||||
],
|
||||
]);
|
||||
//执行重新打包
|
||||
Route::get('crud/npm', 'v1.setting.SystemCrud/npm')->option(['real_name' => '执行重新打包']);
|
||||
//获取CRUD列表
|
||||
Route::get('crud/column_type', 'v1.setting.SystemCrud/columnType')->option(['real_name' => '获取CRUD列表']);
|
||||
//获取菜单TREE形数据
|
||||
|
||||
@ -201,7 +201,7 @@ class Terminal
|
||||
private function output($data)
|
||||
{
|
||||
$data = [
|
||||
'data' => $data,
|
||||
'message' => $data,
|
||||
];
|
||||
return Response::create($data, 'json')->getContent();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user