TODO: 完成助理共享
Some checks failed
Build / build (push) Failing after 8m10s

This commit is contained in:
Twilight 2024-09-14 15:39:52 +08:00
parent ce2290aa67
commit ba59c4cab2

View File

@ -76,22 +76,34 @@
:options="librarySelects" :options="librarySelects"
/> />
</n-form-item> </n-form-item>
<n-space>
<n-button type="primary" @click="editAssistant"> 更新 </n-button> <n-button type="primary" @click="editAssistant"> 更新 </n-button>
<n-button type="error" @click="deleteAssistant" class="ml-2">
删除
</n-button>
</n-space>
</n-form> </n-form>
<div class="mt-3" v-if="userTools.length"> <div class="mt-3" v-if="userTools.length">
<n-h3>工具</n-h3> <n-h3>工具</n-h3>
<div class="flex justify-between items-center"> <div class="flex justify-between items-center">
<div> <div>工具 1</div>
工具 1
</div>
<div> <div>
<n-switch /> <n-switch />
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<n-divider />
<div>
<div class="flex justify-between align-middle items-center">
<n-h3>助理共享</n-h3>
<n-button tertiary @click="showCreateDialog = true">
新建助理
</n-button>
</div>
</div>
</n-drawer-content> </n-drawer-content>
</n-drawer> </n-drawer>
@ -138,6 +150,7 @@ import router from "@/router";
import { ref } from "vue"; import { ref } from "vue";
import { import {
EntityAssistant, EntityAssistant,
EntityAssistantShare,
EntityAssistantTool, EntityAssistantTool,
EntityLibrary, EntityLibrary,
EntityTool, EntityTool,
@ -154,19 +167,24 @@ const currentAssistant: Ref<EntityAssistant> = ref({});
const assistants: Ref<EntityAssistant[]> = ref([]); const assistants: Ref<EntityAssistant[]> = ref([]);
const librarySelects: any = ref([]); const librarySelects: any = ref([]);
const libraries: Ref<EntityLibrary[]> = ref([]); const libraries: Ref<EntityLibrary[]> = ref([]);
const assistantShares: Ref<EntityAssistantShare[]> = ref([]);
async function getChats() { async function getChats() {
chatStore.chats = (await getApi().Chat.apiV1ChatsGet()).data.data; chatStore.chats = (await getApi().Chat.apiV1ChatsGet()).data.data;
} }
const deleteAssistant = async (id: number) => { const deleteAssistant = async () => {
dialog.warning({ dialog.warning({
title: "删除助理", title: "删除助理",
content: "删除后,将不能恢复", content: "删除后,将不能恢复",
positiveText: "确定", positiveText: "确定",
negativeText: "取消", negativeText: "取消",
onPositiveClick: async () => { onPositiveClick: async () => {
await getApi().Assistant.apiV1AssistantsIdDelete(id); await getApi().Assistant.apiV1AssistantsIdDelete(
currentAssistantId.value
);
await getAssistants(); await getAssistants();
showSettingsDialog.value = false;
}, },
}); });
}; };
@ -177,6 +195,8 @@ const showEditAssistant = async (id: number) => {
currentAssistant.value = currentAssistant.value =
(await getApi().Assistant.apiV1AssistantsIdGet(id)).data.data ?? {}; (await getApi().Assistant.apiV1AssistantsIdGet(id)).data.data ?? {};
assistantShares.value =
(await getApi().Assistant.apiV1AssistantsIdSharesGet(id)).data.data ?? [];
getTools(); getTools();
}; };
@ -207,6 +227,7 @@ const createAssistant = async () => {
currentAssistant.value.description ?? currentAssistant.value.name ?? "", currentAssistant.value.description ?? currentAssistant.value.name ?? "",
}); });
await getAssistants(); await getAssistants();
showCreateDialog.value = false;
}; };
const getLibraries = async () => { const getLibraries = async () => {