From 925f8d0ea461773933bee183900859bbb633b049 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Mon, 27 Nov 2023 17:38:08 +0800 Subject: [PATCH] feat: add sticky block component (#4919) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind feature /area console /milestone 2.11.x #### What this PR does / why we need it: 添加 `` 组件,用于将元素固定在顶部或者底部。 此外,此 PR 针对主题设置、插件设置、系统设置等表单可能较长的页面使用了此组件。 图片 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/4548 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 添加 `` 组件,用于将元素固定在顶部或者底部,并为主题 / 插件 / 系统设置的底部保存按钮区域做了适配。 ``` --- .../modules/interface/themes/ThemeSetting.vue | 25 ++++---- .../modules/system/plugins/tabs/Setting.vue | 26 +++++---- .../system/settings/SystemSettings.vue | 4 +- .../settings/tabs/NotificationSetting.vue | 26 +++++---- .../modules/system/settings/tabs/Setting.vue | 58 ++++++++++--------- .../components/sticky-block/StickyBlock.vue | 53 +++++++++++++++++ 6 files changed, 129 insertions(+), 63 deletions(-) create mode 100644 console/src/components/sticky-block/StickyBlock.vue diff --git a/console/console-src/modules/interface/themes/ThemeSetting.vue b/console/console-src/modules/interface/themes/ThemeSetting.vue index f0f617919..4da9c405d 100644 --- a/console/console-src/modules/interface/themes/ThemeSetting.vue +++ b/console/console-src/modules/interface/themes/ThemeSetting.vue @@ -14,6 +14,7 @@ import { apiClient } from "@/utils/api-client"; import { useSettingFormConvert } from "@console/composables/use-setting-form"; import { useI18n } from "vue-i18n"; import { useQuery, useQueryClient } from "@tanstack/vue-query"; +import StickyBlock from "@/components/sticky-block/StickyBlock.vue"; const { t } = useI18n(); const queryClient = useQueryClient(); @@ -86,17 +87,19 @@ await suspense(); :data="configMapFormData[group]" /> -
-
- - {{ $t("core.common.buttons.save") }} - -
-
+ + + {{ $t("core.common.buttons.save") }} + + diff --git a/console/console-src/modules/system/plugins/tabs/Setting.vue b/console/console-src/modules/system/plugins/tabs/Setting.vue index 3a0a535db..7223112db 100644 --- a/console/console-src/modules/system/plugins/tabs/Setting.vue +++ b/console/console-src/modules/system/plugins/tabs/Setting.vue @@ -14,6 +14,7 @@ import type { ConfigMap, Plugin, Setting } from "@halo-dev/api-client"; import { useI18n } from "vue-i18n"; import { useQuery, useQueryClient } from "@tanstack/vue-query"; import { toRaw } from "vue"; +import StickyBlock from "@/components/sticky-block/StickyBlock.vue"; const { t } = useI18n(); const queryClient = useQueryClient(); @@ -82,17 +83,20 @@ const handleSaveConfigMap = async () => { /> -
-
- - {{ $t("core.common.buttons.save") }} - -
-
+ + + + {{ $t("core.common.buttons.save") }} + + diff --git a/console/console-src/modules/system/settings/SystemSettings.vue b/console/console-src/modules/system/settings/SystemSettings.vue index 6c285ff3b..706872de6 100644 --- a/console/console-src/modules/system/settings/SystemSettings.vue +++ b/console/console-src/modules/system/settings/SystemSettings.vue @@ -82,7 +82,7 @@ provide>("setting", setting);
- + -
+
diff --git a/console/console-src/modules/system/settings/tabs/NotificationSetting.vue b/console/console-src/modules/system/settings/tabs/NotificationSetting.vue index 30a0778d8..f5361b4dd 100644 --- a/console/console-src/modules/system/settings/tabs/NotificationSetting.vue +++ b/console/console-src/modules/system/settings/tabs/NotificationSetting.vue @@ -10,6 +10,7 @@ import { computed } from "vue"; import { toRaw } from "vue"; import type { FormKitSchemaCondition, FormKitSchemaNode } from "@formkit/core"; import { useI18n } from "vue-i18n"; +import StickyBlock from "@/components/sticky-block/StickyBlock.vue"; const queryClient = useQueryClient(); const { t } = useI18n(); @@ -86,17 +87,20 @@ const { isLoading: isMutating, mutate } = useMutation({ > -
-
- - {{ $t("core.common.buttons.save") }} - -
-
+ + + + {{ $t("core.common.buttons.save") }} + +
diff --git a/console/console-src/modules/system/settings/tabs/Setting.vue b/console/console-src/modules/system/settings/tabs/Setting.vue index 8cdc6ab96..e50cc1579 100644 --- a/console/console-src/modules/system/settings/tabs/Setting.vue +++ b/console/console-src/modules/system/settings/tabs/Setting.vue @@ -4,6 +4,7 @@ import { computed, ref, type Ref, inject, toRaw } from "vue"; // components import { Toast, VButton } from "@halo-dev/components"; +import StickyBlock from "@/components/sticky-block/StickyBlock.vue"; // hooks import { useSettingFormConvert } from "@console/composables/use-setting-form"; @@ -67,35 +68,36 @@ const handleSaveConfigMap = async () => { diff --git a/console/src/components/sticky-block/StickyBlock.vue b/console/src/components/sticky-block/StickyBlock.vue new file mode 100644 index 000000000..96f9b7bb5 --- /dev/null +++ b/console/src/components/sticky-block/StickyBlock.vue @@ -0,0 +1,53 @@ + + + + +