app.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. errorNum: Cookies.get('errorNum') ? Cookies.get('errorNum') : 0,
  22. wsData: []
  23. }
  24. const mutations = {
  25. TOGGLE_SIDEBAR: state => {
  26. state.sidebar.opened = !state.sidebar.opened
  27. state.sidebar.withoutAnimation = false
  28. if (state.sidebar.opened) {
  29. Cookies.set('sidebarStatus', 1)
  30. } else {
  31. Cookies.set('sidebarStatus', 0)
  32. }
  33. },
  34. CLOSE_SIDEBAR: (state, withoutAnimation) => {
  35. Cookies.set('sidebarStatus', 0)
  36. state.sidebar.opened = false
  37. state.sidebar.withoutAnimation = withoutAnimation
  38. },
  39. TOGGLE_DEVICE: (state, device) => {
  40. state.device = device
  41. },
  42. TOGGLE_DIALOG: (state, dialog) => {
  43. state.dialog = dialog
  44. Cookies.set('dialogStatus', dialog)
  45. },
  46. TOGGLE_PWDFLAG: (state, pwdflag) => {
  47. state.pwdflag = pwdflag
  48. },
  49. TOGGLE_OUTFLAG: (state, outflag) => {
  50. state.outflag = outflag
  51. },
  52. TOGGLE_OUTCHECK: (state, outcheck) => {
  53. state.outcheck = outcheck
  54. },
  55. SYSTEM_SET: (state, systemSet) => {
  56. state.systemSet = systemSet
  57. Cookies.set('systemSet', systemSet)
  58. },
  59. ERROR_NUM: (state, systemSet) => {
  60. state.errorNum = systemSet
  61. Cookies.set('errorNum', systemSet)
  62. },
  63. WS_DATA: (state, data) => {
  64. state.wsData = data
  65. },
  66. }
  67. const actions = {
  68. toggleSideBar ({ commit }) {
  69. commit('TOGGLE_SIDEBAR')
  70. },
  71. closeSideBar ({ commit }, { withoutAnimation }) {
  72. commit('CLOSE_SIDEBAR', withoutAnimation)
  73. },
  74. toggleDevice ({ commit }, device) {
  75. commit('TOGGLE_DEVICE', device)
  76. },
  77. toggleDialog ({ commit }, dialog) {
  78. commit('TOGGLE_DIALOG', dialog)
  79. },
  80. togglePwdflag ({ commit }, pwdflag) {
  81. commit('TOGGLE_PWDFLAG', pwdflag)
  82. },
  83. toggleOutflag ({ commit }, outflag) {
  84. commit('TOGGLE_OUTFLAG', outflag)
  85. },
  86. toggleOutcheck ({ commit }, outcheck) {
  87. commit('TOGGLE_OUTCHECK', outcheck)
  88. },
  89. getSystemSet ({ commit }, systemSet) {
  90. commit('SYSTEM_SET', systemSet)
  91. },
  92. getErrorNum ({ commit }, systemSet) {
  93. commit('ERROR_NUM', systemSet)
  94. },
  95. getWsData ({ commit }, data) {
  96. commit('WS_DATA', data)
  97. },
  98. }
  99. export default {
  100. namespaced: true,
  101. state,
  102. mutations,
  103. actions
  104. }