mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-24 12:07:28 +08:00
feat(admin): optimize subscription template configuration and add Surfboard subscription template
- Improved the code structure for subscription template configuration. - Added a new feature in the admin panel to configure Surfboard subscription templates.
This commit is contained in:
+7
-11
@@ -4,12 +4,15 @@ namespace App\Protocols;
|
||||
|
||||
use App\Utils\Helper;
|
||||
use App\Contracts\ProtocolInterface;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class Surge implements ProtocolInterface
|
||||
{
|
||||
public $flags = ['surge'];
|
||||
private $servers;
|
||||
private $user;
|
||||
const CUSTOM_TEMPLATE_FILE = 'resources/rules/custom.surge.conf';
|
||||
const DEFAULT_TEMPLATE_FILE = 'resources/rules/default.surge.conf';
|
||||
|
||||
public function __construct($user, $servers)
|
||||
{
|
||||
@@ -59,17 +62,10 @@ class Surge implements ProtocolInterface
|
||||
}
|
||||
}
|
||||
|
||||
// 优先从 admin_setting 获取模板
|
||||
$config = admin_setting('subscribe_template_surge');
|
||||
if (empty($config)) {
|
||||
$defaultConfig = base_path('resources/rules/default.surge.conf');
|
||||
$customConfig = base_path('resources/rules/custom.surge.conf');
|
||||
if (file_exists($customConfig)) {
|
||||
$config = file_get_contents($customConfig);
|
||||
} else {
|
||||
$config = file_get_contents($defaultConfig);
|
||||
}
|
||||
}
|
||||
|
||||
$config = File::exists(base_path(self::CUSTOM_TEMPLATE_FILE))
|
||||
? File::get(base_path(self::CUSTOM_TEMPLATE_FILE))
|
||||
: File::get(base_path(self::DEFAULT_TEMPLATE_FILE));
|
||||
|
||||
// Subscription link
|
||||
$subsDomain = request()->header('Host');
|
||||
|
||||
Reference in New Issue
Block a user