From 6c243d02bc57444b481c1fcd99a05fa61fad6889 Mon Sep 17 00:00:00 2001 From: CaiHaosen <“caihaosen@mail.bnu.edu.cn> Date: Tue, 27 Aug 2024 11:07:07 +0800 Subject: [PATCH 1/2] fix: add type assertions to fix TypeScript errors --- ui/src/views/HtmlInjectionList.vue | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ui/src/views/HtmlInjectionList.vue b/ui/src/views/HtmlInjectionList.vue index 8687556a..e0411f60 100644 --- a/ui/src/views/HtmlInjectionList.vue +++ b/ui/src/views/HtmlInjectionList.vue @@ -40,13 +40,12 @@ const activeTab = ref("All"); // 获取代码注入列表 const fetchHtmlInjections = async () => { const response = await axiosInstance.get("/apis/theme.halo.run/v1alpha1/htmlinjections"); - htmlInjections.value = response.data; + htmlInjections.value = response.data as HtmlInjectionList; fuse.value = new Fuse(response.data.items, { keys: ['spec.name', 'spec.description'], threshold: 0.3, }); - //console.log('fetch data:', response.data); - + console.log('fetch data:', response.data); }; // 打开模态窗口 @@ -116,7 +115,7 @@ const handleToggle = (htmlInjection: HtmlInjection) => { const filteredHtmlInjections = computed(() => { let results = htmlInjections.value.items; if (keyword.value && fuse.value) { - results = fuse.value.search(keyword.value).map(result => result.item); + results = fuse.value.search(keyword.value).map(result => result.item as HtmlInjection); } if (activeTab.value === "Enabled") { return results.filter(htmlInjection => htmlInjection.spec.enabled); From 3dfc79bdd3a8ecd9aad5fee99205e004c0bdf849 Mon Sep 17 00:00:00 2001 From: CaiHaosen <“caihaosen@mail.bnu.edu.cn> Date: Wed, 28 Aug 2024 11:05:55 +0800 Subject: [PATCH 2/2] refactor: split HtmlInjection form into creation and editing components --- ui/src/views/HtmlInjectionAdd.vue | 154 -------------------- ui/src/views/HtmlInjectionCreationModal.vue | 58 ++++++++ ui/src/views/HtmlInjectionEditionModal.vue | 52 +++++++ ui/src/views/HtmlInjectionForm.vue | 88 +++++++++++ ui/src/views/HtmlInjectionList.vue | 90 +++++++----- 5 files changed, 252 insertions(+), 190 deletions(-) delete mode 100644 ui/src/views/HtmlInjectionAdd.vue create mode 100644 ui/src/views/HtmlInjectionCreationModal.vue create mode 100644 ui/src/views/HtmlInjectionEditionModal.vue create mode 100644 ui/src/views/HtmlInjectionForm.vue diff --git a/ui/src/views/HtmlInjectionAdd.vue b/ui/src/views/HtmlInjectionAdd.vue deleted file mode 100644 index 5462871f..00000000 --- a/ui/src/views/HtmlInjectionAdd.vue +++ /dev/null @@ -1,154 +0,0 @@ - - - - - diff --git a/ui/src/views/HtmlInjectionCreationModal.vue b/ui/src/views/HtmlInjectionCreationModal.vue new file mode 100644 index 00000000..ca0a306b --- /dev/null +++ b/ui/src/views/HtmlInjectionCreationModal.vue @@ -0,0 +1,58 @@ + + + + diff --git a/ui/src/views/HtmlInjectionEditionModal.vue b/ui/src/views/HtmlInjectionEditionModal.vue new file mode 100644 index 00000000..f257fd5b --- /dev/null +++ b/ui/src/views/HtmlInjectionEditionModal.vue @@ -0,0 +1,52 @@ + + + + diff --git a/ui/src/views/HtmlInjectionForm.vue b/ui/src/views/HtmlInjectionForm.vue new file mode 100644 index 00000000..ded8ffc6 --- /dev/null +++ b/ui/src/views/HtmlInjectionForm.vue @@ -0,0 +1,88 @@ + + + + + diff --git a/ui/src/views/HtmlInjectionList.vue b/ui/src/views/HtmlInjectionList.vue index e0411f60..bdf9c8d4 100644 --- a/ui/src/views/HtmlInjectionList.vue +++ b/ui/src/views/HtmlInjectionList.vue @@ -1,5 +1,5 @@