From 9c2567424819fe894aa81f290c83e68cc771fc08 Mon Sep 17 00:00:00 2001 From: kejun Date: Wed, 22 Mar 2023 17:01:52 +0800 Subject: [PATCH] feat: when error add retry --- components/tool/ToolDetail.vue | 8 +++++- components/tool/ToolForms.vue | 4 ++- composables/useAi.ts | 49 ++++++++++++++++++++-------------- locales/en.json | 3 ++- locales/zh-CN.json | 3 ++- 5 files changed, 43 insertions(+), 24 deletions(-) diff --git a/components/tool/ToolDetail.vue b/components/tool/ToolDetail.vue index cec2dea..a048a76 100644 --- a/components/tool/ToolDetail.vue +++ b/components/tool/ToolDetail.vue @@ -13,10 +13,15 @@ const { reset, toggleHistory, error, + resend, } = useAi(props.tool); function submit(data: any) { - send(data); + if (error.value) { + resend(); + } else { + send(data); + } } function stop() { cancel(); @@ -60,6 +65,7 @@ defineExpose({ @stop="stop" @reset="handleReset" :tool="tool" + :error="error" /> diff --git a/components/tool/ToolForms.vue b/components/tool/ToolForms.vue index 4cb5c1b..2a5f00f 100644 --- a/components/tool/ToolForms.vue +++ b/components/tool/ToolForms.vue @@ -8,6 +8,7 @@ export default defineComponent({ tool: Object as PropType, readonly: Boolean, loading: Boolean, + error: {} as any, }, setup(props) { const { formData } = useToolFormData(props.tool!); @@ -87,7 +88,8 @@ export default defineComponent({
- {{ $t("tool.forms.submit") }} + {{ $t("tool.forms.submit") }} + {{ $t("tool.forms.retry") }}