mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
perf: 优化安装体验
This commit is contained in:
parent
033b8c702a
commit
2b0bf6cbb7
10
.env.example
10
.env.example
@ -5,16 +5,6 @@ APP_DEBUG=false
|
|||||||
APP_URL=http://localhost
|
APP_URL=http://localhost
|
||||||
|
|
||||||
ADMIN_SETTING_CACHE=60 #设置缓存时间(单位秒)
|
ADMIN_SETTING_CACHE=60 #设置缓存时间(单位秒)
|
||||||
#LaravelS配置
|
|
||||||
LARAVELS_LISTEN_IP=0.0.0.0
|
|
||||||
LARAVELS_LISTEN_PORT=80
|
|
||||||
LARAVELS_HANDLE_STATIC=true
|
|
||||||
LARAVELS_MAX_REQUEST=1000
|
|
||||||
LARAVELS_WORKER_NUM=2
|
|
||||||
LARAVELS_TIMER=true
|
|
||||||
|
|
||||||
APP_RUNNING_IN_CONSOLE=true
|
|
||||||
|
|
||||||
LOG_CHANNEL=stack
|
LOG_CHANNEL=stack
|
||||||
|
|
||||||
DB_CONNECTION=mysql
|
DB_CONNECTION=mysql
|
||||||
|
@ -45,7 +45,6 @@ class XboardInstall extends Command
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// \Artisan::call('config:clear');
|
|
||||||
$isDocker = env('docker', false);
|
$isDocker = env('docker', false);
|
||||||
$this->info("__ __ ____ _ ");
|
$this->info("__ __ ____ _ ");
|
||||||
$this->info("\ \ / /| __ ) ___ __ _ _ __ __| | ");
|
$this->info("\ \ / /| __ ) ___ __ _ _ __ __| | ");
|
||||||
@ -73,9 +72,7 @@ class XboardInstall extends Command
|
|||||||
if (!file_exists(base_path($sqliteFile))) {
|
if (!file_exists(base_path($sqliteFile))) {
|
||||||
// 创建空文件
|
// 创建空文件
|
||||||
if (!touch(base_path($sqliteFile))) {
|
if (!touch(base_path($sqliteFile))) {
|
||||||
echo "sqlite创建成功: $sqliteFile";
|
$this->info("sqlite创建成功: $sqliteFile");
|
||||||
} else {
|
|
||||||
echo "sqlite创建失败";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$envConfig = [
|
$envConfig = [
|
||||||
@ -85,6 +82,24 @@ class XboardInstall extends Command
|
|||||||
'DB_USERNAME' => '',
|
'DB_USERNAME' => '',
|
||||||
'DB_PASSWORD' => '',
|
'DB_PASSWORD' => '',
|
||||||
];
|
];
|
||||||
|
try {
|
||||||
|
\Config::set("database.default", 'sqlite');
|
||||||
|
\Config::set("database.connections.sqlite.database", base_path($envConfig['DB_DATABASE']));
|
||||||
|
\DB::purge('sqlite');
|
||||||
|
\DB::connection('sqlite')->getPdo();
|
||||||
|
if (!blank(\DB::connection('sqlite')->getPdo()->query("SELECT name FROM sqlite_master WHERE type='table'")->fetchAll(\PDO::FETCH_COLUMN))) {
|
||||||
|
if (confirm(label: '检测到数据库中已经存在数据,是否要清空数据库以便安装新的数据?', default: false, yes: '清空', no: '退出安装')) {
|
||||||
|
$this->info('正在清空数据库请稍等');
|
||||||
|
$this->call('db:wipe', ['--force' => true]);
|
||||||
|
$this->info('数据库清空完成');
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 连接失败,输出错误消息
|
||||||
|
$this->error("数据库连接失败:" . $e->getMessage());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$isMysqlValid = false;
|
$isMysqlValid = false;
|
||||||
while (!$isMysqlValid) {
|
while (!$isMysqlValid) {
|
||||||
@ -93,10 +108,11 @@ class XboardInstall extends Command
|
|||||||
'DB_HOST' => text(label: "请输入数据库地址", default: '127.0.0.1', required: true),
|
'DB_HOST' => text(label: "请输入数据库地址", default: '127.0.0.1', required: true),
|
||||||
'DB_PORT' => text(label: '请输入数据库端口', default: '3306', required: true),
|
'DB_PORT' => text(label: '请输入数据库端口', default: '3306', required: true),
|
||||||
'DB_DATABASE' => text(label: '请输入数据库名', default: 'xboard', required: true),
|
'DB_DATABASE' => text(label: '请输入数据库名', default: 'xboard', required: true),
|
||||||
'DB_USERNAME' => text(label: '请输入数据库用户名', required: true),
|
'DB_USERNAME' => text(label: '请输入数据库用户名', default: 'root', required: true),
|
||||||
'DB_PASSWORD' => text(label: '请输入数据库密码', required: false),
|
'DB_PASSWORD' => text(label: '请输入数据库密码', required: false),
|
||||||
];
|
];
|
||||||
try {
|
try {
|
||||||
|
\Config::set("database.default", 'mysql');
|
||||||
\Config::set("database.connections.mysql.host", $envConfig['DB_HOST']);
|
\Config::set("database.connections.mysql.host", $envConfig['DB_HOST']);
|
||||||
\Config::set("database.connections.mysql.port", $envConfig['DB_PORT']);
|
\Config::set("database.connections.mysql.port", $envConfig['DB_PORT']);
|
||||||
\Config::set("database.connections.mysql.database", $envConfig['DB_DATABASE']);
|
\Config::set("database.connections.mysql.database", $envConfig['DB_DATABASE']);
|
||||||
@ -105,6 +121,15 @@ class XboardInstall extends Command
|
|||||||
\DB::purge('mysql');
|
\DB::purge('mysql');
|
||||||
\DB::connection('mysql')->getPdo();
|
\DB::connection('mysql')->getPdo();
|
||||||
$isMysqlValid = true;
|
$isMysqlValid = true;
|
||||||
|
if (!blank(\DB::connection('mysql')->select('SHOW TABLES'))) {
|
||||||
|
if (confirm(label: '检测到数据库中已经存在数据,是否要清空数据库以便安装新的数据?', default: false, yes: '清空', no: '不清空')) {
|
||||||
|
$this->info('正在清空数据库请稍等');
|
||||||
|
$this->call('db:wipe', ['--force' => true]);
|
||||||
|
$this->info('数据库清空完成');
|
||||||
|
} else {
|
||||||
|
$isMysqlValid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// 连接失败,输出错误消息
|
// 连接失败,输出错误消息
|
||||||
$this->error("数据库连接失败:" . $e->getMessage());
|
$this->error("数据库连接失败:" . $e->getMessage());
|
||||||
@ -127,7 +152,7 @@ class XboardInstall extends Command
|
|||||||
$envConfig['REDIS_PASSWORD'] = text(label: '请输入redis密码(默认: null)', default: '');
|
$envConfig['REDIS_PASSWORD'] = text(label: '请输入redis密码(默认: null)', default: '');
|
||||||
}
|
}
|
||||||
$redisConfig = [
|
$redisConfig = [
|
||||||
'client' => 'phpredis', // 或 'phpredis'
|
'client' => 'phpredis',
|
||||||
'default' => [
|
'default' => [
|
||||||
'host' => $envConfig['REDIS_HOST'],
|
'host' => $envConfig['REDIS_HOST'],
|
||||||
'password' => $envConfig['REDIS_PASSWORD'],
|
'password' => $envConfig['REDIS_PASSWORD'],
|
||||||
@ -152,6 +177,7 @@ class XboardInstall extends Command
|
|||||||
;
|
;
|
||||||
$email = text(
|
$email = text(
|
||||||
label: '请输入管理员账号',
|
label: '请输入管理员账号',
|
||||||
|
default: 'admin@demo.com',
|
||||||
required: true,
|
required: true,
|
||||||
validate: fn(string $email): ?string => match (true) {
|
validate: fn(string $email): ?string => match (true) {
|
||||||
!filter_var($email, FILTER_VALIDATE_EMAIL) => '请输入有效的邮箱地址.',
|
!filter_var($email, FILTER_VALIDATE_EMAIL) => '请输入有效的邮箱地址.',
|
||||||
@ -161,14 +187,10 @@ class XboardInstall extends Command
|
|||||||
$password = Helper::guid(false);
|
$password = Helper::guid(false);
|
||||||
$this->saveToEnv($envConfig);
|
$this->saveToEnv($envConfig);
|
||||||
|
|
||||||
\Artisan::call('config:clear');
|
$this->call('config:cache');
|
||||||
\Artisan::call('config:cache');
|
$this->call('cache:clear');
|
||||||
\Artisan::call('cache:clear');
|
|
||||||
$this->info('正在清空数据库请稍等');
|
|
||||||
\Artisan::call('db:wipe');
|
|
||||||
$this->info('数据库清空完成');
|
|
||||||
$this->info('正在导入数据库请稍等...');
|
$this->info('正在导入数据库请稍等...');
|
||||||
\Artisan::call("migrate");
|
\Artisan::call("migrate", ['--force' => true]);
|
||||||
$this->info(\Artisan::output());
|
$this->info(\Artisan::output());
|
||||||
$this->info('数据库导入完成');
|
$this->info('数据库导入完成');
|
||||||
$this->info('开始注册管理员账号');
|
$this->info('开始注册管理员账号');
|
||||||
|
@ -27,7 +27,7 @@ class AddColumnVersionAndIsObfsToServerHysteriaTable extends Migration
|
|||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::table('v2_server_hysteria', function (Blueprint $table) {
|
Schema::table('v2_server_hysteria', function (Blueprint $table) {
|
||||||
$table->dropColumn('alversionpn','is_obfs');
|
$table->dropColumn('version','is_obfs');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user