| | |
| | | <script> |
| | | import ScrollPane from './ScrollPane' |
| | | import path from 'path' |
| | | import { getCookie } from '@/utils/auth' |
| | | |
| | | export default { |
| | | components: { ScrollPane }, |
| | |
| | | mounted() { |
| | | this.initTags() |
| | | this.addTags() |
| | | this.beforeUnload() |
| | | }, |
| | | methods: { |
| | | // 解决 vue-admin-template 刷新页面 TagsView 丢失问题 |
| | | beforeUnload() { |
| | | // 监听页面刷新 |
| | | window.addEventListener('beforeunload', () => { |
| | | // visitedViews数据结构太复杂无法直接JSON.stringify处理,先转换需要的数据 |
| | | const tabViews = this.visitedViews.map(item => { |
| | | return { |
| | | fullPath: item.fullPath, |
| | | hash: item.hash, |
| | | meta: { ...item.meta }, |
| | | name: item.name, |
| | | params: { ...item.params }, |
| | | path: item.path, |
| | | query: { ...item.query }, |
| | | title: item.title |
| | | } |
| | | }) |
| | | sessionStorage.setItem('tabViews', JSON.stringify(tabViews)) |
| | | }) |
| | | |
| | | // 页面初始化加载判断缓存中是否有数据 |
| | | const oldViews = JSON.parse(sessionStorage.getItem('tabViews')) || [] |
| | | if (oldViews.length > 0) { |
| | | this.$store.state.tagsView.visitedViews = oldViews |
| | | } |
| | | }, |
| | | isActive(route) { |
| | | return route.path === this.$route.path |
| | | }, |
| | |
| | | }, |
| | | |
| | | // user logout |
| | | logout({ commit, state }) { |
| | | logout({ commit, state, dispatch }) { |
| | | return new Promise((resolve, reject) => { |
| | | const usercode = getCookie('navTabId') |
| | | const username = getCookie('admin') |
| | |
| | | removeCookie('navTabId') |
| | | removeCookie('usertype') |
| | | removeCookie('userid') |
| | | } |
| | | commit('RESET_STATE') |
| | | |
| | | resolve() |
| | | // reset visited views and cached views |
| | | dispatch('tagsView/delAllViews', null, { root: true }) |
| | | sessionStorage.removeItem('tabViews') |
| | | |
| | | commit('RESET_STATE') |
| | | |
| | | resolve() |
| | | } |
| | | }).catch(error => { |
| | | reject(error) |
| | | }) |
| | |
| | | |
| | | const SER_HZ = /^[\u4e00-\u9fa5]+$/ |
| | | export default { |
| | | name: 'Zzjg', |
| | | name: 'JSQD', |
| | | components: { |
| | | Pagination |
| | | }, |
| | |
| | | |
| | | const SER_HZ = /^[\u4e00-\u9fa5]+$/ |
| | | export default { |
| | | name: 'Zzjg', |
| | | name: 'WLDW', |
| | | components: { |
| | | Pagination |
| | | }, |