diff --git a/app/Protocols/Shadowsocks.php b/app/Protocols/Shadowsocks.php index 6ed9b79..c0a6da6 100644 --- a/app/Protocols/Shadowsocks.php +++ b/app/Protocols/Shadowsocks.php @@ -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; diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index dc9fa02..10b1eb9 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -37,7 +37,6 @@ class OrderService * @param Plan $plan * @param string $period * @param string|null $couponCode - * @param array|null $telegramMessageIds * @return Order * @throws ApiException */ diff --git a/app/Services/Plugin/PluginManager.php b/app/Services/Plugin/PluginManager.php index 4edd1ff..ac0e6c1 100644 --- a/app/Services/Plugin/PluginManager.php +++ b/app/Services/Plugin/PluginManager.php @@ -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);