فهرست منبع

朋友圈添加删除功能

wkw 2 هفته پیش
والد
کامیت
87cf723541

+ 24 - 25
src/api/axios.js

@@ -48,36 +48,35 @@ axiosInstance.interceptors.request.use(
 
 // 响应拦截器
 axiosInstance.interceptors.response.use(
-  (res) => {
-    const systemStore = useSystemStore();
-    systemStore.localLoading();
-    const { code, message: msg } = res.data;
-
+  res => {
+    // HTTP 2xx 的响应
+    const data = res.data;
 
-    if (requestState.NotAccessRight.includes(code)) {
-      // showNotify({ type: 'warning', message: msg });
+    // 旧接口 code
+    if (typeof data.code !== 'undefined') return data;
 
-      return Promise.reject(msg);
-    }
-
-    if (requestState.exception.includes(code)) {
-      // showNotify({ type: 'warning', message: msg });
-      return Promise.reject(msg);
+    // 新接口 ret/status/message
+    if (typeof data.status !== 'undefined') {
+      return {
+        code: data.status === 200 ? 1 : 0, // code 1 表示成功
+        message: data.message || '',
+        data: data
+      }
     }
 
-    return res.data;
+    return data;
   },
-  (err) => {
-    const systemStore = useSystemStore();
-    systemStore.localLoading(); 
-    const msg = err.response?.data ? err.response.data.message : "";
-    // showNotify({ type: 'warning', message: msg });
-    if (requestState.beOverdue.includes( err.status)) { 
-      // 
-      fn_logout(); 
-      return undefined;
-    }
-    return Promise.reject(err);
+  err => {
+    const data = err.response?.data || {};
+    const status = data.status || err.response?.status;
+    const message = data.message || err.message || '请求失败';
+
+    // 统一返回 code = 0 的失败结果,不抛异常
+    return Promise.resolve({
+      code: 0,
+      message,
+      data
+    });
   }
 );
 

+ 5 - 1
src/api/path/im.api.js

@@ -156,4 +156,8 @@ export function dynamicComment(param) {
 //  动态详情
 export function dynamicDetail(params) {
   return httpRequest.get('/dynamic_detail', { params });
-}
+}
+//  删除朋友圈
+export function dynamicRevoke(param) {
+  return httpRequest.post('/wallet/dynamic/revoke', param);
+}

+ 3 - 3
src/updater/update.json

@@ -1,7 +1,7 @@
 {
-  "version": "2.0.6",
-  "releaseDate": "2025-09-22 10:28:58",
-  "checksum": "fa702c100937809e537f48e9ffdff79913de3c12eee8605c82d02df1b26357dd",
+  "version": "2.0.7",
+  "releaseDate": "2025-09-23 08:21:25",
+  "checksum": "2f6d124162387c48e0ffba2d197d8b136ba66b7b7ff0e045009b55dd38d26646",
   "minBinaryVersion": "2.0.0",
   "mandatory": false,
   "upDataDescription": "✨修正一些錯誤。。。。!!!"

+ 41 - 6
src/views/im/components/Discover/Discover.vue

@@ -66,7 +66,10 @@
                 <!-- 底部点赞评论按钮 -->
                 <div class="item-footer">
                   <div class="time">{{ item.created_at }}</div>
-                  <div style="position: relative;">
+                  <div class="icon-style">
+                    <div class="delete-style" @click="deleteItem(item)" v-if="walletAddress == '0xF3aE056E12B164E73309add80fD73709769cA945'">
+                      <van-icon name="delete-o" color="#b6b6b6" />
+                    </div>
                     <div @click="toggleActions(i,item)" style="cursor:pointer; display:inline-block;">
                       <svg-icon class="actions-icon" name="more1"/>
                     </div>
@@ -94,20 +97,20 @@
                   @update:comments="setComments(i, $event)">
                 </Remark>
 
-                <!-- 视频弹框 -->
-                <VideoDialog :visible="showVideo" :url="videoUrl" @close="showVideo = false"></VideoDialog>
               </div>
             </div>
           </div>
         </template>
       </van-list>
     </van-pull-refresh>
+    <!-- 视频弹框 -->
+    <VideoDialog :visible="showVideo" :url="videoUrl" @close="showVideo = false" :videoThumb="videoThumb"></VideoDialog>
   </div>
 </template>
 
 <script>
-import { dynamicList, dynamicLike,dynamicDetail } from "@/api/path/im.api";
-import { showToast, showImagePreview } from 'vant';
+import { dynamicList, dynamicLike,dynamicDetail,dynamicRevoke } from "@/api/path/im.api";
+import { showToast, showImagePreview,showConfirmDialog } from 'vant';
 import Remark from '../remarkList/index.vue';
 import VideoDialog from '../VideoDialog/index.vue';
 
@@ -125,9 +128,13 @@ export default {
       remarkRefs: [],
       showVideo: false,
       videoUrl: '',
-      videoName: ''
+      videoName: '',
+      videoThumb:'',
     }
   },
+  props: {
+    walletAddress: { type: String, default: '' }
+  },
   methods: {
     async loadList(isRefresh = false) {
       if (this.loading) return;
@@ -244,8 +251,28 @@ export default {
       // })
       this.videoUrl = item.video
       this.videoName = item.filename
+      this.videoThumb = item.video_thumb
       this.showVideo = true;
     },
+    // 删除朋友圈
+    deleteItem(item){
+      showConfirmDialog({
+        message: '确定删除吗?',
+        confirmButtonColor:'#4765DD',
+      }).then(async () => {
+        const res = await dynamicRevoke({did:item.dynamic_id});
+        if (res.code == 1) {
+          showToast(res.message || '删除成功');
+          setTimeout(()=>{
+            this.onRefresh();
+          },1000)
+        } else {
+          showToast(res.message || '删除失败');
+        }
+      }).catch(() => {
+        // on cancel
+      });
+    },
     gotoRecord() {
       this.$router.push('record');
     },
@@ -414,6 +441,14 @@ export default {
             font-size: 12px;
             color: #8D8D8D;
           }
+          .icon-style{
+            display: flex;
+            align-items: center;
+            position: relative;
+          }
+          .delete-style{
+            margin-right: 5px;
+          }
           .actions-icon{
             width: 14px;
             height: 14px;

+ 92 - 28
src/views/im/components/VideoDialog/index.vue

@@ -1,58 +1,122 @@
 <template>
     <div v-if="visible" class="video-dialog">
-        <div class="video-container">
-            <div class="header">
-                <van-button type="primary" size="small" @click="close">关闭视频</van-button>
-            </div>
-            <video class="video-box" :src="url" controls autoplay></video>
+      <div class="video-container">
+        <!-- 关闭按钮 -->
+        <div class="header">
+          <van-button type="primary" size="small" @click="close">关闭视频</van-button>
         </div>
+  
+        <!-- 封面图 + loading -->
+        <div v-if="loading" class="thumb-wrapper">
+          <van-image :src="videoThumb" fit="cover" class="video-thumb" />
+          <van-loading class="loading" size="64px" color="#4765DD"/>
+        </div>
+  
+        <!-- 视频 -->
+        <video
+          ref="videoEl"
+          class="video-box"
+          :src="newUrl"
+          controls
+          autoplay
+          @loadeddata="onVideoLoaded"
+        ></video>
+      </div>
     </div>
-</template>
-
-<script>
-export default {
+  </template>
+  
+  <script>
+  export default {
     name: 'VideoDialog',
     props: {
-        visible: { type: Boolean, default: false },
-        url: { type: String, default: '' }
+      visible: { type: Boolean, default: false },
+      url: { type: String, default: '' },
+      videoThumb: { type: String, default: '' }
     },
-    methods: {
-        close() {
-            // 通知父组件
-            this.$emit('close');
+    data() {
+      return {
+        newUrl: '',
+        loading: true
+      }
+    },
+    watch: {
+      visible(val) {
+        if (val) {
+          this.newUrl = this.url;
+          this.loading = true;
         }
+      }
+    },
+    methods: {
+      close() {
+        this.$emit('close');
+        this.pauseVideo();
+      },
+      onVideoLoaded() {
+        this.loading = false;
+      },
+      pauseVideo() {
+        const video = this.$refs.videoEl;
+        if (video && !video.paused) video.pause();
+      }
     }
-};
-</script>
-
-<style scoped>
-.video-dialog {
+  }
+  </script>
+  
+  <style scoped>
+  .video-dialog {
     position: fixed;
     top: 0;
     left: 0;
     width: 100%;
     height: 100%;
     z-index: 9999;
-}
-.video-container {
+  }
+  .video-container {
+    position: relative;
     background: #000;
     width: 100%;
     height: 100vh;
     display: flex;
     flex-direction: column;
-}
-.header {
+  }
+  .header {
     padding: 8px;
     position: absolute;
     top: 10px;
     left: 10px;
     z-index: 10;
-}
+  }
+  
+  /* 封面 + loading */
+  .thumb-wrapper {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100%;
+    height: 100%;
+    z-index: 5;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    flex-direction: column;
+  }
+  .video-thumb {
+    width: 100%;
+    height: 100%;
+    object-fit: cover;
+  }
+  .loading {
+    position: absolute;
+    z-index: 15;
+  }
   
-.video-box {
+  /* 视频 */
+  .video-box {
     flex: 1;
     width: 100%;
     height: 100%;
     object-fit: contain;
-}
-</style>
+    z-index: 1;
+  }
+  </style>  

+ 1 - 1
src/views/im/index.vue

@@ -70,7 +70,7 @@
     </van-pull-refresh>
     </template>
     <template v-else>
-      <Discover />
+      <Discover :walletAddress="walletStore.account"/>
     </template>
     <van-action-sheet
       v-model:show="showSheet"