Browse Source

刷新我的收藏

jwyu 2 years ago
parent
commit
73dfdc12b2
2 changed files with 21 additions and 3 deletions
  1. 16 1
      src/components/MyCollect.vue
  2. 5 2
      src/layout/component/Header.vue

+ 16 - 1
src/components/MyCollect.vue

@@ -1,5 +1,5 @@
 <script setup>
-import {onMounted,reactive} from 'vue'
+import {onMounted,reactive,watch} from 'vue'
 import {apiMyCollectList,apiCancelCollect} from '@/api/user'
 import { useRouter } from 'vue-router'
 import { ElMessage,ElMessageBox } from 'element-plus'
@@ -7,6 +7,21 @@ import Search from '@/components/Search.vue'
 import moment from 'moment'
 
 const router=useRouter()
+const props=defineProps({
+    show:{
+        type:Boolean,
+        default:false
+    }
+})
+watch(
+    ()=>props.show,
+    (e)=>{
+        if(e){
+            // 刷新收藏
+            handleTypeChange(0)
+        }
+    }
+)
 
 
 const listState=reactive({

+ 5 - 2
src/layout/component/Header.vue

@@ -177,6 +177,9 @@ const handleSetUserInfo=()=>{
   router.push('/user/setinfo')
 }
 
+// 我的收藏
+let showCollect=ref(false)
+
 
 </script>
 
@@ -188,12 +191,12 @@ const handleSetUserInfo=()=>{
     </div>
     <div class="flex-col-center userinfo-wrap">
       <!-- 我的收藏 -->
-      <el-popover trigger="click" :width="460" popper-style="box-shadow: rgb(14 18 22 / 35%) 0px 10px 38px -10px, rgb(14 18 22 / 20%) 0px 10px 20px -15px; padding: 20px;">
+      <el-popover trigger="click" @show="showCollect=true" @hide="showCollect=false" :width="460" popper-style="box-shadow: rgb(14 18 22 / 35%) 0px 10px 38px -10px, rgb(14 18 22 / 20%) 0px 10px 20px -15px; padding: 20px;">
         <template #reference>
           <img v-if="userInfo" style="width:26px;height:25px;margin-right:21px;position: relative;top:-2px" src="@/assets/icon-start.png" alt="">
         </template>
         <template #default>
-          <MyCollect/>
+          <MyCollect :show="showCollect"/>
         </template>
       </el-popover>
       <!-- 消息 -->