App.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <div id="app" v-cloak>
  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. console.log(this.$route.fullPath);
  50. this.$router.push(`/login`);
  51. }
  52. },
  53. },
  54. };
  55. </script>
  56. <style lang="scss">
  57. @import "./assets/css/index.scss";
  58. //因为element-ui的confim组件并不是vue生成的不具有[data-v....],所以全局注入一个class
  59. // .lzx_BtnErr{
  60. // background: #f56c6c !important;
  61. // color: #fff !important;
  62. // }
  63. </style>