menu.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. function randomColor() {
  2. return '#' + Math.random().toString(16).substr(2, 6).toUpperCase();
  3. }
  4. const top = [
  5. {
  6. label: '首页',
  7. path: '/wel/index',
  8. icon: 'el-icon-document',
  9. meta: {
  10. i18n: 'dashboard',
  11. },
  12. parentId: 0,
  13. },
  14. {
  15. label: '测试',
  16. icon: 'el-icon-document',
  17. path: '/test',
  18. meta: {
  19. i18n: 'test',
  20. },
  21. parentId: 1,
  22. },
  23. {
  24. label: '更多',
  25. icon: 'el-icon-document',
  26. path: '/wel/more',
  27. meta: {
  28. menu: false,
  29. i18n: 'more',
  30. },
  31. parentId: 2,
  32. },
  33. ];
  34. const first = [
  35. {
  36. label: '缓冲',
  37. path: '/cache',
  38. component: 'views/util/cache',
  39. icon: 'icon-caidan',
  40. iconBgColor: randomColor(),
  41. meta: {
  42. i18n: 'cache',
  43. keepAlive: true,
  44. },
  45. children: [],
  46. },
  47. {
  48. label: '参数',
  49. path: '/params',
  50. component: 'views/util/params',
  51. icon: 'icon-caidan',
  52. iconBgColor: randomColor(),
  53. meta: {
  54. i18n: 'params',
  55. },
  56. },
  57. {
  58. label: '详情页',
  59. path: '/detail',
  60. component: 'views/util/detail',
  61. icon: 'icon-caidan',
  62. iconBgColor: randomColor(),
  63. meta: {
  64. i18n: 'detail',
  65. },
  66. },
  67. {
  68. label: '标签',
  69. path: '/tags',
  70. component: 'views/util/tags',
  71. icon: 'icon-caidan',
  72. iconBgColor: randomColor(),
  73. meta: {
  74. i18n: 'tags',
  75. },
  76. children: [],
  77. },
  78. {
  79. label: '存储',
  80. path: '/store',
  81. component: 'views/util/store',
  82. icon: 'icon-caidan',
  83. iconBgColor: randomColor(),
  84. meta: {
  85. i18n: 'store',
  86. },
  87. children: [],
  88. },
  89. {
  90. label: '日志监控',
  91. path: '/logs',
  92. component: 'views/util/logs',
  93. icon: 'icon-caidan',
  94. iconBgColor: randomColor(),
  95. meta: {
  96. i18n: 'logs',
  97. },
  98. children: [],
  99. },
  100. {
  101. label: '返回顶部',
  102. path: '/top',
  103. component: 'views/util/top',
  104. icon: 'icon-caidan',
  105. iconBgColor: randomColor(),
  106. meta: {
  107. i18n: 'top',
  108. },
  109. children: [],
  110. },
  111. {
  112. label: '图钉',
  113. path: '/affix',
  114. component: 'views/util/affix',
  115. icon: 'icon-caidan',
  116. iconBgColor: randomColor(),
  117. meta: {
  118. i18n: 'affix',
  119. },
  120. children: [],
  121. },
  122. {
  123. label: '多级菜单',
  124. path: '/deep',
  125. iconBgColor: randomColor(),
  126. children: [
  127. {
  128. label: '多级菜单1-1',
  129. path: 'deep',
  130. iconBgColor: randomColor(),
  131. children: [
  132. {
  133. label: '多级菜单2-1',
  134. path: 'deep',
  135. iconBgColor: randomColor(),
  136. component: 'views/util/deep',
  137. },
  138. ],
  139. },
  140. ],
  141. },
  142. {
  143. label: '外部页面',
  144. path: '/out',
  145. icon: 'icon-caidan',
  146. iconBgColor: randomColor(),
  147. meta: {
  148. i18n: 'out',
  149. },
  150. children: [
  151. {
  152. label: '官方网站(内嵌页面)',
  153. path: 'website',
  154. href: 'https://avuejs.com',
  155. icon: 'icon-caidan',
  156. iconBgColor: randomColor(),
  157. meta: {
  158. i18n: 'website',
  159. },
  160. },
  161. {
  162. label: '全局函数(外链页面)',
  163. path: 'api',
  164. href: 'https://avuejs.com/docs/api?test1=1&test2=2',
  165. icon: 'icon-caidan',
  166. iconBgColor: randomColor(),
  167. meta: {
  168. target: '_blank',
  169. i18n: 'api',
  170. },
  171. },
  172. ],
  173. },
  174. {
  175. label: '组合API方式',
  176. path: '/setup',
  177. component: 'views/util/setup',
  178. icon: 'icon-caidan',
  179. iconBgColor: randomColor(),
  180. children: [],
  181. },
  182. {
  183. label: '通用模板',
  184. path: '/crud',
  185. component: 'views/util/crud',
  186. icon: 'icon-caidan',
  187. iconBgColor: randomColor(),
  188. meta: {
  189. i18n: 'crud',
  190. },
  191. children: [],
  192. },
  193. {
  194. label: '表格',
  195. path: '/table',
  196. component: 'views/util/table',
  197. icon: 'icon-caidan',
  198. iconBgColor: randomColor(),
  199. meta: {
  200. i18n: 'table',
  201. },
  202. children: [],
  203. },
  204. {
  205. label: '表单',
  206. path: '/form',
  207. component: 'views/util/form',
  208. icon: 'icon-caidan',
  209. iconBgColor: randomColor(),
  210. meta: {
  211. i18n: 'form',
  212. },
  213. children: [],
  214. },
  215. {
  216. label: '异常页',
  217. path: '/error',
  218. meta: {
  219. i18n: 'error',
  220. },
  221. icon: 'icon-caidan',
  222. iconBgColor: randomColor(),
  223. children: [
  224. {
  225. label: 'error403',
  226. path: 'error',
  227. component: 'components/error-page/403',
  228. icon: 'icon-caidan',
  229. iconBgColor: randomColor(),
  230. children: [],
  231. },
  232. {
  233. label: 'error404',
  234. path: '404',
  235. component: 'components/error-page/404',
  236. icon: 'icon-caidan',
  237. iconBgColor: randomColor(),
  238. children: [],
  239. },
  240. {
  241. label: 'error500',
  242. path: '500',
  243. component: 'components/error-page/500',
  244. icon: 'icon-caidan',
  245. iconBgColor: randomColor(),
  246. children: [],
  247. },
  248. ],
  249. },
  250. {
  251. label: '关于',
  252. path: '/about',
  253. component: 'views/util/about',
  254. icon: 'icon-caidan',
  255. iconBgColor: randomColor(),
  256. meta: {
  257. i18n: 'about',
  258. },
  259. children: [],
  260. },
  261. ];
  262. const second = [
  263. {
  264. label: '测试页面',
  265. path: '/test',
  266. component: 'views/util/test',
  267. icon: 'icon-caidan',
  268. meta: {
  269. i18n: 'test',
  270. },
  271. children: [],
  272. },
  273. ];
  274. let menu = [first, second];
  275. export default [
  276. {
  277. url: '/user/getMenu',
  278. method: 'get',
  279. response: ({ query }) => {
  280. return {
  281. data: menu[query.type || 0] || [],
  282. };
  283. },
  284. },
  285. {
  286. url: '/user/getTopMenu',
  287. method: 'get',
  288. response: () => {
  289. return {
  290. data: top,
  291. };
  292. },
  293. },
  294. ];