app.js 981 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // #ifndef VUE3
  2. const statConfig = require('uni-stat-config').default || require('uni-stat-config');
  3. // #endif
  4. export default {
  5. namespaced: true,
  6. state: {
  7. inited: false,
  8. navMenu: [],
  9. routes: [],
  10. appName: process.env.VUE_APP_NAME || process.env.UNI_APP_NAME || '',
  11. // #ifndef VUE3
  12. appid: statConfig && statConfig.appid || ''
  13. // #endif
  14. // #ifdef VUE3
  15. appid: process.env.UNI_APP_ID || ''
  16. // #endif
  17. },
  18. mutations: {
  19. SET_APP_NAME: (state, appName) => {
  20. state.appName = appName
  21. },
  22. SET_NAV_MENU: (state, navMenu) => {
  23. state.inited = true
  24. state.navMenu = navMenu
  25. },
  26. SET_ROUTES: (state, routes) => {
  27. state.routes = routes
  28. }
  29. },
  30. actions: {
  31. init({
  32. commit,
  33. dispatch
  34. }) {
  35. // 初始化获取用户信息
  36. dispatch('user/getUserInfo', null, {
  37. root: true
  38. })
  39. },
  40. setAppName({
  41. commit
  42. }, appName) {
  43. commit('SET_APP_NAME', appName)
  44. },
  45. setRoutes({
  46. commit
  47. }, routes) {
  48. commit('SET_ROUTES', routes)
  49. }
  50. }
  51. }