diff --git a/packages/frontend/src/scripts/tms/provide-ui.ts b/packages/frontend/src/scripts/tms/provide-ui.ts new file mode 100644 index 000000000000..a7c647ca3ab4 --- /dev/null +++ b/packages/frontend/src/scripts/tms/provide-ui.ts @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: syuilo and misskey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { inject, provide } from 'vue'; + +type Ui = ( + | 'universal' + | 'deck' + | 'classic' + | 'visitor' + | 'zen' + | 'minimum' +); + +const UI_PROVIDE_KEY = Symbol('UiProvideKey'); + +export const provideUi = (ui: Ui): void => { + provide(UI_PROVIDE_KEY, ui); +}; + +export const injectUi = (): Ui | undefined => { + return inject(UI_PROVIDE_KEY); +}; diff --git a/packages/frontend/src/ui/classic.vue b/packages/frontend/src/ui/classic.vue index 9bb49b3a81d6..6400dfd8f758 100644 --- a/packages/frontend/src/ui/classic.vue +++ b/packages/frontend/src/ui/classic.vue @@ -57,9 +57,12 @@ import { defaultStore } from '@/store.js'; import { i18n } from '@/i18n.js'; import { miLocalStorage } from '@/local-storage.js'; import { mainRouter } from '@/router/main.js'; +import { provideUi } from '@/scripts/tms/provide-ui.js'; const XHeaderMenu = defineAsyncComponent(() => import('./classic.header.vue')); const XWidgets = defineAsyncComponent(() => import('./universal.widgets.vue')); +provideUi('classic'); + const isRoot = computed(() => mainRouter.currentRoute.value.name === 'index'); const DESKTOP_THRESHOLD = 1100; diff --git a/packages/frontend/src/ui/deck.vue b/packages/frontend/src/ui/deck.vue index 4aa4ccdb2375..e10851083ead 100644 --- a/packages/frontend/src/ui/deck.vue +++ b/packages/frontend/src/ui/deck.vue @@ -118,6 +118,7 @@ import XDirectColumn from '@/ui/deck/direct-column.vue'; import XRoleTimelineColumn from '@/ui/deck/role-timeline-column.vue'; import { mainRouter } from '@/router/main.js'; import { MenuItem } from '@/types/menu.js'; +import { provideUi } from '@/scripts/tms/provide-ui.js'; const XStatusBars = defineAsyncComponent(() => import('@/ui/_common_/statusbars.vue')); const XAnnouncements = defineAsyncComponent(() => import('@/ui/_common_/announcements.vue')); @@ -134,6 +135,8 @@ const columnComponents = { roleTimeline: XRoleTimelineColumn, }; +provideUi('deck'); + mainRouter.navHook = (path, flag): boolean => { if (flag === 'forcePage') return false; const noMainColumn = !deckStore.state.columns.some(x => x.type === 'main'); diff --git a/packages/frontend/src/ui/minimum.vue b/packages/frontend/src/ui/minimum.vue index db5eb19c2079..e83adcc6c053 100644 --- a/packages/frontend/src/ui/minimum.vue +++ b/packages/frontend/src/ui/minimum.vue @@ -19,6 +19,9 @@ import XCommon from './_common_/common.vue'; import { PageMetadata, provideMetadataReceiver, provideReactiveMetadata } from '@/scripts/page-metadata.js'; import { instanceName } from '@/config.js'; import { mainRouter } from '@/router/main.js'; +import { provideUi } from '@/scripts/tms/provide-ui.js'; + +provideUi('minimum'); const isRoot = computed(() => mainRouter.currentRoute.value.name === 'index'); diff --git a/packages/frontend/src/ui/universal.vue b/packages/frontend/src/ui/universal.vue index 3bce1c0d3690..ace3e986c7dc 100644 --- a/packages/frontend/src/ui/universal.vue +++ b/packages/frontend/src/ui/universal.vue @@ -111,12 +111,15 @@ import { miLocalStorage } from '@/local-storage.js'; import { CURRENT_STICKY_BOTTOM } from '@/const.js'; import { useScrollPositionManager } from '@/nirax.js'; import { mainRouter } from '@/router/main.js'; +import { provideUi } from '@/scripts/tms/provide-ui.js'; const XWidgets = defineAsyncComponent(() => import('./universal.widgets.vue')); const XSidebar = defineAsyncComponent(() => import('@/ui/_common_/navbar.vue')); const XStatusBars = defineAsyncComponent(() => import('@/ui/_common_/statusbars.vue')); const XAnnouncements = defineAsyncComponent(() => import('@/ui/_common_/announcements.vue')); +provideUi('universal'); + const isRoot = computed(() => mainRouter.currentRoute.value.name === 'index'); const DESKTOP_THRESHOLD = 1100; diff --git a/packages/frontend/src/ui/visitor.vue b/packages/frontend/src/ui/visitor.vue index e26c96cd4f37..8ccfc4b4376e 100644 --- a/packages/frontend/src/ui/visitor.vue +++ b/packages/frontend/src/ui/visitor.vue @@ -80,6 +80,9 @@ import MkVisitorDashboard from '@/components/MkVisitorDashboard.vue'; import XSigninDialog from '@/components/MkSigninDialog.vue'; import XSignupDialog from '@/components/MkSignupDialog.vue'; import XCommon from './_common_/common.vue'; +import { provideUi } from '@/scripts/tms/provide-ui.js'; + +provideUi('visitor'); const isRoot = computed(() => mainRouter.currentRoute.value.name === 'index'); diff --git a/packages/frontend/src/ui/zen.vue b/packages/frontend/src/ui/zen.vue index bb8cffaf5206..e9bc9757d5ac 100644 --- a/packages/frontend/src/ui/zen.vue +++ b/packages/frontend/src/ui/zen.vue @@ -28,6 +28,9 @@ import { PageMetadata, provideMetadataReceiver, provideReactiveMetadata } from ' import { instanceName, ui } from '@/config.js'; import { i18n } from '@/i18n.js'; import { mainRouter } from '@/router/main.js'; +import { provideUi } from '@/scripts/tms/provide-ui.js'; + +provideUi('zen'); const isRoot = computed(() => mainRouter.currentRoute.value.name === 'index');