Prechádzať zdrojové kódy

feat: 问答记录增加长按删除

sunxiao 3 dní pred
rodič
commit
96a6a458c7
3 zmenil súbory, kde vykonal 30 pridanie a 4 odobranie
  1. 1 1
      .env.production
  2. 8 0
      src/api/chat.js
  3. 21 3
      src/pages/answer/history.vue

+ 1 - 1
.env.production

@@ -8,5 +8,5 @@ VITE_APP_ENV = 'production'
 VITE_IMGAGE_PATH = 'https://static.fuxicarbon.com/bigModel/wechat'
 
 # 开发环境
-VITE_APP_BASE_API =  http://chat.sequoialibra.com:81/apiServe
+VITE_APP_BASE_API = https://bigmodel.sqlibra.com/apiServe
 

+ 8 - 0
src/api/chat.js

@@ -50,5 +50,13 @@ export const chatApi = {
   getHelperList: () => http({
     method: 'GET',
     url: '/front/bigModel/agentAssistant/list'
+  }),
+
+  /**
+   * 删除问答记录
+   */
+  delAnswerItem: (id) => http({
+    method: 'DELETE',
+    url: '/front/bigModel/chat/deleteOneChtById/' + id
   })
 }

+ 21 - 3
src/pages/answer/history.vue

@@ -19,12 +19,27 @@ const hanldeItemClick = ({ sessionId }) => {
   uni.navigateBack({ delta: 1 });
 }
 
+
+const hanldeItemLongpress = ({ id }) => {
+  uni.showModal({
+    title: "提示",
+    content: "请确认,是否删除该记录",
+    success: async (status) => {
+      if (status.confirm) {
+        await chatApi.delAnswerItem(id);
+        initHistoryList();
+        uni.showToast({ title: '删除成功', icon: 'none', duration: 3000, mask: true });
+      }
+    }
+  })
+}
+
 // 前往个人中心
 const onJumpToUser = () => {
   uni.navigateTo({ url: '/pages/user/index' })
 }
 
-onMounted(() => {
+const initHistoryList = () => {
   chatApi.getQaHistoryList().then(({ data }) => {
     historyList.value = Object.keys(data).map(key => {
       const children = data[key];
@@ -39,7 +54,10 @@ onMounted(() => {
       }
     })?.sort((a, b) => dayjs(b.title).diff(dayjs(a.title)));
   });
-})
+}
+
+onMounted(() => initHistoryList());
+
 </script>
 
 <template>
@@ -51,7 +69,7 @@ onMounted(() => {
       <view class="history-list">
         <view class="history-item" v-for="item, index in historyList" :key="index">
           <view class="title">{{ item.title }}</view>
-          <view class="item-inner" v-for="val, i in item.children" :key="i" @click="hanldeItemClick(val)">
+          <view class="item-inner" v-for="val, i in item.children" :key="i" @click="hanldeItemClick(val)" @longpress="hanldeItemLongpress(val)">
             <view class="time">{{ val.time }}</view>
             <view class="info">
               <view class="circle"></view>