12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <template>
- <div v-cloak id="app">
- <router-view />
- </div>
- </template>
- <script>
- import { mapGetters } from 'vuex'
- export default {
- name: 'App',
- data() {
- return {
- code: ''
- }
- },
- computed: {
- ...mapGetters(['isSupertube'])
- },
- async created() {
- await this.getMenu()
- },
- mounted() {
- this.jumpToListPageWithDetailPage()
- },
- methods: {
- jumpToListPageWithDetailPage() {
- if (!this.isDetailPage() || this.isSupertube) return
- const listPageUrl = this.getListPageUrl()
- this.$router.push(listPageUrl)
- },
- isDetailPage() {
- const { path } = this.$route
- return path && path.indexOf('Detail')
- },
- getListPageUrl() {
- const { path = '' } = this.$route
- const [listPageUrl] = path.split('Detail')
- return listPageUrl
- },
- async getMenu() {
- this.$store
- .dispatch('user/getMenuList', this)
- .then(async(res) => {
- console.log(res)
- if (res === 'noToken') {
- await this.logout()
- } else{
- if (
- this.$route.path === '/' ||
- this.$route.path === '/login' ||
- this.$route.path === '/loadingPage'
- ) {
- await window.vm.$router.replace('/welcome')
- }
- }
- })
- .catch((_err) => { this.logout() })
- },
- async logout() {
- if (this.$route.path !== '/login' && this.$route.path !== '/accept') {
- await this.$store.dispatch('user/logout')
- await this.$router.push(`/login`)
- }
- }
- }
- }
- </script>
- <style lang="scss">
- @import "./assets/css/index.scss";
- // 因为element-ui的confim组件并不是vue生成的不具有[data-v....],所以全局注入一个class
- // .lzx_BtnErr{
- // background: #f56c6c !important;
- // color: #fff !important;
- // }
- </style>
|