theme.js 771 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import storage from '@/utils/storage'
  2. import { isEmpty } from '@/utils/util'
  3. import { APP_THEME } from '@/store/mutation-types'
  4. const theme = {
  5. state: {
  6. // 当前自定义主题
  7. appTheme: {
  8. mainBg: '#fa2209',
  9. mainBg2: '#ff6335',
  10. mainText: '#ffffff',
  11. viceBg: '#ffb100',
  12. viceBg2: '#ffb900',
  13. viceText: '#ffffff',
  14. },
  15. },
  16. mutations: {
  17. SET_APP_THEME: (state, value) => {
  18. if (!isEmpty(value)) {
  19. state.appTheme = value
  20. }
  21. }
  22. },
  23. actions: {
  24. // 记录自定义主题
  25. SetAppTheme({ commit }, value) {
  26. return new Promise((resolve, reject) => {
  27. storage.set(APP_THEME, value)
  28. commit('SET_APP_THEME', value)
  29. resolve()
  30. })
  31. }
  32. }
  33. }
  34. export default theme