App.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div v-cloak id="app">
  3. <router-view />
  4. </div>
  5. </template>
  6. <script>
  7. import { JudgeEnvironment } from '@/utils/validate'
  8. import { getCode } from '@/utils/dingding'
  9. export default {
  10. name: 'App',
  11. data() {
  12. return {
  13. code: ''
  14. }
  15. },
  16. async created() {
  17. await this.getMenu()
  18. },
  19. methods: {
  20. async getMenu() {
  21. this.$store
  22. .dispatch('user/getMenuList', this)
  23. .then(async(res) => {
  24. if (res === 'noToken') {
  25. await this.logout()
  26. } else if (res === 'success' || res === 'success-dataV') {
  27. if (
  28. this.$route.path === '/loadingPage' ||
  29. this.$route.path === '/' ||
  30. this.$route.path === '/login'
  31. ) {
  32. if (res === 'success-dataV') {
  33. window.vm.$router.replace('/bigScreen/datavScr')
  34. } else {
  35. window.vm.$router.replace('/welcome')
  36. }
  37. }
  38. } else {
  39. await this.logout()
  40. }
  41. })
  42. .catch(async(err) => {
  43. await this.logout()
  44. })
  45. },
  46. async logout() {
  47. if (this.$route.path !== '/login') {
  48. await this.$store.dispatch('user/logout')
  49. this.$router.push(`/login`)
  50. }
  51. }
  52. }
  53. }
  54. </script>
  55. <style lang="scss">
  56. @import "./assets/css/index.scss";
  57. //因为element-ui的confim组件并不是vue生成的不具有[data-v....],所以全局注入一个class
  58. // .lzx_BtnErr{
  59. // background: #f56c6c !important;
  60. // color: #fff !important;
  61. // }
  62. </style>