mock-data.ts 9.2 KB

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