From e3b5abc529a6ab8c29512371e027cd006185be1e Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Wed, 20 Jul 2022 16:54:20 +0800 Subject: [PATCH] chore: update themes data mock Signed-off-by: Ryan Wang --- src/modules/interface/themes/ThemeDetail.vue | 153 +++-- src/modules/interface/themes/themes-mock.ts | 587 ------------------- 2 files changed, 113 insertions(+), 627 deletions(-) delete mode 100644 src/modules/interface/themes/themes-mock.ts diff --git a/src/modules/interface/themes/ThemeDetail.vue b/src/modules/interface/themes/ThemeDetail.vue index d6d6e8294..3aaec347f 100644 --- a/src/modules/interface/themes/ThemeDetail.vue +++ b/src/modules/interface/themes/ThemeDetail.vue @@ -14,24 +14,97 @@ import { VTabbar, VTag, } from "@halo-dev/components"; -import { ref } from "vue"; +import { onMounted, ref } from "vue"; import { RouterLink } from "vue-router"; -import { themes } from "@/modules/interface/themes/themes-mock"; +import type { Metadata } from "@halo-dev/api-client"; -const currentTheme = ref(themes[0]); -const changeTheme = ref(false); +interface ThemeAuthor { + name: string; + website: string; +} + +interface ThemeSpec { + displayName: string; + author: ThemeAuthor; + description?: string; + logo?: string; + website?: string; + repo?: string; + version: string; + require: string; +} + +interface Theme { + metadata: Metadata; + spec: ThemeSpec; + kind: string; + apiVersion: string; +} + +const themes = ref([]); +const currentTheme = ref({} as Theme); +const themesModal = ref(false); const themeActiveId = ref("detail"); -// eslint-disable-next-line -const handleChangeTheme = (theme: any) => { +const handleChangeTheme = (theme: Theme) => { currentTheme.value = theme; - changeTheme.value = false; + themesModal.value = false; }; + +const handleFetchThemes = async () => { + themes.value = await new Promise((resolve) => { + resolve([ + { + apiVersion: "theme.halo.run/v1alpha1", + kind: "Theme", + metadata: { + name: "default", + }, + spec: { + displayName: "Default", + author: { + name: "halo-dev", + website: "https://halo.run", + }, + description: "Halo 2.0 的默认主题", + logo: "https://halo.run/logo", + website: "https://github.com/halo-sigs/theme-default.git", + repo: "https://github.com/halo-sigs/theme-default.git", + version: "1.0.0", + require: "2.0.0", + }, + }, + { + apiVersion: "theme.halo.run/v1alpha1", + kind: "Theme", + metadata: { + name: "gtvg", + }, + spec: { + displayName: "GTVG", + author: { + name: "guqing", + website: "https://guqing.xyz", + }, + description: "测试主题", + logo: "https://guqing.xyz/logo.png", + website: "https://github.com/guqing/halo-theme-test.git", + repo: "https://github.com/guqing/halo-theme-test.git", + version: "1.0.0", + require: "2.0.0", + }, + }, + ]); + }); + currentTheme.value = themes.value[0]; +}; + +onMounted(handleFetchThemes);