1
0

mock-data.ts 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. export interface UserInfo {
  2. id: number;
  3. password: string;
  4. realName: string;
  5. roles: string[];
  6. username: string;
  7. homePath?: string;
  8. }
  9. export const MOCK_USERS: UserInfo[] = [
  10. {
  11. id: 0,
  12. password: '123456',
  13. realName: 'Vben',
  14. roles: ['super'],
  15. username: 'vben',
  16. },
  17. {
  18. id: 1,
  19. password: '123456',
  20. realName: 'Admin',
  21. roles: ['admin'],
  22. username: 'admin',
  23. homePath: '/workspace',
  24. },
  25. {
  26. id: 2,
  27. password: '123456',
  28. realName: 'Jack',
  29. roles: ['user'],
  30. username: 'jack',
  31. homePath: '/analytics',
  32. },
  33. ];
  34. export const MOCK_CODES = [
  35. // super
  36. {
  37. codes: ['AC_100100', 'AC_100110', 'AC_100120', 'AC_100010'],
  38. username: 'vben',
  39. },
  40. {
  41. // admin
  42. codes: ['AC_100010', 'AC_100020', 'AC_100030'],
  43. username: 'admin',
  44. },
  45. {
  46. // user
  47. codes: ['AC_1000001', 'AC_1000002'],
  48. username: 'jack',
  49. },
  50. ];
  51. const dashboardMenus = [
  52. {
  53. meta: {
  54. order: -1,
  55. title: 'page.dashboard.title',
  56. },
  57. name: 'Dashboard',
  58. path: '/dashboard',
  59. redirect: '/analytics',
  60. children: [
  61. {
  62. name: 'Analytics',
  63. path: '/analytics',
  64. component: '/dashboard/analytics/index',
  65. meta: {
  66. affixTab: true,
  67. title: 'page.dashboard.analytics',
  68. },
  69. },
  70. {
  71. name: 'Workspace',
  72. path: '/workspace',
  73. component: '/dashboard/workspace/index',
  74. meta: {
  75. title: 'page.dashboard.workspace',
  76. },
  77. },
  78. ],
  79. },
  80. ];
  81. const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
  82. const roleWithMenus = {
  83. admin: {
  84. component: '/demos/access/admin-visible',
  85. meta: {
  86. icon: 'mdi:button-cursor',
  87. title: 'demos.access.adminVisible',
  88. },
  89. name: 'AccessAdminVisibleDemo',
  90. path: '/demos/access/admin-visible',
  91. },
  92. super: {
  93. component: '/demos/access/super-visible',
  94. meta: {
  95. icon: 'mdi:button-cursor',
  96. title: 'demos.access.superVisible',
  97. },
  98. name: 'AccessSuperVisibleDemo',
  99. path: '/demos/access/super-visible',
  100. },
  101. user: {
  102. component: '/demos/access/user-visible',
  103. meta: {
  104. icon: 'mdi:button-cursor',
  105. title: 'demos.access.userVisible',
  106. },
  107. name: 'AccessUserVisibleDemo',
  108. path: '/demos/access/user-visible',
  109. },
  110. };
  111. return [
  112. {
  113. meta: {
  114. icon: 'ic:baseline-view-in-ar',
  115. keepAlive: true,
  116. order: 1000,
  117. title: 'demos.title',
  118. },
  119. name: 'Demos',
  120. path: '/demos',
  121. redirect: '/demos/access',
  122. children: [
  123. {
  124. name: 'AccessDemos',
  125. path: '/demosaccess',
  126. meta: {
  127. icon: 'mdi:cloud-key-outline',
  128. title: 'demos.access.backendPermissions',
  129. },
  130. redirect: '/demos/access/page-control',
  131. children: [
  132. {
  133. name: 'AccessPageControlDemo',
  134. path: '/demos/access/page-control',
  135. component: '/demos/access/index',
  136. meta: {
  137. icon: 'mdi:page-previous-outline',
  138. title: 'demos.access.pageAccess',
  139. },
  140. },
  141. {
  142. name: 'AccessButtonControlDemo',
  143. path: '/demos/access/button-control',
  144. component: '/demos/access/button-control',
  145. meta: {
  146. icon: 'mdi:button-cursor',
  147. title: 'demos.access.buttonControl',
  148. },
  149. },
  150. {
  151. name: 'AccessMenuVisible403Demo',
  152. path: '/demos/access/menu-visible-403',
  153. component: '/demos/access/menu-visible-403',
  154. meta: {
  155. authority: ['no-body'],
  156. icon: 'mdi:button-cursor',
  157. menuVisibleWithForbidden: true,
  158. title: 'demos.access.menuVisible403',
  159. },
  160. },
  161. roleWithMenus[role],
  162. ],
  163. },
  164. ],
  165. },
  166. ];
  167. };
  168. export const MOCK_MENUS = [
  169. {
  170. menus: [...dashboardMenus, ...createDemosMenus('super')],
  171. username: 'vben',
  172. },
  173. {
  174. menus: [...dashboardMenus, ...createDemosMenus('admin')],
  175. username: 'admin',
  176. },
  177. {
  178. menus: [...dashboardMenus, ...createDemosMenus('user')],
  179. username: 'jack',
  180. },
  181. ];
  182. export const MOCK_MENU_LIST = [
  183. {
  184. id: 1,
  185. name: 'Workspace',
  186. status: 1,
  187. type: 'menu',
  188. icon: 'mdi:dashboard',
  189. path: '/workspace',
  190. component: '/dashboard/workspace/index',
  191. meta: {
  192. icon: 'carbon:workspace',
  193. title: 'page.dashboard.workspace',
  194. affixTab: true,
  195. order: 0,
  196. },
  197. },
  198. {
  199. id: 2,
  200. meta: {
  201. icon: 'carbon:settings',
  202. order: 9997,
  203. title: 'system.title',
  204. badge: 'new',
  205. badgeType: 'normal',
  206. badgeVariants: 'primary',
  207. },
  208. status: 1,
  209. type: 'catalog',
  210. name: 'System',
  211. path: '/system',
  212. children: [
  213. {
  214. id: 201,
  215. pid: 2,
  216. path: '/system/menu',
  217. name: 'SystemMenu',
  218. authCode: 'System:Menu:List',
  219. status: 1,
  220. type: 'menu',
  221. meta: {
  222. icon: 'carbon:menu',
  223. title: 'system.menu.title',
  224. },
  225. component: '/system/menu/list',
  226. children: [
  227. {
  228. id: 20_101,
  229. pid: 201,
  230. name: 'SystemMenuCreate',
  231. status: 1,
  232. type: 'button',
  233. authCode: 'System:Menu:Create',
  234. meta: { title: 'common.create' },
  235. },
  236. {
  237. id: 20_102,
  238. pid: 201,
  239. name: 'SystemMenuEdit',
  240. status: 1,
  241. type: 'button',
  242. authCode: 'System:Menu:Edit',
  243. meta: { title: 'common.edit' },
  244. },
  245. {
  246. id: 20_103,
  247. pid: 201,
  248. name: 'SystemMenuDelete',
  249. status: 1,
  250. type: 'button',
  251. authCode: 'System:Menu:Delete',
  252. meta: { title: 'common.delete' },
  253. },
  254. ],
  255. },
  256. {
  257. id: 202,
  258. pid: 2,
  259. path: '/system/dept',
  260. name: 'SystemDept',
  261. status: 1,
  262. type: 'menu',
  263. authCode: 'System:Dept:List',
  264. meta: {
  265. icon: 'carbon:container-services',
  266. title: 'system.dept.title',
  267. },
  268. component: '/system/dept/list',
  269. children: [
  270. {
  271. id: 20_401,
  272. pid: 201,
  273. name: 'SystemDeptCreate',
  274. status: 1,
  275. type: 'button',
  276. authCode: 'System:Dept:Create',
  277. meta: { title: 'common.create' },
  278. },
  279. {
  280. id: 20_402,
  281. pid: 201,
  282. name: 'SystemDeptEdit',
  283. status: 1,
  284. type: 'button',
  285. authCode: 'System:Dept:Edit',
  286. meta: { title: 'common.edit' },
  287. },
  288. {
  289. id: 20_403,
  290. pid: 201,
  291. name: 'SystemDeptDelete',
  292. status: 1,
  293. type: 'button',
  294. authCode: 'System:Dept:Delete',
  295. meta: { title: 'common.delete' },
  296. },
  297. ],
  298. },
  299. ],
  300. },
  301. {
  302. id: 9,
  303. meta: {
  304. badgeType: 'dot',
  305. order: 9998,
  306. title: 'demos.vben.title',
  307. icon: 'carbon:data-center',
  308. },
  309. name: 'Project',
  310. path: '/vben-admin',
  311. type: 'catalog',
  312. status: 1,
  313. children: [
  314. {
  315. id: 901,
  316. pid: 9,
  317. name: 'VbenDocument',
  318. path: '/vben-admin/document',
  319. component: 'IFrameView',
  320. type: 'embedded',
  321. status: 1,
  322. meta: {
  323. icon: 'carbon:book',
  324. iframeSrc: 'https://doc.vben.pro',
  325. title: 'demos.vben.document',
  326. },
  327. },
  328. {
  329. id: 902,
  330. pid: 9,
  331. name: 'VbenGithub',
  332. path: '/vben-admin/github',
  333. component: 'IFrameView',
  334. type: 'link',
  335. status: 1,
  336. meta: {
  337. icon: 'carbon:logo-github',
  338. link: 'https://github.com/vbenjs/vue-vben-admin',
  339. title: 'Github',
  340. },
  341. },
  342. {
  343. id: 903,
  344. pid: 9,
  345. name: 'VbenAntdv',
  346. path: '/vben-admin/antdv',
  347. component: 'IFrameView',
  348. type: 'link',
  349. status: 0,
  350. meta: {
  351. icon: 'carbon:hexagon-vertical-solid',
  352. badgeType: 'dot',
  353. link: 'https://ant.vben.pro',
  354. title: 'demos.vben.antdv',
  355. },
  356. },
  357. ],
  358. },
  359. {
  360. id: 10,
  361. component: '_core/about/index',
  362. type: 'menu',
  363. status: 1,
  364. meta: {
  365. icon: 'lucide:copyright',
  366. order: 9999,
  367. title: 'demos.vben.about',
  368. },
  369. name: 'About',
  370. path: '/about',
  371. },
  372. ];
  373. export function getMenuIds(menus: any[]) {
  374. const ids: number[] = [];
  375. menus.forEach((item) => {
  376. ids.push(item.id);
  377. if (item.children && item.children.length > 0) {
  378. ids.push(...getMenuIds(item.children));
  379. }
  380. });
  381. return ids;
  382. }