app.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. const state = () => ({
  2. isPc: true,
  3. screen: 'pc',
  4. static: `${process.env.STATIC_URL}/pc`,
  5. loginVisiable: false,
  6. routePrefix: '', // 路由前缀
  7. themeName: 'normal',
  8. screenWidth: 0,
  9. showHeader: true,
  10. showFooter: true,
  11. accessToken: '',
  12. wxConfig: {},
  13. })
  14. const mutations = {
  15. SET_SCREEN(state, width) {
  16. if (width > 768) {
  17. state.isPc = true
  18. state.screen = 'pc'
  19. } else {
  20. state.isPc = false
  21. state.screen = 'h5'
  22. }
  23. state.screenWidth = width
  24. state.static = `${process.env.STATIC_URL}/${state.screen}`
  25. },
  26. SHOW_LOGIN(state) {
  27. state.loginVisiable = true
  28. },
  29. HIDE_LOGIN(state) {
  30. state.loginVisiable = false
  31. },
  32. // 供应商模板类型
  33. SET_ROUTE_PREFIX(state, prefix) {
  34. state.routePrefix = prefix
  35. },
  36. // 设置主题
  37. SET_PAGE_THEME(state, name) {
  38. state.themeName = name
  39. },
  40. // hide layout
  41. HIDE_LAYOUT(state) {
  42. state.showHeader = false
  43. state.showFooter = false
  44. },
  45. SHOW_LAYOUT(state) {
  46. state.showHeader = true
  47. state.showFooter = true
  48. },
  49. SET_WXCONFIG(state, config) {
  50. state.wxConfig = config
  51. },
  52. }
  53. const actions = {}
  54. export default {
  55. namespaced: true,
  56. state,
  57. mutations,
  58. actions,
  59. }