From e2084a34c12c458930959cff9b02013b9e6c1976 Mon Sep 17 00:00:00 2001 From: Twilight Date: Wed, 18 Sep 2024 17:30:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E8=B5=84=E6=96=99?= =?UTF-8?q?=E5=BA=93=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/settings/LibrarySettings.vue | 63 ++++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/src/components/settings/LibrarySettings.vue b/src/components/settings/LibrarySettings.vue index 313a5aa..7a15d55 100644 --- a/src/components/settings/LibrarySettings.vue +++ b/src/components/settings/LibrarySettings.vue @@ -152,6 +152,40 @@ 上传文档 + +
+ + + +
+
+ {{ c.name }} +
+
+ + + + + + + + +
删除后,文档将无法被检索
+
+
+
+
+
+
+
@@ -169,6 +203,8 @@ import { TrashBinOutline, SettingsOutline, DocumentOutline, + Reload, + Checkmark } from "@vicons/ionicons5"; import { AxiosError } from "axios"; import { useMessage } from "naive-ui"; @@ -192,11 +228,23 @@ const createDocument: Ref = ref({ name: "", content: "", }); -const libraryDocuments: Ref = ref([]); -const showEditDialog = (library: EntityLibrary) => { +const documents: Ref = ref([]); + +const showEditDialog = async (library: EntityLibrary) => { currentLibrary.value = library; showEditLibraryDialog.value = true; + + getDocuments(library.id ?? 0); }; + +const getDocuments = async (libraryId: number) => { + await getApi() + .Library.apiV1LibrariesIdDocumentsGet(libraryId) + .then((r) => { + documents.value = r.data.data ?? []; + }); +}; + const updateLibrary = async () => { if (currentLibrary.value.id) { await getApi().Library.apiV1LibrariesIdPut(currentLibrary.value.id, { @@ -238,9 +286,20 @@ const newDocument = async () => { currentLibrary.value.id, createDocument.value ); + + getDocuments(currentLibrary.value.id); } }; +const deleteDocument = async (documentId: number) => { + await getApi().Library.apiV1LibrariesIdDocumentsDocumentIdDelete( + documentId, + currentLibrary.value.id ?? 0 + ); + + getDocuments(currentLibrary.value.id ?? 0); +}; + onMounted(() => { libraryStore.updateLibraries(); });