private void 检查更新(bool manual = false) { var 网喵喵 = new HttpClient(); try { 网喵喵.GetStringAsync("https://guest314.win/MLT/update.json").ContinueWith((Task <string> task) => { var json = JsonMapper.ToObject(task.Result); var 更新喵喵 = new 喵喵更新() { versionCode = Convert.ToInt32(json["versionCode"].ToString()), versionName = json["versionName"].ToString(), url = json["url"].ToString() }; if (更新喵喵.versionCode >= 喵喵版本号) { Device.BeginInvokeOnMainThread(() => { this.更新喵喵(更新喵喵); }); } else if (manual) { Device.BeginInvokeOnMainThread(() => { DisplayAlert("更新喵喵!", "已经是最新版本啦!" + 更新喵喵.versionCode, "喵"); }); } }); } catch (Exception e) { if (manual) { Device.BeginInvokeOnMainThread(() => { DisplayAlert("更新喵喵失败!", e.Message, "喵"); }); } } }
private void 更新喵喵(喵喵更新 喵) { DisplayAlert("发现更新!", 喵.versionName, "去更新喵", "不要更新").ContinueWith((Task <bool> 更新喵) => { if (更新喵.Result) { Device.BeginInvokeOnMainThread(() => MyHelper.OpenURL(喵.url)); } }); }