common.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import {
  2. setStore,
  3. getStore,
  4. removeStore
  5. } from '@/util/store'
  6. import website from '@/config/website'
  7. const common = {
  8. state: {
  9. language: getStore({name: 'language'}) || 'zh',
  10. isCollapse: false,
  11. isFullScren: false,
  12. isMenu: true,
  13. isShade: false,
  14. screen: -1,
  15. isLock: getStore({name: 'isLock'}) || false,
  16. showTag: true,
  17. showDebug: true,
  18. showCollapse: true,
  19. showSearch: true,
  20. showLock: true,
  21. showFullScren: true,
  22. showTheme: true,
  23. showMenu: true,
  24. showColor: true,
  25. colorName: getStore({name: 'colorName'}) || '#409EFF',
  26. themeName: getStore({name: 'themeName'}) || 'theme-bule',
  27. lockPasswd: getStore({name: 'lockPasswd'}) || '',
  28. website: website,
  29. },
  30. mutations: {
  31. SET_LANGUAGE: (state, language) => {
  32. state.language = language
  33. setStore({
  34. name: 'language',
  35. content: state.language
  36. })
  37. },
  38. SET_SHADE: (state, active) => {
  39. state.isShade = active;
  40. },
  41. SET_COLLAPSE: (state) => {
  42. state.isCollapse = !state.isCollapse;
  43. },
  44. SET_FULLSCREN: (state) => {
  45. state.isFullScren = !state.isFullScren;
  46. },
  47. SET_IS_MENU: (state, menu) => {
  48. state.isMenu = menu;
  49. },
  50. SET_LOCK: (state) => {
  51. state.isLock = true;
  52. setStore({
  53. name: 'isLock',
  54. content: state.isLock,
  55. type: 'session'
  56. })
  57. },
  58. SET_SCREEN: (state, screen) => {
  59. state.screen = screen;
  60. },
  61. SET_COLOR_NAME: (state, colorName) => {
  62. state.colorName = colorName;
  63. setStore({
  64. name: 'colorName',
  65. content: state.colorName,
  66. })
  67. },
  68. SET_THEME_NAME: (state, themeName) => {
  69. state.themeName = themeName;
  70. setStore({
  71. name: 'themeName',
  72. content: state.themeName,
  73. })
  74. },
  75. SET_LOCK_PASSWD: (state, lockPasswd) => {
  76. state.lockPasswd = lockPasswd;
  77. setStore({
  78. name: 'lockPasswd',
  79. content: state.lockPasswd,
  80. type: 'session'
  81. })
  82. },
  83. CLEAR_LOCK: (state) => {
  84. state.isLock = false;
  85. state.lockPasswd = '';
  86. removeStore({
  87. name: 'lockPasswd',
  88. type: 'session'
  89. });
  90. removeStore({
  91. name: 'isLock',
  92. type: 'session'
  93. });
  94. },
  95. }
  96. }
  97. export default common