新增错误提示对话框以提升用户操作反馈

在工具页面,当工具绑定操作失败时,用户将看到一个错误提示对话框,而不是控制台日志。这提高了用户操作的可见性和应用的用户友好性。
```
This commit is contained in:
ivamp 2024-08-03 23:44:28 +08:00
parent f238e45581
commit 5ae5f37556

View File

@ -45,6 +45,21 @@
</v-col>
</v-row>
</div>
<div>
<v-dialog v-model="bindFailed.show" max-width="290" persistent>
<v-card>
<v-card-title class="headline">操作失败</v-card-title>
<v-card-text>{{ bindFailed.message }}</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="green darken-1" @click="bindFailed.show = false"
>好的</v-btn
>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</template>
<script setup lang="ts">
@ -61,7 +76,10 @@ import {
const assistantId = router.currentRoute.value.params.id as number;
const assistant: Ref<ApiV1AssistantsPost200Response> = ref({});
const tools: Ref<ApiV1ToolsGet200Response> = ref({});
const bindFailed = ref({
show: false,
message: "绑定失败",
});
const bindedTools: Ref<ApiV1AssistantsIdToolsGet200Response> = ref({});
function getAssistant() {
@ -104,7 +122,8 @@ function bindTool(toolId: number) {
refresh();
})
.catch((e) => {
console.log(e);
bindFailed.value.show = true;
bindFailed.value.message = e.response.data.error;
});
}