Commit 2ca012c8 by caoyanzhi

update: 客户标签

parent 399544bc
import Router from 'vue-router';
import _import from './_import.js';
import delCache from '../utils/del-cache.js';
// import delCache from '@/utils/router-utils.js';
const errorPage = r => {
import('view/errorPage/index.vue').then(module => {
......@@ -203,8 +204,14 @@ const router = new Router({
scrollBehavior: () => ({ y: 0 })
})
router.beforeEach((to, from, next) => {
const { fromPath = [] } = from.meta || {};
from.meta.keepAlive = fromPath.includes(to.path);
const { keepAlive, componentName, fromPath } = to.meta || {};
if (keepAlive && fromPath.every(el => el != '/')) {
fromPath.push('/');
}
// 当前路径的keepAlive为true而且from.path不在fromPath中时,将清除to.path的缓存
if (keepAlive && fromPath.every(el => el != from.path)) {
delCache(router.apps, componentName);
}
next();
})
export default router;
/**
* 需求分析
* A是列表页,B是详情页,C是另一个列表页
* A=>B=>A A的状态不变
* A=>C=>A A为初始状态
* A=>B=>C=>A A为初始状态
* A=>B=>A=>C=>A A为初始状态
* A=>B=>A=>C=>A=>B=>A A的状态不变(保持A最新的状态)
* A=>B=>A=>C=>A=>B=>C=>A A为初始状态
*/
/**
* 查找指定的组件实例
* @param {array} components 组件树
* @param {string} componentName 指定的组件name
......@@ -18,6 +7,7 @@
function getComponent(components, componentName) {
let result = {};
components.some(el => {
// console.log(el.$options.name);
if (el.$options.name == componentName) {
result = el;
} else if (Array.isArray(el.$children)) {
......@@ -33,13 +23,12 @@ function getComponent(components, componentName) {
* @param {object} vm 组件实例
*/
function delCache(vm) {
let { componentOptions, parent = {}, key } = vm.$vnode || {};
if (!vm.$vnode) return;
let { componentOptions, parent, key } = vm.$vnode || {};
let { cache, keys } = parent.componentInstance || {};
cache = cache || {};
keys = Array.isArray(keys) ? keys : [];
if (!componentOptions) return;
if (!key) {
const { Ctor, tag } = componentOptions;
key = Ctor.cid + (tag ? `::${tag}` : '');
......
......@@ -43,6 +43,7 @@
style="width: 260px;float: left;margin-left: 0"
v-model="memberTag"
@keyup.native.enter="searchMemberList"
@blur="searchMemberList"
@clear="allTagList"
clearable
></el-input>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment