private async void View_ScriptNotify(object sender, NotifyEventArgs e) { try { if (!string.IsNullOrEmpty(e.Value)) { JObject jsonBody = JObject.Parse(e.Value); string method = jsonBody["method"].ToString(); string data = jsonBody["data"].ToString(); switch (method) { case "ToListPage": ImageListModel model = data.ToEntity <ImageListModel>(); PivotView.AddSelect(model.Title, new ListPage(model.Id, NowUrl, ImageCount)); break; case "ToHomePage": PivotView.AddSelect("主页", new HomePage(data)); break; case "DownTorrent": var torrent = _torrents.First(x => x.DownUrl == data); try { var file = await Http.GetBtyeAsync(data); AppSettings.DownPath = await FileHelper.DownFile(torrent.Name + ".torrent", file, AppSettings.DownPath); ShowWebViewToast(torrent.Name + "下载成功!"); } catch (Exception ex) { ShowWebViewToast(torrent.Name + "下载失败! 错误信息:" + ex.Message); } break; } } } catch (Exception ex) { ShowMessage(ex.Message); } }
private void View_ScriptNotify(object sender, NotifyEventArgs e) { if (!string.IsNullOrEmpty(e.Value)) { JObject jsonBody = JObject.Parse(e.Value); string method = jsonBody["method"].ToString(); string data = jsonBody["data"].ToString(); switch (method) { case "ToDetailPage": ImageListModel model = data.ToEntity <ImageListModel>(); PivotView.AddSelect(model.Title, new DetailPage(model.Herf)); break; case "Search": Search(data); break; } } }