mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-23 19:37:35 +08:00
feat: add plugin update support + fix bugs
This commit is contained in:
@@ -47,7 +47,7 @@ class Shadowsocks extends AbstractProtocol
|
||||
"remarks" => $server['name'],
|
||||
"server" => $server['host'],
|
||||
"server_port" => $server['port'],
|
||||
"password" => $item['password'],
|
||||
"password" => $server['password'],
|
||||
"method" => data_get($server, 'protocol_settings.cipher')
|
||||
];
|
||||
return $config;
|
||||
|
||||
@@ -37,7 +37,6 @@ class OrderService
|
||||
* @param Plan $plan
|
||||
* @param string $period
|
||||
* @param string|null $couponCode
|
||||
* @param array|null $telegramMessageIds
|
||||
* @return Order
|
||||
* @throws ApiException
|
||||
*/
|
||||
|
||||
@@ -428,8 +428,22 @@ class PluginManager
|
||||
|
||||
$targetPath = $this->pluginPath . '/' . Str::studly($config['code']);
|
||||
if (File::exists($targetPath)) {
|
||||
File::deleteDirectory($extractPath);
|
||||
throw new \Exception('插件已存在');
|
||||
$installedConfigPath = $targetPath . '/config.json';
|
||||
if (!File::exists($installedConfigPath)) {
|
||||
throw new \Exception('已安装插件缺少配置文件,无法判断是否可升级');
|
||||
}
|
||||
$installedConfig = json_decode(File::get($installedConfigPath), true);
|
||||
|
||||
$oldVersion = $installedConfig['version'] ?? null;
|
||||
$newVersion = $config['version'] ?? null;
|
||||
if (!$oldVersion || !$newVersion) {
|
||||
throw new \Exception('插件缺少版本号,无法判断是否可升级');
|
||||
}
|
||||
if (version_compare($newVersion, $oldVersion, '<=')) {
|
||||
throw new \Exception('上传插件版本不高于已安装版本,无法升级');
|
||||
}
|
||||
|
||||
File::deleteDirectory($targetPath);
|
||||
}
|
||||
|
||||
File::copyDirectory($pluginPath, $targetPath);
|
||||
|
||||
Reference in New Issue
Block a user