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 }, //滚动正文 scroll(state,scrollTop){ state.read[state.activeName].scrollTop=scrollTop }, //查找状态 find(state,item){ state.read[state.activeName].find=item }, //更新正文 updateContent(state,content){ state.read[state.activeName].content=content }, //更新收藏状态 updateCollect(state,key){ state.read[key].hasCollect=!state.read[key].hasCollect }, //重置 reset(state){ state.read={ } state.activeName='' } }