RouterVo.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. namespace ZR.Model.System.Vo
  2. {
  3. /// <summary>
  4. /// 路由展示
  5. /// </summary>
  6. public class RouterVo
  7. {
  8. /// <summary>
  9. /// 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
  10. /// </summary>
  11. [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
  12. public bool AlwaysShow { get; set; }
  13. /// <summary>
  14. /// 组件地址
  15. /// </summary>
  16. private string component;
  17. /// <summary>
  18. /// 是否隐藏路由,当设置 true 的时候该路由不会再侧边栏出现
  19. /// </summary>
  20. [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
  21. public bool Hidden { get; set; }
  22. /// <summary>
  23. /// 路由名字
  24. /// </summary>
  25. public string Name { get; set; }
  26. /// <summary>
  27. /// 路由地址
  28. /// </summary>
  29. public string Path { get; set; }
  30. /// <summary>
  31. /// 重定向地址,当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
  32. /// </summary>
  33. public string Redirect { get; set; }
  34. /// <summary>
  35. /// 路由参数: 如{ "key": "value"}
  36. /// </summary>
  37. public string Query { get; set; }
  38. /// <summary>
  39. /// 其他元素
  40. /// </summary>
  41. public Meta Meta { get; set; }
  42. /// <summary>
  43. /// 子路由
  44. /// </summary>
  45. [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
  46. public List<RouterVo> Children { get; set; }
  47. public string Component { get => component; set => component = value; }
  48. }
  49. public class Meta
  50. {
  51. /// <summary>
  52. /// 设置该路由在侧边栏和面包屑中展示的名字
  53. /// </summary>
  54. public string Title { get; set; }
  55. /// <summary>
  56. /// 设置该路由的图标,对应路径src/assets/icons/svg
  57. /// </summary>
  58. public string Icon { get; set; }
  59. /// <summary>
  60. /// 设置为true,则不会被 <keep-alive>缓存
  61. /// </summary>
  62. public bool NoCache { get; set; }
  63. public string TitleKey { get; set; } = string.Empty;
  64. public string Link { get; set; } = string.Empty;
  65. public int IsNew { get; set; }
  66. /// <summary>
  67. /// icon颜色
  68. /// </summary>
  69. public string IconColor { get; set; }
  70. /// <summary>
  71. /// 权限字符
  72. /// </summary>
  73. public string Permi { get; set; }
  74. public Meta(string title, string icon)
  75. {
  76. Title = title;
  77. Icon = icon;
  78. }
  79. public Meta(string title, string icon, string path)
  80. {
  81. Title = title;
  82. Icon = icon;
  83. Link = path;
  84. }
  85. public Meta(string title, string icon, bool noCache, string titleKey, string path, DateTime addTime)
  86. {
  87. Title = title;
  88. Icon = icon;
  89. NoCache = noCache;
  90. TitleKey = titleKey;
  91. if (!string.IsNullOrEmpty(path) && (path.StartsWith(UserConstants.HTTP) || path.StartsWith(UserConstants.HTTPS)))
  92. {
  93. Link = path;
  94. }
  95. if (addTime != DateTime.MinValue)
  96. {
  97. TimeSpan ts = DateTime.Now - addTime;
  98. if (ts.Days < 7)
  99. {
  100. IsNew = 1;
  101. }
  102. }
  103. }
  104. }
  105. }