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

46 lines
1.0 KiB

import Vue from 'vue'
4 years ago
/**
* 阅读论文标签数据
*/
export const state=()=>({
//已打开论文列表
read: { },
4 years ago
//激活的论文标签
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)
4 years ago
}
},
//关闭论文标签
close(state,title){
Vue.delete(state.read,title)
if(Object.keys(state.read).length>0&&state.activeName===title){
mutations.choose(state)
4 years ago
}
},
//选择论文标签
choose(state,title=Object.keys(state.read)[Object.keys(state.read).length-1]){
4 years ago
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
4 years ago
}
}