12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import router from "@/router";
- export default {
- state: {
- history:[],
- historyPath:[],
- currentPath:null,
- },
- mutations: {
- addHistoryPath(state,path){
- let paths=state.historyPath.filter(item=>{
- return item!==path;
- })
- paths.push(path);
- state.historyPath=paths;
- state.currentPath=path;
- },
- addHistory(state,history){
- if(!history.name){
- return
- }
- let index=-1;
- state.history.forEach((item,i)=>{
- if(item.path===history.path)
- index=i;
- })
-
- if(index!==-1){
- state.history[index] = history
- return;
- }
- state.history.push(history)
- },
- removeHistory(state,path){
- state.history=state.history.filter(item=>{
- return item.path!=path;
- })
- if(state.history.length == 0){
- router.push(
- {
- path:'/administrator/home',
- }
- )
- }
- },
- removeHistoryPath(state,path){
- state.historyPath=state.historyPath.filter(item=>{
- return item!=path;
- })
- if(state.historyPath.length>0)
- state.currentPath=state.historyPath[state.historyPath.length-1];
- else
- state.currentPath=null;
- }
- },
- actions: {
- }
- }
|