sunxuewei 2 年 前
コミット
27ab894677

+ 1 - 0
src/components/uploadFile/index.vue

@@ -69,6 +69,7 @@ const uploadList: any = computed({
69 69
 });
70 70
 const headers = {
71 71
   Authorization: "Bearer " + store.getters.access_token
72
+  // "Content-Type": "multipart/form-data;charset=UTF-8"
72 73
 };
73 74
 const fileData = {
74 75
   bucket: "reservoir"

+ 6 - 0
src/hooks/detailQuery/getQuery.ts

@@ -0,0 +1,6 @@
1
+import store from "@/store";
2
+
3
+export function getQuery(path: string) {
4
+  const query = store.getters.detailQuery;
5
+  return query[path] || {};
6
+}

+ 4 - 0
src/hooks/detailQuery/index.ts

@@ -0,0 +1,4 @@
1
+import { setQuery } from "./setQuery";
2
+import { getQuery } from "./getQuery";
3
+
4
+export { setQuery, getQuery };

+ 10 - 0
src/hooks/detailQuery/setQuery.ts

@@ -0,0 +1,10 @@
1
+import store from "@/store";
2
+import router from "@/router";
3
+import { nextTick } from "vue";
4
+
5
+export function setQuery(path: string, query: any) {
6
+  store.commit("ADD_QUERY", { path, query });
7
+  nextTick(() => {
8
+    router.push({ path });
9
+  });
10
+}

+ 3 - 1
src/store/getters.ts

@@ -8,5 +8,7 @@ export default {
8 8
   tagWel: (state: any) => state.tag.tagWel,
9 9
   tagList: (state: any) => state.tag.tagList,
10 10
 
11
-  website: (state: any) => state.common.website
11
+  website: (state: any) => state.common.website,
12
+
13
+  detailQuery: (state: any) => state.query.detailQuery
12 14
 };

+ 3 - 1
src/store/index.ts

@@ -3,12 +3,14 @@ import getters from "./getters";
3 3
 import user from "./modules/user";
4 4
 import tag from "./modules/tag";
5 5
 import common from "./modules/common";
6
+import query from "./modules/query";
6 7
 
7 8
 export default createStore({
8 9
   getters,
9 10
   modules: {
10 11
     user,
11 12
     tag,
12
-    common
13
+    common,
14
+    query
13 15
   }
14 16
 });

+ 27 - 0
src/store/modules/query.ts

@@ -0,0 +1,27 @@
1
+import cache from "@/utils/cache";
2
+
3
+export default {
4
+  state: () => ({
5
+    detailQuery: cache.session.getJSON("detailQuery") || {}
6
+  }),
7
+  mutations: {
8
+    ADD_QUERY: (state: any, query: any) => {
9
+      state.detailQuery[query.path] = query.query;
10
+      cache.session.setJSON("detailQuery", state.detailQuery);
11
+    },
12
+    DEL_QUERY: (state: any, path: string) => {
13
+      delete state.detailQuery[path];
14
+      cache.session.setJSON("detailQuery", state.detailQuery);
15
+    },
16
+    DEL_ALL_QUERY: (state: any) => {
17
+      state.detailQuery = {};
18
+      cache.session.setJSON("detailQuery", state.detailQuery);
19
+    },
20
+    DEL_OTHER_QUERY: (state: any, path: string) => {
21
+      state.detailQuery = {
22
+        [path]: state.detailQuery[path]
23
+      };
24
+      cache.session.setJSON("detailQuery", state.detailQuery);
25
+    }
26
+  }
27
+};

+ 11 - 22
src/store/modules/tag.ts

@@ -1,10 +1,11 @@
1 1
 import cache from "@/utils/cache";
2
-import { diff } from "@/utils/util";
3 2
 import website from "@/const/website";
4
-import { ITagType } from "@/const/interface_type";
3
+
5 4
 import { ref } from "vue";
5
+import { diff } from "@/utils/util";
6
+import { ITagType } from "@/const/interface_type";
7
+import store from "..";
6 8
 
7
-const isFirstPage = website.isFirstPage;
8 9
 const tagWel = website.fistPage;
9 10
 const tagObj = ref<ITagType>({
10 11
   label: "", // 标题名称
@@ -14,20 +15,6 @@ const tagObj = ref<ITagType>({
14 15
   // group: [] // 分组
15 16
 });
16 17
 
17
-// 处理首个标签
18
-function setFistTag(list: ITagType[]) {
19
-  if (list.length === 1) {
20
-    list[0].close = false;
21
-  } else {
22
-    list.forEach((ele) => {
23
-      if (ele.value === tagWel.value && isFirstPage === false) {
24
-        ele.close = false;
25
-      } else {
26
-        ele.close = true;
27
-      }
28
-    });
29
-  }
30
-}
31 18
 export default {
32 19
   state: () => ({
33 20
     tagList: cache.session.getJSON("tagList") || [],
@@ -40,29 +27,31 @@ export default {
40 27
       cache.session.setJSON("tag", state.tag);
41 28
       if (state.tagList.some((ele: any) => diff(ele, action))) return;
42 29
       state.tagList.push(action);
43
-      setFistTag(state.tagList);
44 30
       cache.session.setJSON("tagList", state.tagList);
45 31
     },
46 32
     DEL_TAG: (state: any, action: ITagType) => {
33
+      const query = store.getters.detailQuery;
34
+      const isDel = Object.keys(query).find((item) => action.value.includes(item));
35
+      if (isDel) store.commit("DEL_QUERY", isDel);
47 36
       state.tagList = state.tagList.filter((item: ITagType) => {
48 37
         return !diff(item, action);
49 38
       });
50
-      setFistTag(state.tagList);
51 39
       cache.session.setJSON("tagList", state.tagList);
52 40
     },
53 41
     DEL_ALL_TAG: (state: any) => {
54 42
       state.tagList = [];
43
+      store.commit("DEL_ALL_QUERY");
55 44
       cache.session.setJSON("tagList", state.tagList);
56 45
     },
57 46
     DEL_TAG_OTHER: (state: any) => {
47
+      const query = store.getters.detailQuery;
48
+      const isRetain = Object.keys(query).find((item) => state.tag.value.includes(item));
49
+      if (isRetain) store.commit("DEL_OTHER_QUERY", isRetain);
58 50
       state.tagList = state.tagList.filter((item: ITagType) => {
59 51
         if (item.value === state.tag.value) {
60 52
           return true;
61
-        } else if (!website.isFirstPage && item.value === website.fistPage.value) {
62
-          return true;
63 53
         }
64 54
       });
65
-      setFistTag(state.tagList);
66 55
       cache.session.setJSON("tagList", state.tagList);
67 56
     }
68 57
   },