You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudnote_web/store/read.js

43 lines
931 B

4 years ago
/**
* 阅读论文标签数据
*/
export const state=()=>({
//已打开论文列表
read:[],
//激活的论文标签
activeName:''
})
export const mutations = {
//新建论文标签
open(state,item){
let isNew=true
for(let i in state.read) {
if (state.read[i].title === item.title) {
isNew=false
mutations.choose(state,item.title)
}
}
if(isNew) {
state.read.push(item)
mutations.choose(state, state.read[state.read.length - 1].title)
}
},
//关闭论文标签
close(state,title){
for(let i in state.read){
if(state.read[i].title===title){
state.read.splice(i,1)
if(state.read.length>0){
if(state.activeName===title) {
mutations.choose(state, state.read[state.read.length - 1].title)
}
}
}
}
},
//选择论文标签
choose(state,title){
state.activeName=title
}
}