fromModule.js 1.05 KB
import { mapMutations } from 'vuex'
export default {
  computed: {
    isFromApplicationModule() {
      return this.getCurrentRouteQuery().from === 'applicationModule'
    },
    currentTabActiveName() {
      return this.getCurrentRouteQuery().tabActiveName
    },
    currentShowTab() {
      const currentTab = this.currentTabPaneList.filter(
        (item) => item.name === this.currentTabActiveName
      )
      return this.isFromApplicationModule ? currentTab : this.currentTabPaneList
    },
  },
  mounted() {
    this.updateApplicationModule(this.isFromApplicationModule)
    if (this.isFromApplicationModule) {
      this.currentActiveTab = this.currentTabActiveName
    }
  },
  methods: {
    ...mapMutations('matter', ['updateApplicationModule']),
    getCurrentRouteQuery() {
      const locationHref = window.location.href
      let query = {}
      locationHref.replace(/([^?&]+)=([^?&]+)/g, (match, key, value) => {
        query[key] = decodeURIComponent(value) //解析字符为中文
        return `${value}${key}`
      })
      return query
    },
  },
}