public LoginViewModel() { if (CookieHelper.CheckLogin()) { UserName = AppSettingService.GetKeyValue(SettingKey.UserName) as string; } }
public async void GetData() { if (!CookieHelper.CheckLogin() || IsLoading) { return; } try { IsLoading = true; var html = await GetHtmlData2(SoduPageValue.BookShelfPage, false, true); var list = ListPageDataHelper.GetBookShelftListFromHtml(html); if (list == null || list.Count == 0) { if (html != null && html.Contains(SoduPageValue.BookShelfPage)) { Books = null; ToastHelper.ShowMessage("您的在线书架为空"); } else { ToastHelper.ShowMessage("获取在线书架数据失败"); } } else { var result = await CompareWithLocalCache(list.ToList()); Books?.Clear(); foreach (var book in list) { Books?.Add(book); } } } catch (Exception ex) { Debug.WriteLine(ex.Message + "\n" + ex.StackTrace); } finally { IsLoading = false; } }
public void GetCacheData() { if (!CookieHelper.CheckLogin()) { return; } Task.Run(() => { if (string.IsNullOrEmpty(AppSettingService.GetUserId())) { return; } var books = DbBookShelf.GetBooks(AppDataPath.GetAppCacheDbPath(), AppSettingService.GetUserId()); DispatcherHelper.CheckBeginInvokeOnUI(() => { books.ForEach(p => Books.Add(p)); }); }); }
public MainViewModel() { IsLogin = CookieHelper.CheckLogin(); InitTabbar(); ViewModelInstance.Instance.BookContent.InitSettingValue(); }