diff --git a/src/modules/interface/themes/components/ThemeListModal.vue b/src/modules/interface/themes/components/ThemeListModal.vue index f6df9555..49dbf817 100644 --- a/src/modules/interface/themes/components/ThemeListModal.vue +++ b/src/modules/interface/themes/components/ThemeListModal.vue @@ -2,15 +2,12 @@ import { IconAddCircle, IconGitHub, - Dialog, VButton, VEmpty, VModal, VSpace, - VTag, VEntity, VEntityField, - VStatusDot, VTabItem, VTabs, VLoading, @@ -18,15 +15,11 @@ import { import LazyImage from "@/components/image/LazyImage.vue"; import ThemePreviewModal from "./preview/ThemePreviewModal.vue"; import ThemeUploadModal from "./ThemeUploadModal.vue"; +import ThemeListItem from "./components/ThemeListItem.vue"; import { computed, ref, watch } from "vue"; import type { Theme } from "@halo-dev/api-client"; import { apiClient } from "@/utils/api-client"; -import { usePermission } from "@/utils/permission"; import { onBeforeRouteLeave } from "vue-router"; -import { useThemeStore } from "@/stores/theme"; -import { storeToRefs } from "pinia"; - -const { currentUserHasPermission } = usePermission(); const props = withDefaults( defineProps<{ @@ -49,7 +42,7 @@ const emit = defineEmits<{ const activeTab = ref("installed"); const themes = ref([] as Theme[]); const loading = ref(false); -const themeInstall = ref(false); +const themeUploadVisible = ref(false); const creating = ref(false); const refreshInterval = ref(); @@ -57,8 +50,6 @@ const modalTitle = computed(() => { return activeTab.value === "installed" ? "已安装的主题" : "未安装的主题"; }); -const { activatedTheme } = storeToRefs(useThemeStore()); - const handleFetchThemes = async (options?: { mute?: boolean }) => { try { clearInterval(refreshInterval.value); @@ -104,57 +95,6 @@ watch( } ); -const handleUninstall = async (theme: Theme, deleteExtensions?: boolean) => { - Dialog.warning({ - title: `${ - deleteExtensions - ? "确定要删除该主题以及对应的配置吗?" - : "确定要删除该主题吗?" - }`, - description: "该操作不可恢复。", - onConfirm: async () => { - try { - await apiClient.extension.theme.deletethemeHaloRunV1alpha1Theme({ - name: theme.metadata.name, - }); - - // delete theme setting and configMap - if (!deleteExtensions) { - return; - } - - const { settingName, configMapName } = theme.spec; - - if (settingName) { - await apiClient.extension.setting.deletev1alpha1Setting( - { - name: settingName, - }, - { - mute: true, - } - ); - } - - if (configMapName) { - await apiClient.extension.configMap.deletev1alpha1ConfigMap( - { - name: configMapName, - }, - { - mute: true, - } - ); - } - } catch (e) { - console.error("Failed to uninstall theme", e); - } finally { - await handleFetchThemes(); - } - }, - }); -}; - const handleCreateTheme = async (theme: Theme) => { try { creating.value = true; @@ -204,6 +144,7 @@ defineExpose({ handleFetchThemes, }); +// preview const previewVisible = ref(false); const selectedPreviewTheme = ref(); @@ -211,6 +152,19 @@ const handleOpenPreview = (theme: Theme) => { selectedPreviewTheme.value = theme; previewVisible.value = true; }; + +// upgrade +const themeToUpgrade = ref(); + +const handleOpenUpgradeModal = (theme: Theme) => { + themeToUpgrade.value = theme; + themeUploadVisible.value = true; +}; + +const handleOpenInstallModal = () => { + themeToUpgrade.value = undefined; + themeUploadVisible.value = true; +};