(local: string, remote: string)
| 103 | } |
| 104 | |
| 105 | // 比较版本号 |
| 106 | function compareVersions(local: string, remote: string): { |
| 107 | hasUpdate: boolean; |
| 108 | localVersion: string; |
| 109 | remoteVersion: string; |
| 110 | } { |
| 111 | if (local === "未运行" || local === "获取失败" || remote === "获取失败") { |
| 112 | return { hasUpdate: false, localVersion: local, remoteVersion: remote }; |
| 113 | } |
| 114 | |
| 115 | const parseVersion = (v: string) => { |
| 116 | const cleaned = v.replace(/^v/, ""); |
| 117 | return cleaned.split(".").map(num => parseInt(num) || 0); |
| 118 | }; |
| 119 | |
| 120 | const localParts = parseVersion(local); |
| 121 | const remoteParts = parseVersion(remote); |
| 122 | |
| 123 | for (let i = 0; i < Math.max(localParts.length, remoteParts.length); i++) { |
| 124 | const localPart = localParts[i] || 0; |
| 125 | const remotePart = remoteParts[i] || 0; |
| 126 | |
| 127 | if (remotePart > localPart) { |
| 128 | return { hasUpdate: true, localVersion: local, remoteVersion: remote }; |
| 129 | } |
| 130 | if (localPart > remotePart) { |
| 131 | return { hasUpdate: false, localVersion: local, remoteVersion: remote }; |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | return { hasUpdate: false, localVersion: local, remoteVersion: remote }; |
| 136 | } |
| 137 | |
| 138 | const help = `🧩 <b>Sub-Store 管理</b> |
no test coverage detected