Bladeren bron

生成图片、视频失败后积分退回提示

liyanbo 2 weken geleden
bovenliggende
commit
7e93bebe4f

+ 5 - 4
src/components/ai/image/ImageToImage.vue

@@ -167,6 +167,7 @@ const selectedStyle = ref('');
 const styleList = ['电影写真', '中国风', '卡通', '动漫', '素描', '像素风格'];
 const styleList = ['电影写真', '中国风', '卡通', '动漫', '素描', '像素风格'];
 const conversationInProgress = ref(false);
 const conversationInProgress = ref(false);
 const modelId = ref(0)
 const modelId = ref(0)
+const POINT_COST = 100
 
 
 onMounted(async () => {
 onMounted(async () => {
   try {
   try {
@@ -269,7 +270,7 @@ const sendMessage = async() => {
   }
   }
   if (conversationInProgress.value) return
   if (conversationInProgress.value) return
 
 
-  if (!await ensureAiPoint(100)) return
+  if (!await ensureAiPoint(POINT_COST)) return
 
 
   // 如果正在录音,先停止录音
   // 如果正在录音,先停止录音
   if (isVoiceRecording.value) {
   if (isVoiceRecording.value) {
@@ -316,7 +317,7 @@ const sendMessage = async() => {
   } catch (error) {
   } catch (error) {
     const loadingIdx = imageAllList.value.findIndex(m => m.loading === true)
     const loadingIdx = imageAllList.value.findIndex(m => m.loading === true)
     if (loadingIdx !== -1) imageAllList.value.splice(loadingIdx, 1)
     if (loadingIdx !== -1) imageAllList.value.splice(loadingIdx, 1)
-    Message().error('创建图片生成任务失败,请稍后重试')
+    Message().error('创建图片生成任务失败,请稍后重试,本次未消耗积分')
   } finally {
   } finally {
     conversationInProgress.value = false;
     conversationInProgress.value = false;
   }
   }
@@ -367,11 +368,11 @@ const refreshWatchImages = async () => {
 
 
     if (image.status === AiImageStatusEnum.FAIL) {
     if (image.status === AiImageStatusEnum.FAIL) {
       const errorMsg = parseArkErrorMessage(image.errorMessage)
       const errorMsg = parseArkErrorMessage(image.errorMessage)
-      const failMsg = { id: genMsgId(), type: 'ai', content: `生成图片失败:${errorMsg}` }
+      const failMsg = { id: genMsgId(), type: 'ai', content: `生成图片失败:${errorMsg}(消耗的 ✦${POINT_COST} 积分已退回)` }
       imageAllList.value.push(failMsg)
       imageAllList.value.push(failMsg)
       cacheDataHistoryList.value.push(failMsg)
       cacheDataHistoryList.value.push(failMsg)
       localStorage.setItem(props.cacheDataHistoryKey, JSON.stringify(cacheDataHistoryList.value))
       localStorage.setItem(props.cacheDataHistoryKey, JSON.stringify(cacheDataHistoryList.value))
-      Message().error(`图片生成失败:${errorMsg}`)
+      Message().error(`图片生成失败:${errorMsg},消耗的 ✦${POINT_COST} 积分已退回`)
       return
       return
     }
     }
 
 

+ 5 - 4
src/components/ai/image/TextToImage.vue

@@ -170,6 +170,7 @@ const cacheDataHistoryList = ref([]);
 const conversationInProgress = ref(false);
 const conversationInProgress = ref(false);
 const demoImageList = [demo1, demo2, demo3, demo4]
 const demoImageList = [demo1, demo2, demo3, demo4]
 const modelId = ref(0)
 const modelId = ref(0)
+const POINT_COST = 100
 
 
 onMounted(async () => {
 onMounted(async () => {
   try {
   try {
@@ -270,7 +271,7 @@ const sendMessage = async() => {
   }
   }
   if (conversationInProgress.value) return
   if (conversationInProgress.value) return
 
 
-  if (!await ensureAiPoint(100)) return
+  if (!await ensureAiPoint(POINT_COST)) return
 
 
   // 如果正在录音,先停止录音
   // 如果正在录音,先停止录音
   if (isVoiceRecording.value) {
   if (isVoiceRecording.value) {
@@ -310,7 +311,7 @@ const sendMessage = async() => {
   } catch (error) {
   } catch (error) {
     const loadingIdx = imageAllList.value.findIndex(m => m.loading === true)
     const loadingIdx = imageAllList.value.findIndex(m => m.loading === true)
     if (loadingIdx !== -1) imageAllList.value.splice(loadingIdx, 1)
     if (loadingIdx !== -1) imageAllList.value.splice(loadingIdx, 1)
-    Message().error('创建图片生成任务失败,请稍后重试')
+    Message().error('创建图片生成任务失败,请稍后重试,本次未消耗积分')
   } finally {
   } finally {
     conversationInProgress.value = false;
     conversationInProgress.value = false;
   }
   }
@@ -359,11 +360,11 @@ const refreshWatchImages = async () => {
 
 
     if (image.status === AiImageStatusEnum.FAIL) {
     if (image.status === AiImageStatusEnum.FAIL) {
       const errorMsg = parseArkErrorMessage(image.errorMessage)
       const errorMsg = parseArkErrorMessage(image.errorMessage)
-      const failMsg = { id: genMsgId(), type: 'ai', content: `生成图片失败:${errorMsg}` }
+      const failMsg = { id: genMsgId(), type: 'ai', content: `生成图片失败:${errorMsg}(消耗的 ✦${POINT_COST} 积分已退回)` }
       imageAllList.value.push(failMsg)
       imageAllList.value.push(failMsg)
       cacheDataHistoryList.value.push(failMsg)
       cacheDataHistoryList.value.push(failMsg)
       localStorage.setItem(props.cacheDataHistoryKey, JSON.stringify(cacheDataHistoryList.value))
       localStorage.setItem(props.cacheDataHistoryKey, JSON.stringify(cacheDataHistoryList.value))
-      Message().error(`图片生成失败:${errorMsg}`)
+      Message().error(`图片生成失败:${errorMsg},消耗的 ✦${POINT_COST} 积分已退回`)
       return
       return
     }
     }
 
 

+ 5 - 4
src/components/ai/video/ImageToVideo.vue

@@ -147,6 +147,7 @@ const imageUploadRef = ref(null);
 // 对话状态变量
 // 对话状态变量
 const conversationInProgress = ref(false);
 const conversationInProgress = ref(false);
 const modelId = ref(0)
 const modelId = ref(0)
+const POINT_COST = 500
 
 
 onMounted(async () => {
 onMounted(async () => {
   try {
   try {
@@ -252,7 +253,7 @@ const sendMessage = async() => {
   }
   }
   if (conversationInProgress.value) return
   if (conversationInProgress.value) return
 
 
-  if (!await ensureAiPoint(500)) return
+  if (!await ensureAiPoint(POINT_COST)) return
 
 
   // 如果正在录音,先停止录音
   // 如果正在录音,先停止录音
   if (isVoiceRecording.value) {
   if (isVoiceRecording.value) {
@@ -294,7 +295,7 @@ const sendMessage = async() => {
     // 创建任务失败,移除 loading 消息
     // 创建任务失败,移除 loading 消息
     const loadingIdx = imageAllList.value.findIndex(m => m.loading === true)
     const loadingIdx = imageAllList.value.findIndex(m => m.loading === true)
     if (loadingIdx !== -1) imageAllList.value.splice(loadingIdx, 1)
     if (loadingIdx !== -1) imageAllList.value.splice(loadingIdx, 1)
-    Message().error('创建视频生成任务失败,请稍后重试')
+    Message().error('创建视频生成任务失败,请稍后重试,本次未消耗积分')
   } finally {
   } finally {
     conversationInProgress.value = false;
     conversationInProgress.value = false;
   }
   }
@@ -345,11 +346,11 @@ const refreshWatchImages = async () => {
 
 
     if (image.status === AiImageStatusEnum.FAIL) {
     if (image.status === AiImageStatusEnum.FAIL) {
       const errorMsg = parseArkErrorMessage(image.errorMessage)
       const errorMsg = parseArkErrorMessage(image.errorMessage)
-      const failMsg = { id: genMsgId(), type: 'ai', content: `生成视频失败:${errorMsg}` }
+      const failMsg = { id: genMsgId(), type: 'ai', content: `生成视频失败:${errorMsg}(消耗的 ✦${POINT_COST} 积分已退回)` }
       imageAllList.value.push(failMsg)
       imageAllList.value.push(failMsg)
       cacheDataHistoryList.value.push(failMsg)
       cacheDataHistoryList.value.push(failMsg)
       localStorage.setItem(props.cacheDataHistoryKey, JSON.stringify(cacheDataHistoryList.value))
       localStorage.setItem(props.cacheDataHistoryKey, JSON.stringify(cacheDataHistoryList.value))
-      Message().error(`视频生成失败:${errorMsg}`)
+      Message().error(`视频生成失败:${errorMsg},消耗的 ✦${POINT_COST} 积分已退回`)
       return
       return
     }
     }