From 4ff8efbbce023add9ea4d90eb00e8cde076bdc52 Mon Sep 17 00:00:00 2001 From: CaiHaosen <“caihaosen@mail.bnu.edu.cn> Date: Fri, 12 Jul 2024 12:59:58 +0800 Subject: [PATCH] Implement UI with Basic CRUD Functionality --- ui/src/index.ts | 8 +- ui/src/types/index.ts | 46 +++++ ui/src/views/HomeView.vue | 169 ------------------ ui/src/views/HtmlInjectionAdd.vue | 269 +++++++++++++++++++++++++++++ ui/src/views/HtmlInjectionList.vue | 257 +++++++++++++++++++++++++++ 5 files changed, 576 insertions(+), 173 deletions(-) create mode 100644 ui/src/types/index.ts delete mode 100644 ui/src/views/HomeView.vue create mode 100644 ui/src/views/HtmlInjectionAdd.vue create mode 100644 ui/src/views/HtmlInjectionList.vue diff --git a/ui/src/index.ts b/ui/src/index.ts index b0057650..8dc0f15a 100644 --- a/ui/src/index.ts +++ b/ui/src/index.ts @@ -1,5 +1,5 @@ import { definePlugin } from "@halo-dev/console-shared"; -import HomeView from "./views/HomeView.vue"; +import HtmlInjectionList from "./views/HtmlInjectionList.vue"; import { IconPlug } from "@halo-dev/components"; import { markRaw } from "vue"; @@ -9,9 +9,9 @@ export default definePlugin({ { parentName: "Root", route: { - path: "/codes", - name: "InjectionCode", - component: HomeView, + path: "/HtmlInjection", + name: "HtmlInjection", + component: HtmlInjectionList, meta: { title: "代码注入管理", searchable: true, diff --git a/ui/src/types/index.ts b/ui/src/types/index.ts new file mode 100644 index 00000000..947ce46a --- /dev/null +++ b/ui/src/types/index.ts @@ -0,0 +1,46 @@ +export interface Metadata { + name: string; + labels?: { + [key: string]: string; + } | null; + annotations?: { + [key: string]: string; + } | null; + version?: number | null; + creationTimestamp?: string | null; + deletionTimestamp?: string | null; +} + +export interface HtmlInjectionSpec { + name: string; + description: string; + fragment: string; + injectionPoint: 'HEADER' | 'FOOTER'; + pageRules: Set; + enabled: boolean; +} + +/** + * 与自定义模型 HtmlInjection 对应 + */ +export interface HtmlInjection { + spec: HtmlInjectionSpec; + apiVersion: "theme.halo.run/v1alpha1"; // apiVersion=自定义模型的 group/version + kind: "HtmlInjection"; // Code 自定义模型中 @GVK 注解中的 kind + metadata: Metadata; +} + +/** + * HtmlInjection 自定义模型生成 list API 所对应的类型 + */ +export interface HtmlInjectionList { + page: number; + size: number; + total: number; + items: Array; + first: boolean; + last: boolean; + hasNext: boolean; + hasPrevious: boolean; + totalPages: number; +} diff --git a/ui/src/views/HomeView.vue b/ui/src/views/HomeView.vue deleted file mode 100644 index 9b9cb0af..00000000 --- a/ui/src/views/HomeView.vue +++ /dev/null @@ -1,169 +0,0 @@ - - - - - diff --git a/ui/src/views/HtmlInjectionAdd.vue b/ui/src/views/HtmlInjectionAdd.vue new file mode 100644 index 00000000..a3c6397c --- /dev/null +++ b/ui/src/views/HtmlInjectionAdd.vue @@ -0,0 +1,269 @@ + + + + + diff --git a/ui/src/views/HtmlInjectionList.vue b/ui/src/views/HtmlInjectionList.vue new file mode 100644 index 00000000..b9fd4c7e --- /dev/null +++ b/ui/src/views/HtmlInjectionList.vue @@ -0,0 +1,257 @@ + + + + +