import Vue from 'vue' /** * 阅读论文标签数据 */ export const state=()=>({ //已打开论文列表 read: { }, //激活的论文标签 activeName:'' }) export const mutations = { //新建论文标签 open(state,item){ if(item.title in state.read){ mutations.choose(state,item.title) }else{ Vue.set(state.read,item.title, item) mutations.choose(state) } }, //关闭论文标签 close(state,title){ Vue.delete(state.read,title) if(Object.keys(state.read).length>0&&state.activeName===title){ mutations.choose(state) } }, //选择论文标签 choose(state,title=Object.keys(state.read)[Object.keys(state.read).length-1]){ state.activeName=title } }