common.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import { getStore, removeStore, setStore } from '@/util/store'
  2. import website from '@/const/website'
  3. const common = {
  4. state: {
  5. isCollapse: false,
  6. isFullScreen: false,
  7. isShade: false,
  8. screen: -1,
  9. isLock: getStore({ name: 'isLock' }) || false,
  10. showTag: getStore({ name: 'showTag' }),
  11. showDebug: getStore({ name: 'showDebug' }),
  12. showCollapse: getStore({ name: 'showCollapse' }),
  13. showSearch: getStore({ name: 'showSearch' }),
  14. showLock: getStore({ name: 'showLock' }),
  15. showFullScreen: getStore({ name: 'showFullScreen' }),
  16. showTheme: getStore({ name: 'showTheme' }),
  17. showColor: getStore({ name: 'showColor' }),
  18. showMenu: getStore({ name: 'showMenu' }),
  19. theme: getStore({ name: 'theme' }) || '#409EFF',
  20. themeName: getStore({ name: 'themeName' }) || 'theme-white',
  21. lockPasswd: getStore({ name: 'lockPasswd' }) || '',
  22. website: website
  23. },
  24. actions: {},
  25. mutations: {
  26. SET_SHADE: (state, active) => {
  27. state.isShade = active
  28. },
  29. SET_COLLAPSE: (state) => {
  30. state.isCollapse = !state.isCollapse
  31. },
  32. SET_FULLSCREEN: (state) => {
  33. state.isFullScreen = !state.isFullScreen
  34. },
  35. SET_SHOW_COLLAPSE: (state, active) => {
  36. state.showCollapse = active
  37. setStore({
  38. name: 'showCollapse',
  39. content: state.showCollapse
  40. })
  41. },
  42. SET_SHOW_TAG: (state, active) => {
  43. state.showTag = active
  44. setStore({
  45. name: 'showTag',
  46. content: state.showTag
  47. })
  48. },
  49. SET_SHOW_MENU: (state, active) => {
  50. state.showMenu = active
  51. setStore({
  52. name: 'showMenu',
  53. content: state.showMenu
  54. })
  55. },
  56. SET_SHOW_LOCK: (state, active) => {
  57. state.showLock = active
  58. setStore({
  59. name: 'showLock',
  60. content: state.showLock
  61. })
  62. },
  63. SET_SHOW_SEARCH: (state, active) => {
  64. state.showSearch = active
  65. setStore({
  66. name: 'showSearch',
  67. content: state.showSearch
  68. })
  69. },
  70. SET_SHOW_FULL_SCREEN: (state, active) => {
  71. state.showFullScreen = active
  72. setStore({
  73. name: 'showFullScreen',
  74. content: state.showFullScreen
  75. })
  76. },
  77. SET_SHOW_DEBUG: (state, active) => {
  78. state.showDebug = active
  79. setStore({
  80. name: 'showDebug',
  81. content: state.showDebug
  82. })
  83. },
  84. SET_SHOW_THEME: (state, active) => {
  85. state.showTheme = active
  86. setStore({
  87. name: 'showTheme',
  88. content: state.showTheme
  89. })
  90. },
  91. SET_SHOW_COLOR: (state, active) => {
  92. state.showColor = active
  93. setStore({
  94. name: 'showColor',
  95. content: state.showColor
  96. })
  97. },
  98. SET_LOCK: (state) => {
  99. state.isLock = true
  100. setStore({
  101. name: 'isLock',
  102. content: state.isLock,
  103. type: 'session'
  104. })
  105. },
  106. SET_SCREEN: (state, screen) => {
  107. state.screen = screen
  108. },
  109. SET_THEME: (state, color) => {
  110. state.theme = color
  111. setStore({
  112. name: 'theme',
  113. content: state.theme
  114. })
  115. },
  116. SET_THEME_NAME: (state, themeName) => {
  117. state.themeName = themeName
  118. setStore({
  119. name: 'themeName',
  120. content: state.themeName
  121. })
  122. },
  123. SET_LOCK_PASSWD: (state, lockPasswd) => {
  124. state.lockPasswd = lockPasswd
  125. setStore({
  126. name: 'lockPasswd',
  127. content: state.lockPasswd,
  128. type: 'session'
  129. })
  130. },
  131. CLEAR_LOCK: (state) => {
  132. state.isLock = false
  133. state.lockPasswd = ''
  134. removeStore({
  135. name: 'lockPasswd'
  136. })
  137. removeStore({
  138. name: 'isLock',
  139. type: 'session'
  140. })
  141. }
  142. }
  143. }
  144. export default common