| 60 | |
| 61 | // 获取Sub-Store版本 |
| 62 | async function getSubStoreVersion(): Promise<string> { |
| 63 | try { |
| 64 | const containerStatus = await sh( |
| 65 | "docker ps --format '{{.Names}}' | grep sub-store" |
| 66 | ); |
| 67 | if (!containerStatus.trim()) { |
| 68 | return "未运行"; |
| 69 | } |
| 70 | |
| 71 | let logOutput = await sh( |
| 72 | "docker logs sub-store 2>&1 | grep 'Sub-Store -- v' | head -1" |
| 73 | ); |
| 74 | |
| 75 | // 如果没有找到版本信息,可能是日志不完整,重启容器生成完整日志 |
| 76 | if (!logOutput.trim()) { |
| 77 | await sh("docker restart sub-store"); |
| 78 | await sh("sleep 5"); // 等待容器启动 |
| 79 | logOutput = await sh( |
| 80 | "docker logs sub-store 2>&1 | grep 'Sub-Store -- v' | head -1" |
| 81 | ); |
| 82 | } |
| 83 | |
| 84 | const versionMatch = logOutput.match(/Sub-Store -- (v[\d.]+)/); |
| 85 | return versionMatch ? versionMatch[1] : "未知版本"; |
| 86 | } catch (error: any) { |
| 87 | return "获取失败"; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | // 获取远程最新版本 |
| 92 | async function getRemoteVersion(): Promise<string> { |