export default {
	state: {
		openedPageList: [],
		activePage: {
			'name': '',
			'path': ''
		}
	},
	getters: {
		collapse(state) { // 对应着上面state
			return state.collapse
		}
	},
	mutations: {
		addTab(state, data) {
//添加到当前活动页后面
			let index = 1
			for (let openedPage of state.openedPageList) {
				if (openedPage.path === state.activePage.path) {
					break
				}
				index++
			}
			state.openedPageList.splice(index, 0,{
				'name': data.name,
				'path': data.path
			})
			//删除刷新时产生的空白
			 let indexRemove = 0
			 for (let openedPage of state.openedPageList) {
			 	if (openedPage.name === null||openedPage.name === '') {
			 		break
			 	}
			 	indexRemove++
			 }
			 state.openedPageList.splice(indexRemove, 1)
			 
		},
		removeTab(state, path) {
			let index = 0
			for (let openedPage of state.openedPageList) {
				if (openedPage.path === path) {
					break
				}
				index++
			}
			state.openedPageList.splice(index, 1)
		},
		setActive(state, data) {
			state.activePage = {
				name: data.name,
				path: data.path
			}
		},
		setOpenedPageList(state, openedPageList){
			state.openedPageList = openedPageList
		}
	},
	actions: {}
}
