permiss.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { defineStore } from 'pinia';
  2. interface ObjectList {
  3. [key: string]: string[];
  4. }
  5. export const usePermissStore = defineStore('permiss', {
  6. state: () => {
  7. const defaultList: ObjectList = {
  8. admin: [
  9. '0',
  10. '1',
  11. '11',
  12. '12',
  13. '13',
  14. '2',
  15. '21',
  16. '22',
  17. '23',
  18. '24',
  19. '25',
  20. '26',
  21. '27',
  22. '28',
  23. '29',
  24. '291',
  25. '292',
  26. '3',
  27. '31',
  28. '32',
  29. '33',
  30. '34',
  31. '4',
  32. '41',
  33. '42',
  34. '5',
  35. '7',
  36. '6',
  37. '61',
  38. '62',
  39. '63',
  40. '64',
  41. '65',
  42. '66',
  43. ],
  44. user: ['0', '1', '11', '12', '13'],
  45. };
  46. const username = localStorage.getItem('vuems_name');
  47. console.log(username);
  48. return {
  49. key: (username == 'admin' ? defaultList.admin : defaultList.user) as string[],
  50. defaultList,
  51. };
  52. },
  53. actions: {
  54. handleSet(val: string[]) {
  55. this.key = val;
  56. },
  57. },
  58. });