feat: add reload theme setting support (halo-dev/console#620)

#### What type of PR is this?

/kind feature
/milestone 2.0

#### What this PR does / why we need it:

支持重载主题设置,以便开发主题的时候重载配置。适配 https://github.com/halo-dev/halo/pull/2456

#### Which issue(s) this PR fixes:

Fixes halo-dev/halo#2426

#### Screenshots:

<img width="1664" alt="image" src="https://user-images.githubusercontent.com/21301288/191891908-64e25ec9-968f-4b56-95f8-d1479db0f31b.png">

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo-admin 

#### Does this PR introduce a user-facing change?

```release-note
None
```
pull/3445/head
Ryan Wang 2022-09-27 15:44:17 +08:00 committed by GitHub
parent 38f9762955
commit d55cbe8656
3 changed files with 67 additions and 29 deletions

View File

@ -34,7 +34,7 @@
"@formkit/themes": "1.0.0-beta.10",
"@formkit/vue": "1.0.0-beta.10",
"@halo-dev/admin-shared": "workspace:*",
"@halo-dev/api-client": "^0.0.26",
"@halo-dev/api-client": "^0.0.27",
"@halo-dev/components": "workspace:*",
"@halo-dev/richtext-editor": "^0.0.0-alpha.7",
"@tiptap/extension-character-count": "2.0.0-beta.31",

View File

@ -14,7 +14,7 @@ importers:
'@formkit/themes': 1.0.0-beta.10
'@formkit/vue': 1.0.0-beta.10
'@halo-dev/admin-shared': workspace:*
'@halo-dev/api-client': ^0.0.26
'@halo-dev/api-client': ^0.0.27
'@halo-dev/components': workspace:*
'@halo-dev/richtext-editor': ^0.0.0-alpha.7
'@iconify-json/mdi': ^1.1.33
@ -101,7 +101,7 @@ importers:
'@formkit/themes': 1.0.0-beta.10_tailwindcss@3.1.8
'@formkit/vue': 1.0.0-beta.10_jhzixbi2r7n2xnmwczrcaimaey
'@halo-dev/admin-shared': link:packages/shared
'@halo-dev/api-client': 0.0.26
'@halo-dev/api-client': 0.0.27
'@halo-dev/components': link:packages/components
'@halo-dev/richtext-editor': 0.0.0-alpha.7_vue@3.2.39
'@tiptap/extension-character-count': 2.0.0-beta.31
@ -1894,8 +1894,8 @@ packages:
- windicss
dev: false
/@halo-dev/api-client/0.0.26:
resolution: {integrity: sha512-MSyl2wF3KXSQSYWuqdBcaBgct1RzcQAS9HcLL1oBb0lDLjlUgZv6IEANpPZS80UN0bQjvsGl9JOnqwoIUKUK8A==}
/@halo-dev/api-client/0.0.27:
resolution: {integrity: sha512-ghEz442I8zPrORfCxUdxILgaieHA8v5Pr4k9urL0i19Yeqg179PjXsFHVXkmGUxMzXi5J6F/65D3Qcbq8nHB+Q==}
dev: false
/@halo-dev/richtext-editor/0.0.0-alpha.7_vue@3.2.39:

View File

@ -4,18 +4,34 @@ import { inject } from "vue";
import { RouterLink } from "vue-router";
// components
import { VAlert, VSpace, VTag } from "@halo-dev/components";
import { VAlert, VSpace, VTag, IconMore, VButton } from "@halo-dev/components";
// types
import type { ComputedRef, Ref } from "vue";
import type { Theme } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
const selectedTheme = inject<Ref<Theme | undefined>>("selectedTheme");
const isActivated = inject<ComputedRef<boolean>>("isActivated");
const handleReloadThemeSetting = async () => {
if (!selectedTheme?.value) {
return;
}
try {
await apiClient.theme.reloadThemeSetting({
name: selectedTheme.value.metadata.name,
});
} catch (error) {
console.error("Failed to reload theme setting", error);
}
};
</script>
<template>
<div class="bg-white px-4 py-4 sm:px-6">
<div class="group flex items-center justify-between">
<div class="flex flex-row gap-3">
<div
class="h-12 w-12 overflow-hidden rounded border bg-white hover:shadow-sm"
@ -41,6 +57,28 @@ const isActivated = inject<ComputedRef<boolean>>("isActivated");
</p>
</div>
</div>
<FloatingDropdown>
<div
class="cursor-pointer rounded p-1 transition-all hover:text-blue-600 group-hover:bg-gray-100"
>
<IconMore />
</div>
<template #popper>
<div class="w-48 p-2">
<VSpace class="w-full" direction="column">
<VButton
v-close-popper
block
type="danger"
@click="handleReloadThemeSetting"
>
刷新设置表单
</VButton>
</VSpace>
</div>
</template>
</FloatingDropdown>
</div>
</div>
<div class="border-t border-gray-200">
<dl class="divide-y divide-gray-100">