MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / compareVersions

Function compareVersions

sub/sub.ts:105–135  ·  view source on GitHub ↗
(local: string, remote: string)

Source from the content-addressed store, hash-verified

103}
104
105// 比较版本号
106function 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
138const help = `🧩 <b>Sub-Store 管理</b>

Callers 1

SubStorePluginClass · 0.85

Calls 1

parseVersionFunction · 0.85

Tested by

no test coverage detected