webman迁移

This commit is contained in:
2026-03-18 11:22:12 +08:00
parent dab3b3148f
commit ea77c7b3a1
623 changed files with 38163 additions and 106 deletions

View File

@@ -34,6 +34,8 @@ return [
'length' => 2,
// 混淆点长度
'confuse_length' => 2,
// 自定义字体路径(当项目字体不存在且系统回退失败时可指定,如: C:\Windows\Fonts\simhei.ttf
'font_path' => '',
],
// 代理服务器IPRequest 类将尝试获取这些代理服务器发送过来的真实IP
'proxy_server_ip' => [],
@@ -42,7 +44,7 @@ return [
// 默认驱动方式
'default' => 'mysql',
// 加密key
'key' => 'tcbDgmqLVzuAdNH39o0QnhOisvSCFZ7I',
'key' => '5u9HTYBPXId3i6K4S2Q08wWRVFxCENLU',
// 加密方式
'algo' => 'ripemd160',
// 驱动

View File

@@ -6,6 +6,48 @@
*/
use Webman\Route;
use support\Response;
// ==================== 未安装时根路径重定向(迁移自 public/index.php ====================
// 当 install.lock 不存在或未完成安装时,访问 / 或 /index.html 重定向到安装页
$installLockFile = public_path('install.lock');
$installCompleteMark = 'install-end';
$installPageFile = public_path('install/index.html');
Route::get('/', function () use ($installLockFile, $installCompleteMark, $installPageFile) {
$needRedirect = is_file($installPageFile)
&& (!is_file($installLockFile) || @file_get_contents($installLockFile) !== $installCompleteMark);
if ($needRedirect) {
return new Response(302, ['Location' => '/install/']);
}
if (is_file(public_path('index.html'))) {
return new Response(302, ['Location' => '/index.html']);
}
return new Response(404, [], 'Not Found');
});
Route::get('/index.html', function () use ($installLockFile, $installCompleteMark, $installPageFile) {
$needRedirect = is_file($installPageFile)
&& (!is_file($installLockFile) || @file_get_contents($installLockFile) !== $installCompleteMark);
if ($needRedirect) {
return new Response(302, ['Location' => '/install/']);
}
$file = public_path('index.html');
return is_file($file) ? (new Response())->file($file) : new Response(404, [], 'Not Found');
});
// ==================== 安装向导(静态页) ====================
// /install、/install/、/install/index 均返回 public/install/index.html
Route::get('/install', function () {
$file = public_path('install/index.html');
return is_file($file) ? (new Response())->file($file) : new Response(404, [], 'Install page not found');
});
Route::get('/install/', function () {
$file = public_path('install/index.html');
return is_file($file) ? (new Response())->file($file) : new Response(404, [], 'Install page not found');
});
Route::get('/install/index', function () {
$file = public_path('install/index.html');
return is_file($file) ? (new Response())->file($file) : new Response(404, [], 'Install page not found');
});
// ==================== API 路由 ====================
@@ -20,7 +62,7 @@ Route::post('/api/user/logout', [\app\api\controller\User::class, 'logout']);
Route::add(['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD'], '/api/install/terminal', [\app\api\controller\Install::class, 'terminal']);
Route::post('/api/install/changePackageManager', [\app\api\controller\Install::class, 'changePackageManager']);
Route::get('/api/install/envBaseCheck', [\app\api\controller\Install::class, 'envBaseCheck']);
Route::get('/api/install/envNpmCheck', [\app\api\controller\Install::class, 'envNpmCheck']);
Route::add(['GET', 'POST'], '/api/install/envNpmCheck', [\app\api\controller\Install::class, 'envNpmCheck']);
Route::post('/api/install/testDatabase', [\app\api\controller\Install::class, 'testDatabase']);
Route::add(['GET', 'POST'], '/api/install/baseConfig', [\app\api\controller\Install::class, 'baseConfig']);
Route::post('/api/install/commandExecComplete', [\app\api\controller\Install::class, 'commandExecComplete']);
@@ -190,4 +232,4 @@ Route::get('/admin/security/dataRecycleLog/info', [\app\admin\controller\securit
// 放在最后注册;显式加上前端会请求的路径,再加固通配
Route::add('OPTIONS', '/api/index/index', [\app\common\middleware\AllowCrossDomain::class, 'optionsResponse']);
Route::add('OPTIONS', '/api/{path:.+}', [\app\common\middleware\AllowCrossDomain::class, 'optionsResponse']);
Route::add('OPTIONS', '/admin/{path:.+}', [\app\common\middleware\AllowCrossDomain::class, 'optionsResponse']);
Route::add('OPTIONS', '/admin/{path:.+}', [\app\common\middleware\AllowCrossDomain::class, 'optionsResponse']);

View File

@@ -10,11 +10,11 @@ return [
'migrate' => [
'run' => [
'cwd' => '',
'command' => 'php webman migrate:run',
'command' => 'php vendor/bin/phinx migrate',
'notes' => 'Start the database migration'
],
'rollback' => 'php webman migrate:rollback',
'breakpoint' => 'php webman migrate:breakpoint',
'rollback' => ['cwd' => '', 'command' => 'php vendor/bin/phinx rollback'],
'breakpoint' => ['cwd' => '', 'command' => 'php vendor/bin/phinx breakpoint'],
],
'install' => [
'cnpm' => 'npm install cnpm -g --registry=https://registry.npmmirror.com',

View File

@@ -42,16 +42,17 @@ return [
// 服务器地址
'hostname' => $env('database.hostname', '127.0.0.1'),
// 数据库名(与 database.php / .env 一致)
'database' => $env('database.database', 'dafuweng-buildadmin'),
'database' => $env('database.database', 'dafuweng-buildadmin-webman'),
// 用户名(与 .env DATABASE_USERNAME 一致,默认勿用 root 以免与本机 MySQL 不符)
'username' => $env('database.username', 'dafuweng-buildadmin'),
'username' => $env('database.username', 'dafuweng-buildadmin-webman'),
// 密码(与 .env DATABASE_PASSWORD 一致)
'password' => $env('database.password', '123456'),
// 端口
'hostport' => $env('database.hostport', '3306'),
// 数据库连接参数
// 数据库连接参数MYSQL_ATTR_USE_BUFFERED_QUERY 避免 "Cannot execute queries while other unbuffered queries are active"
'params' => [
\PDO::ATTR_TIMEOUT => 3,
\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
],
// 数据库编码默认采用 utf8mb4
'charset' => $env('database.charset', 'utf8mb4'),