diff --git a/package.json b/package.json index a0fb0985..eb798b37 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@formkit/inputs": "^1.0.0-beta.11", "@formkit/themes": "^1.0.0-beta.11", "@formkit/vue": "^1.0.0-beta.11", - "@halo-dev/api-client": "^0.0.39", + "@halo-dev/api-client": "^0.0.40", "@halo-dev/components": "workspace:*", "@halo-dev/console-shared": "workspace:*", "@halo-dev/richtext-editor": "^0.0.0-alpha.8", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3d5fbbad..2f7cbda9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,7 +13,7 @@ importers: '@formkit/inputs': ^1.0.0-beta.11 '@formkit/themes': ^1.0.0-beta.11 '@formkit/vue': ^1.0.0-beta.11 - '@halo-dev/api-client': ^0.0.39 + '@halo-dev/api-client': ^0.0.40 '@halo-dev/components': workspace:* '@halo-dev/console-shared': workspace:* '@halo-dev/richtext-editor': ^0.0.0-alpha.8 @@ -108,7 +108,7 @@ importers: '@formkit/inputs': 1.0.0-beta.11 '@formkit/themes': 1.0.0-beta.11_tailwindcss@3.2.1 '@formkit/vue': 1.0.0-beta.11_vjnbgdptsk6bkj7ab5a6mk2cwm - '@halo-dev/api-client': 0.0.39 + '@halo-dev/api-client': 0.0.40 '@halo-dev/components': link:packages/components '@halo-dev/console-shared': link:packages/shared '@halo-dev/richtext-editor': 0.0.0-alpha.8_vue@3.2.41 @@ -1953,8 +1953,8 @@ packages: - windicss dev: false - /@halo-dev/api-client/0.0.39: - resolution: {integrity: sha512-GuTTJDOj0PPMXo3KTiNYGACRUXqJKnjnApK303eNPWqVodgR3mJVLFTXwa+euAJOkcSG3KkB5OtUFAkZeHRbPA==} + /@halo-dev/api-client/0.0.40: + resolution: {integrity: sha512-SsB+PZkoCwp0cGKGQY+x2oDWiZDwHYH9nytN28b+kY+HnWmNIWgMT64ZnHoHxOnk44m9S9byxwkkvlOamby0AQ==} dev: false /@halo-dev/richtext-editor/0.0.0-alpha.8_vue@3.2.41: diff --git a/src/components/global-search/GlobalSearchModal.vue b/src/components/global-search/GlobalSearchModal.vue index 0c36359e..dc9d8b34 100644 --- a/src/components/global-search/GlobalSearchModal.vue +++ b/src/components/global-search/GlobalSearchModal.vue @@ -12,7 +12,7 @@ import { IconPages, IconUserSettings, } from "@halo-dev/components"; -import { computed, markRaw, onMounted, ref, watch, type Component } from "vue"; +import { computed, markRaw, ref, watch, type Component } from "vue"; import Fuse from "fuse.js"; import { apiClient } from "@/utils/api-client"; import { usePermission } from "@/utils/permission"; @@ -356,6 +356,8 @@ watch( () => props.visible, (visible) => { if (visible) { + handleBuildSearchIndex(); + setTimeout(() => { globalSearchInput.value?.focus(); }, 100); @@ -369,10 +371,6 @@ watch( } ); -onMounted(() => { - handleBuildSearchIndex(); -}); - const onVisibleChange = (visible: boolean) => { emit("update:visible", visible); }; diff --git a/src/main.ts b/src/main.ts index 1b582dab..cba0e87c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,5 @@ -import type { DirectiveBinding } from "vue"; import { createApp } from "vue"; +import type { DirectiveBinding } from "vue"; import { createPinia } from "pinia"; import App from "./App.vue"; import router from "./router"; @@ -17,6 +17,7 @@ import type { User } from "@halo-dev/api-client"; import { hasPermission } from "@/utils/permission"; import { useRoleStore } from "@/stores/role"; import type { RouteRecordRaw } from "vue-router"; +import { useThemeStore } from "./stores/theme"; const app = createApp(App); @@ -175,9 +176,12 @@ async function loadPluginModules() { } } +let currentUser: User | undefined = undefined; + async function loadCurrentUser() { const { data: user } = await apiClient.user.getCurrentUserDetail(); app.provide("currentUser", user); + currentUser = user; const { data: currentPermissions } = await apiClient.user.getPermissions({ name: "-", @@ -204,6 +208,11 @@ async function loadCurrentUser() { ); } +async function loadActivatedTheme() { + const themeStore = useThemeStore(); + await themeStore.fetchActivatedTheme(); +} + (async function () { await initApp(); })(); @@ -218,13 +227,19 @@ async function initApp() { try { loadCoreModules(); + await loadCurrentUser(); + + if (!currentUser) { + return; + } + + await loadActivatedTheme(); + try { await loadPluginModules(); } catch (e) { console.error("Failed to load plugins", e); } - - await loadCurrentUser(); } catch (e) { console.error(e); } finally { diff --git a/src/modules/contents/pages/components/SinglePageSettingModal.vue b/src/modules/contents/pages/components/SinglePageSettingModal.vue index 09da47f3..a73b26d3 100644 --- a/src/modules/contents/pages/components/SinglePageSettingModal.vue +++ b/src/modules/contents/pages/components/SinglePageSettingModal.vue @@ -5,6 +5,7 @@ import type { SinglePageRequest } from "@halo-dev/api-client"; import cloneDeep from "lodash.clonedeep"; import { apiClient } from "@/utils/api-client"; import { v4 as uuid } from "uuid"; +import { useThemeCustomTemplates } from "@/modules/interface/themes/composables/use-theme"; const initialFormState: SinglePageRequest = { page: { @@ -160,6 +161,9 @@ watchEffect(() => { formState.value = cloneDeep(props.singlePage); } }); + +// custom templates +const { templates } = useThemeCustomTemplates("page");