RouterVo.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Model;
  2. using Newtonsoft.Json;
  3. namespace Vo
  4. {
  5. /// <summary>
  6. /// 路由展示
  7. /// </summary>
  8. public class RouterVo
  9. {
  10. [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
  11. public bool AlwaysShow { get; set; }
  12. private string component;
  13. [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
  14. public bool Hidden { get; set; }
  15. public string Name { get; set; }
  16. public string Path { get; set; }
  17. public string Redirect { get; set; }
  18. public Meta Meta { get; set; }
  19. [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
  20. public List<RouterVo> Children { get; set; }
  21. public string Component { get => component; set => component = value; }
  22. }
  23. public class Meta
  24. {
  25. /// <summary>
  26. /// 设置该路由在侧边栏和面包屑中展示的名字
  27. /// </summary>
  28. public string Title { get; set; }
  29. /// <summary>
  30. /// 设置该路由的图标,对应路径src/assets/icons/svg
  31. /// </summary>
  32. public string Icon { get; set; }
  33. /// <summary>
  34. /// 设置为true,则不会被 <keep-alive>缓存
  35. /// </summary>
  36. public bool NoCache { get; set; }
  37. public string TitleKey { get; set; } = string.Empty;
  38. public string Link { get; set; } = string.Empty;
  39. public int IsNew { get; set; }
  40. public Meta(string title, string icon)
  41. {
  42. Title = title;
  43. Icon = icon;
  44. }
  45. public Meta(string title, string icon, string path)
  46. {
  47. Title = title;
  48. Icon = icon;
  49. Link = path;
  50. }
  51. public Meta(string title, string icon, bool noCache, string titleKey, string path, DateTime addTime)
  52. {
  53. Title = title;
  54. Icon = icon;
  55. NoCache = noCache;
  56. TitleKey = titleKey;
  57. if (!string.IsNullOrEmpty(path) && (path.StartsWith(UserConstants.HTTP) || path.StartsWith(UserConstants.HTTPS)))
  58. {
  59. Link = path;
  60. }
  61. if (addTime != DateTime.MinValue)
  62. {
  63. TimeSpan ts = DateTime.Now - addTime;
  64. if (ts.Days < 7)
  65. {
  66. IsNew = 1;
  67. }
  68. }
  69. }
  70. }
  71. }