mirror of
https://github.com/halo-dev/halo.git
synced 2025-12-20 16:44:38 +08:00
#### What type of PR is this? /area ui /kind api-change /milestone 2.22.x #### What this PR does / why we need it: See #7925 #### Which issue(s) this PR fixes: Fixes #7925 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 将 `@halo-dev/console-shared` 重命名为 `@halo-dev/ui-shared` ```
30 lines
758 B
TypeScript
30 lines
758 B
TypeScript
import type { Theme } from "@halo-dev/api-client";
|
|
import { consoleApiClient } from "@halo-dev/api-client";
|
|
import { utils } from "@halo-dev/ui-shared";
|
|
import { defineStore } from "pinia";
|
|
import { ref } from "vue";
|
|
|
|
export const useThemeStore = defineStore("theme", () => {
|
|
const activatedTheme = ref<Theme>();
|
|
|
|
async function fetchActivatedTheme() {
|
|
if (!utils.permission.has(["system:themes:view"])) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const { data } = await consoleApiClient.theme.theme.fetchActivatedTheme({
|
|
mute: true,
|
|
});
|
|
|
|
if (data) {
|
|
activatedTheme.value = data;
|
|
}
|
|
} catch (e) {
|
|
console.error("Failed to fetch active theme", e);
|
|
}
|
|
}
|
|
|
|
return { activatedTheme, fetchActivatedTheme };
|
|
});
|