From 19621635052322005f31579f7f3d481750898d7c Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Fri, 31 Dec 2021 08:56:36 +0800
Subject: [PATCH] 部分更改

---
 src/store/modules/viewer.js |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/src/store/modules/viewer.js b/src/store/modules/viewer.js
index dd07d31..089c0ad 100644
--- a/src/store/modules/viewer.js
+++ b/src/store/modules/viewer.js
@@ -1,15 +1,39 @@
 const viewer = {
     state: {
-        viewer: null
+        viewer: null,
+        visitedViews: [],
+        cachedViews: []
     },
     mutations: {
         SET_VIEWER (state, viewer) {
-            // console.log(viewer, 456)
             state.viewer = viewer
+        },
+        DEL_VISITED_VIEWS: (state, view) => {
+            for (const [i, v] of state.visitedViews.entries()) {
+                if (v.path === view.path) {
+                    state.visitedViews.splice(i, 1)
+                    break
+                }
+            }
+            for (const i of state.cachedViews) {
+                if (i === view.name) {
+                    const index = state.cachedViews.indexOf(i)
+                    state.cachedViews.splice(index, 1)
+                    break
+                }
+            }
         }
     },
     actions: {
-
+        delVisitedViews ({
+            commit,
+            state
+        }, view) {
+            return new Promise((resolve) => {
+                commit('DEL_VISITED_VIEWS', view)
+                resolve([...state.visitedViews])
+            })
+        }
     }
 }
 

--
Gitblit v1.9.3