app.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-10-14 17:17:53
  4. * @LastEditTime: 2022-02-14 17:19:26
  5. * @LastEditors: your name
  6. * @Description: In User Settings Edit
  7. * @FilePath: \Foshan4A\src\store\modules\app.js
  8. */
  9. import Cookies from 'js-cookie'
  10. const state = {
  11. sidebar: {
  12. opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
  13. withoutAnimation: false
  14. },
  15. device: 'desktop',
  16. dialog: Cookies.get('dialogStatus') === 'true' ? true : false,
  17. pwdflag: false,
  18. outflag: false,
  19. outcheck: false,
  20. systemSet: Cookies.get('systemSet') != null ? Cookies.get('systemSet') : null,
  21. }
  22. const mutations = {
  23. TOGGLE_SIDEBAR: state => {
  24. state.sidebar.opened = !state.sidebar.opened
  25. state.sidebar.withoutAnimation = false
  26. if (state.sidebar.opened) {
  27. Cookies.set('sidebarStatus', 1)
  28. } else {
  29. Cookies.set('sidebarStatus', 0)
  30. }
  31. },
  32. CLOSE_SIDEBAR: (state, withoutAnimation) => {
  33. Cookies.set('sidebarStatus', 0)
  34. state.sidebar.opened = false
  35. state.sidebar.withoutAnimation = withoutAnimation
  36. },
  37. TOGGLE_DEVICE: (state, device) => {
  38. state.device = device
  39. },
  40. TOGGLE_DIALOG: (state, dialog) => {
  41. state.dialog = dialog
  42. Cookies.set('dialogStatus', dialog)
  43. },
  44. TOGGLE_PWDFLAG: (state, pwdflag) => {
  45. state.pwdflag = pwdflag
  46. },
  47. TOGGLE_OUTFLAG: (state, outflag) => {
  48. state.outflag = outflag
  49. },
  50. TOGGLE_OUTCHECK: (state, outcheck) => {
  51. state.outcheck = outcheck
  52. },
  53. SYSTEM_SET: (state, systemSet) => {
  54. state.systemSet = systemSet
  55. Cookies.set('systemSet', systemSet)
  56. }
  57. }
  58. const actions = {
  59. toggleSideBar ({ commit }) {
  60. commit('TOGGLE_SIDEBAR')
  61. },
  62. closeSideBar ({ commit }, { withoutAnimation }) {
  63. commit('CLOSE_SIDEBAR', withoutAnimation)
  64. },
  65. toggleDevice ({ commit }, device) {
  66. commit('TOGGLE_DEVICE', device)
  67. },
  68. toggleDialog ({ commit }, dialog) {
  69. commit('TOGGLE_DIALOG', dialog)
  70. },
  71. togglePwdflag ({ commit }, pwdflag) {
  72. commit('TOGGLE_PWDFLAG', pwdflag)
  73. },
  74. toggleOutflag ({ commit }, outflag) {
  75. commit('TOGGLE_OUTFLAG', outflag)
  76. },
  77. toggleOutcheck ({ commit }, outcheck) {
  78. commit('TOGGLE_OUTCHECK', outcheck)
  79. },
  80. getSystemSet({ commit }, systemSet) {
  81. commit('SYSTEM_SET', systemSet)
  82. }
  83. }
  84. export default {
  85. namespaced: true,
  86. state,
  87. mutations,
  88. actions
  89. }