Selaa lähdekoodia

feat: 添加确认拦截

王晓东 1 kuukausi sitten
vanhempi
commit
1dd759e61f

+ 1 - 1
src/pages/agent-avatars/index.tsx

@@ -78,7 +78,7 @@ export default function Index() {
     });
   };
 
-  useDidShow(()=> {
+  useDidShow(() => {
     mutate()
   })
 

+ 48 - 0
src/pages/agent/hooks/useConfirms.tsx

@@ -0,0 +1,48 @@
+import { View } from "@tarojs/components";
+import { useModalStore } from "@/store/modalStore";
+import Taro from "@tarojs/taro";
+export const useConfirms = () => {
+  const { showModal } = useModalStore((state) => state.actions);
+  // 回退确认
+  const navbackConfirm = async () => {
+    return await new Promise((resolve)=> {
+      showModal({
+        content: <View className="text-black font-pingfangSCMedium font-medium text-14 leading-22">确定放弃创建智能体?</View>,
+        confirmText: "我再想想",
+        onConfirm() {
+          Taro.showTabBar().catch(()=> {});
+          resolve(true)
+        },
+        onCancel() {
+          Taro.showTabBar().catch(()=> {});
+          resolve(false)
+        },
+      })
+    })
+  }
+
+
+  const saveAvatarConfirm = async () => {
+    return await new Promise((resolve)=> {
+      showModal({
+        content: <View className="text-black font-pingfangSCMedium font-medium text-14 leading-22">为你的智能体设置一个形象吧</View>,
+        confirmText: "继续设置",
+        cancelText: "暂时不设置",
+        onConfirm() {
+          Taro.showTabBar().catch(()=> {});
+          resolve(true)
+        },
+        onCancel() {
+          Taro.showTabBar().catch(()=> {});
+          resolve(false)
+        },
+      })
+    })
+  }
+
+
+  return {
+    navbackConfirm,
+    saveAvatarConfirm,
+  }
+}

+ 1 - 1
src/pages/agent/index.tsx

@@ -67,7 +67,7 @@ export default function Index() {
     if(!agentTemp){
       return true
     }
-    console.log(agentTemp, agent, 3333)
+    // 创建的智能体没有名字时拦截弹窗
     if(!agentTemp.name){
       const r = await new Promise((resolve)=> {
         showModal({