MCPcopy Create free account
hub / github.com/ClydeTime/Surge / getLatestVersion

Function getLatestVersion

Script/Task/CCBLife.js:249–278  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

247
248// 获取最新版本
249async function getLatestVersion() {
250 let opt = {
251 url: `https://itunes.apple.com/cn/lookup?id=${AppId}`,
252 headers: { "Content-Type": "application/x-www-form-urlencoded" }
253 }
254 return new Promise(resolve => {
255 $.get(opt, async (err, resp, data) => {
256 try {
257 err && $.log(err);
258 if (data) {
259 try {
260 let result = JSON.parse(data);
261 const { trackName, bundleId, version, currentVersionReleaseDate, } = result.results[0];
262 AppVersion = version;
263 $.setdata(AppVersion, 'JHSH_VERSION'); // 数据持久化
264 $.log(`版本信息: ${trackName} ${version}\nBundleId: ${bundleId} \n更新时间: ${currentVersionReleaseDate}`);
265 } catch (e) {
266 $.log(e);
267 };
268 } else {
269 $.log(`版本信息获取失败\n`);
270 }
271 } catch (error) {
272 $.log(error);
273 } finally {
274 resolve();
275 }
276 })
277 })
278}
279
280 /**
281 * 对象属性转小写

Callers 1

CCBLife.jsFile · 0.85

Calls 4

getMethod · 0.45
logMethod · 0.45
parseMethod · 0.45
setdataMethod · 0.45

Tested by

no test coverage detected