mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-24 20:17:32 +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'],
|
"remarks" => $server['name'],
|
||||||
"server" => $server['host'],
|
"server" => $server['host'],
|
||||||
"server_port" => $server['port'],
|
"server_port" => $server['port'],
|
||||||
"password" => $item['password'],
|
"password" => $server['password'],
|
||||||
"method" => data_get($server, 'protocol_settings.cipher')
|
"method" => data_get($server, 'protocol_settings.cipher')
|
||||||
];
|
];
|
||||||
return $config;
|
return $config;
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ class OrderService
|
|||||||
* @param Plan $plan
|
* @param Plan $plan
|
||||||
* @param string $period
|
* @param string $period
|
||||||
* @param string|null $couponCode
|
* @param string|null $couponCode
|
||||||
* @param array|null $telegramMessageIds
|
|
||||||
* @return Order
|
* @return Order
|
||||||
* @throws ApiException
|
* @throws ApiException
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -428,8 +428,22 @@ class PluginManager
|
|||||||
|
|
||||||
$targetPath = $this->pluginPath . '/' . Str::studly($config['code']);
|
$targetPath = $this->pluginPath . '/' . Str::studly($config['code']);
|
||||||
if (File::exists($targetPath)) {
|
if (File::exists($targetPath)) {
|
||||||
File::deleteDirectory($extractPath);
|
$installedConfigPath = $targetPath . '/config.json';
|
||||||
throw new \Exception('插件已存在');
|
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);
|
File::copyDirectory($pluginPath, $targetPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user