merge: sync upstream/master from cedar2025/Xboard
合并上游 cedar2025/Xboard 的 master,并按交互决策保留本地改动。
This commit is contained in:
@@ -17,7 +17,7 @@ class CreateV2SettingsTable extends Migration
|
||||
$table->id();
|
||||
$table->string('group')->comment('设置分组')->nullable();
|
||||
$table->string('type')->comment('设置类型')->nullable();
|
||||
$table->string('name')->comment('设置名称')->uniqid();
|
||||
$table->string('name')->comment('设置名称')->unique();
|
||||
$table->string('value')->comment('设置值')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('v2_subscribe_templates', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->unique()->comment('Template key, e.g. singbox, clash');
|
||||
$table->mediumText('content')->nullable()->comment('Template content');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
$this->seedDefaults();
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('v2_subscribe_templates');
|
||||
}
|
||||
|
||||
private function seedDefaults(): void
|
||||
{
|
||||
// Fallback order matches original protocol class behavior
|
||||
$protocols = [
|
||||
'singbox' => [
|
||||
'resources/rules/custom.sing-box.json',
|
||||
'resources/rules/default.sing-box.json',
|
||||
],
|
||||
'clash' => [
|
||||
'resources/rules/custom.clash.yaml',
|
||||
'resources/rules/default.clash.yaml',
|
||||
],
|
||||
'clashmeta' => [
|
||||
'resources/rules/custom.clashmeta.yaml',
|
||||
'resources/rules/custom.clash.yaml',
|
||||
'resources/rules/default.clash.yaml',
|
||||
],
|
||||
'stash' => [
|
||||
'resources/rules/custom.stash.yaml',
|
||||
'resources/rules/custom.clash.yaml',
|
||||
'resources/rules/default.clash.yaml',
|
||||
],
|
||||
'surge' => [
|
||||
'resources/rules/custom.surge.conf',
|
||||
'resources/rules/default.surge.conf',
|
||||
],
|
||||
'surfboard' => [
|
||||
'resources/rules/custom.surfboard.conf',
|
||||
'resources/rules/default.surfboard.conf',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($protocols as $name => $fileFallbacks) {
|
||||
$existing = DB::table('v2_settings')
|
||||
->where('name', "subscribe_template_{$name}")
|
||||
->value('value');
|
||||
|
||||
if ($existing !== null && $existing !== '') {
|
||||
$content = $existing;
|
||||
} else {
|
||||
$content = '';
|
||||
foreach ($fileFallbacks as $file) {
|
||||
$path = base_path($file);
|
||||
if (File::exists($path)) {
|
||||
$content = File::get($path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DB::table('v2_subscribe_templates')->insert([
|
||||
'name' => $name,
|
||||
'content' => $content,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
// Clean up old entries from v2_settings
|
||||
DB::table('v2_settings')
|
||||
->where('name', 'like', 'subscribe_template_%')
|
||||
->delete();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('v2_admin_audit_log', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('admin_id')->index();
|
||||
$table->string('action', 64)->index()->comment('Action identifier e.g. user.update');
|
||||
$table->string('method', 10);
|
||||
$table->string('uri', 512);
|
||||
$table->text('request_data')->nullable();
|
||||
$table->string('ip', 128)->nullable();
|
||||
$table->unsignedInteger('created_at');
|
||||
$table->unsignedInteger('updated_at');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('v2_admin_audit_log');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('v2_stat_user', function (Blueprint $table) {
|
||||
$table->index(['record_at', 'user_id'], 'idx_stat_user_record_user');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('v2_stat_user', function (Blueprint $table) {
|
||||
$table->dropIndex('idx_stat_user_record_user');
|
||||
});
|
||||
}
|
||||
};
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('v2_server', function (Blueprint $table) {
|
||||
$table->json('custom_outbounds')->nullable()->after('protocol_settings');
|
||||
$table->json('custom_routes')->nullable()->after('custom_outbounds');
|
||||
$table->json('cert_config')->nullable()->after('custom_routes');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('v2_server', function (Blueprint $table) {
|
||||
$table->dropColumn(['custom_outbounds', 'custom_routes', 'cert_config']);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user