Skip to content

Commit

Permalink
refactor(TmsSuperMenu): 参照の構造とプレフィックスを変更
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyme committed Jun 26, 2024
1 parent bed6e15 commit 924361e
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 50 deletions.
41 changes: 41 additions & 0 deletions packages/frontend/src/components/TmsSuperMenu.impl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/

export type TmsSuperMenuProps = {
readonly def: ISuperMenuDefinitions;
readonly wideMode?: boolean;
};

export type SuperMenuDisplayMode = 'default' | 'classic' | 'forceList';

export type ISuperMenuDefinitions = {
readonly title?: string;
readonly items: ISuperMenuItem[];
}[];

type ISuperMenuItem = ISuperMenuItemButton | ISuperMenuItemA | ISuperMenuItemLink;

type ISuperMenuItemBase = {
readonly icon: string;
readonly text: string;
readonly active?: boolean;
readonly danger?: boolean;
};

type ISuperMenuItemButton = ISuperMenuItemBase & {
readonly type: 'button';
readonly action: (ev: MouseEvent) => void;
};

type ISuperMenuItemA = ISuperMenuItemBase & {
readonly type: 'a';
readonly href: string;
readonly target: string;
};

type ISuperMenuItemLink = ISuperMenuItemBase & {
readonly type?: 'link';
readonly to: string;
};
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,9 @@ SPDX-License-Identifier: AGPL-3.0-only

<script lang="ts" setup>
import { tmsStore } from '@/tms/store.js';
import { SuperMenuDef } from '@/types/tms/super-menu.js';
import { type TmsSuperMenuProps } from '@/components/TmsSuperMenu.impl.js';
const props = defineProps<{
def: SuperMenuDef;
wideMode?: boolean;
}>();
const props = defineProps<TmsSuperMenuProps>();
</script>

<style lang="scss" module>
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/pages/admin/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkInfo v-if="noEmailServer" warn>{{ i18n.ts.noEmailServerWarning }} <MkA to="/admin/email-settings" class="_link">{{ i18n.ts.configure }}</MkA></MkInfo>
</div>

<MkSuperMenu :def="menuDef" :wideMode="isWide"></MkSuperMenu>
<TmsSuperMenu :def="menuDef" :wideMode="isWide"></TmsSuperMenu>
</div>
</MkSpacer>
</div>
Expand All @@ -48,9 +48,9 @@ import { lookup } from '@/scripts/lookup.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { PageMetadata, definePageMetadata, provideMetadataReceiver, provideReactiveMetadata } from '@/scripts/page-metadata.js';
import { useRouter } from '@/router/supplier.js';
import { SuperMenuDef } from '@/types/tms/super-menu.js';
import MkInfo from '@/components/MkInfo.vue';
import MkSuperMenu from '@/components/MkSuperMenu.vue';
import TmsSuperMenu from '@/components/TmsSuperMenu.vue';
import { type ISuperMenuDefinitions } from '@/components/TmsSuperMenu.impl.js';
const ROOT_PAGE_PATH = '/admin' as const;
const INITIAL_PAGE_PATH = '/admin/overview' as const;
Expand Down Expand Up @@ -168,7 +168,7 @@ provideReactiveMetadata(pageMetadata);
definePageMetadata(() => pageMetadata.value);
//#region menuDef
const menuDef = computed<SuperMenuDef>(() => [{
const menuDef = computed<ISuperMenuDefinitions>(() => [{
title: i18n.ts.quickAction,
items: [{
type: 'button' as const,
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/pages/settings/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkInfo v-if="emailNotConfigured" warn>{{ i18n.ts.emailNotConfiguredWarning }} <MkA to="/settings/email" class="_link">{{ i18n.ts.configure }}</MkA></MkInfo>
</div>

<MkSuperMenu :def="menuDef" :wideMode="isWide"></MkSuperMenu>
<TmsSuperMenu :def="menuDef" :wideMode="isWide"></TmsSuperMenu>
</div>
</MkSpacer>
</div>
Expand All @@ -39,9 +39,9 @@ import * as os from '@/os.js';
import { clearCache } from '@/scripts/clear-cache.js';
import { PageMetadata, definePageMetadata, provideMetadataReceiver, provideReactiveMetadata } from '@/scripts/page-metadata.js';
import { useRouter } from '@/router/supplier.js';
import { SuperMenuDef } from '@/types/tms/super-menu.js';
import MkInfo from '@/components/MkInfo.vue';
import MkSuperMenu from '@/components/MkSuperMenu.vue';
import TmsSuperMenu from '@/components/TmsSuperMenu.vue';
import { type ISuperMenuDefinitions } from '@/components/TmsSuperMenu.impl.js';
const ROOT_PAGE_PATH = '/settings' as const;
const INITIAL_PAGE_PATH = '/settings/profile' as const;
Expand Down Expand Up @@ -145,7 +145,7 @@ provideReactiveMetadata(pageMetadata);
definePageMetadata(() => pageMetadata.value);
//#region menuDef
const menuDef = computed<SuperMenuDef>(() => [{
const menuDef = computed<ISuperMenuDefinitions>(() => [{
title: i18n.ts.basicSettings,
items: [{
icon: 'ti ti-user',
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/tms/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const tmsStore = markRaw(new Storage('tmsMain', {
},
superMenuDisplayMode: {
where: 'deviceAccount',
default: 'default' as 'default' | 'classic' | 'forceList',
default: 'default' as import('@/components/TmsSuperMenu.impl.js').SuperMenuDisplayMode,
},
pullToRefreshSensitivity: {
where: 'device',
Expand Down
36 changes: 0 additions & 36 deletions packages/frontend/src/types/tms/super-menu.ts

This file was deleted.

0 comments on commit 924361e

Please sign in to comment.