LogoffView.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using Bridge.Html5;
  2. using FrontendRouting;
  3. using LearnBridgeNet.Views.Basic;
  4. namespace LearnBridgeNet.Views
  5. {
  6. [FeRoute("/logoff.html")]
  7. internal class LogoffView : AuthRequiredView
  8. {
  9. private readonly HTMLElement _root;
  10. public LogoffView()
  11. {
  12. _root = new HTMLDivElement();
  13. _root.AppendChild(new HTMLHeadingElement(HeadingType.H1)
  14. {
  15. TextContent = "Safe exit",
  16. });
  17. _root.AppendChild(new HTMLInputElement
  18. {
  19. Type = InputType.Button,
  20. Value = "Login again",
  21. OnClick = evt => FeRoutingManager.Go("/", true)
  22. });
  23. }
  24. public override bool BeforeEnter(FeRoutingView currentView)
  25. {
  26. if (null == currentView && false == XState.IsLogin)
  27. {
  28. FeRoutingManager.Go("/");
  29. return false;
  30. }
  31. if (currentView is LogonView)
  32. {
  33. FeRoutingManager.Go("/", true);
  34. return false;
  35. }
  36. return base.BeforeEnter(currentView);
  37. }
  38. public override void Enter(Node parent)
  39. {
  40. App.NavigateBar.Hidden = true;
  41. XState.IsLogin = false;
  42. parent.AppendChild(_root);
  43. }
  44. public override void Leave()
  45. {
  46. _root.Remove();
  47. App.NavigateBar.Hidden = true;
  48. }
  49. }
  50. }