Browse Source

收藏标签

liuQiang 2 years ago
parent
commit
1283cacfca
2 changed files with 52 additions and 23 deletions
  1. 6 12
      src/router/index.js
  2. 46 11
      src/views/collect/index.vue

+ 6 - 12
src/router/index.js

@@ -88,12 +88,6 @@ export const constantRoutes = [
         name:'search',
         name:'search',
         meta:{ title:'全文搜索',icon: 'dashboard' },
         meta:{ title:'全文搜索',icon: 'dashboard' },
       },
       },
-       {
-        path: 'swagger',
-        component: () => import('@/views/tool/swagger/index.vue'),
-        name: 'swagger',
-        meta: { title: '接口', icon: 'dashboard' },
-      },
       {
       {
         path: "/myfile",
         path: "/myfile",
         component: () => import("@/views/myfile/MyFile"),
         component: () => import("@/views/myfile/MyFile"),
@@ -146,13 +140,13 @@ export const constantRoutes = [
     component: Layout,
     component: Layout,
     redirect: '/index',
     redirect: '/index',
     children: [
     children: [
-      {
-        path: 'swagger',
-        component: () => import('@/views/tool/swagger/index.vue'),
-        name: 'swagger',
-        meta: { title: '接口', icon: 'dashboard' },
+      // {
+      //   path: 'swagger',
+      //   component: () => import('@/views/tool/swagger/index.vue'),
+      //   name: 'swagger',
+      //   meta: { title: '接口', icon: 'dashboard' },
 
 
-      },
+      // },
     ]
     ]
   },
   },
 
 

+ 46 - 11
src/views/collect/index.vue

@@ -18,10 +18,21 @@
       </el-tabs>
       </el-tabs>
       <!-- 添加标签 -->
       <!-- 添加标签 -->
       <div class="addCollect">
       <div class="addCollect">
-        <el-icon color="#2E6BC8">
-          <Plus />
-        </el-icon>
-        <span @click="addCollectFn">添加标签</span>
+        <div v-if="!isAddCollect">
+          <el-icon color="#2E6BC8">
+            <Plus />
+          </el-icon>
+          <span @click="toAddCollectFn">添加标签</span>
+        </div>
+        <div v-else>
+          <el-input
+            v-model="tabName"
+            size="mini"
+            @blur="addCollectFn"
+            maxlength="32"
+            :autofocus="true"
+          ></el-input>
+        </div>
       </div>
       </div>
     </div>
     </div>
     <el-collapse v-model="activeNames" @change="handleChange">
     <el-collapse v-model="activeNames" @change="handleChange">
@@ -129,10 +140,12 @@
 
 
 <script setup>
 <script setup>
 import { onMounted, ref } from "vue";
 import { onMounted, ref } from "vue";
-import { listLabel, addLabel } from "@/api/biz/label.js";
+import { listLabel, addLabel, delLabel } from "@/api/biz/label.js";
 import { listFavorite } from "@/api/biz/favorite.js";
 import { listFavorite } from "@/api/biz/favorite.js";
 const activeNames = ref(["folder", "file"]);
 const activeNames = ref(["folder", "file"]);
 const clickCollect = ref("first"); //当前标签
 const clickCollect = ref("first"); //当前标签
+const isAddCollect = ref(false); //是否在添加标签
+const tabName = ref(""); //新增的标签名
 const tabList = ref([]);
 const tabList = ref([]);
 const tableData = [
 const tableData = [
   {
   {
@@ -194,15 +207,30 @@ const tableData = [
 ];
 ];
 onMounted(async () => {
 onMounted(async () => {
   await getList();
   await getList();
-  await getCollectList()
+  await getCollectList();
 });
 });
 //添加标签
 //添加标签
+const toAddCollectFn = async () => {
+  isAddCollect.value = true;
+  // const res = await addLabel({
+  //   labelName: "tab1",
+  //   params: {},
+  // });
+  // if (res.code == 200) {
+  //   getList();
+  // }
+};
 const addCollectFn = async () => {
 const addCollectFn = async () => {
+  if (!tabName.value) {
+    isAddCollect.value = false;
+    return;
+  }
   const res = await addLabel({
   const res = await addLabel({
-    labelName: "tab1",
-    params: {},
+    labelName: tabName.value,
   });
   });
   if (res.code == 200) {
   if (res.code == 200) {
+    isAddCollect.value = false;
+    tabName.value = "";
     getList();
     getList();
   }
   }
 };
 };
@@ -214,12 +242,18 @@ const getList = async () => {
     tabList.value = res.rows;
     tabList.value = res.rows;
   }
   }
 };
 };
+// 删除标签
+const delTabs = async () => {
+  const res = await delLabel("7")//直接传id
+  console.log('delres = ',res);
+   getList();
+};
 //获取收藏数据
 //获取收藏数据
 const getCollectList = async () => {
 const getCollectList = async () => {
   const res = await listFavorite();
   const res = await listFavorite();
-//   console.log("collectres = ", res);
-  if(res.code === 200 && res.rows.length>0){
-    tableData.value = res.rows
+  //   console.log("collectres = ", res);
+  if (res.code === 200 && res.rows.length > 0) {
+    tableData.value = res.rows;
   }
   }
 };
 };
 </script>
 </script>
@@ -246,6 +280,7 @@ const getCollectList = async () => {
     font-size: 14px;
     font-size: 14px;
     color: #2e6bc8;
     color: #2e6bc8;
     font-weight: 400;
     font-weight: 400;
+    vertical-align: middle;
   }
   }
 }
 }