Skip to content

Commit 924361e

Browse files
committed
refactor(TmsSuperMenu): 参照の構造とプレフィックスを変更
1 parent bed6e15 commit 924361e

File tree

6 files changed

+52
-50
lines changed

6 files changed

+52
-50
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* SPDX-FileCopyrightText: syuilo and misskey-project
3+
* SPDX-License-Identifier: AGPL-3.0-only
4+
*/
5+
6+
export type TmsSuperMenuProps = {
7+
readonly def: ISuperMenuDefinitions;
8+
readonly wideMode?: boolean;
9+
};
10+
11+
export type SuperMenuDisplayMode = 'default' | 'classic' | 'forceList';
12+
13+
export type ISuperMenuDefinitions = {
14+
readonly title?: string;
15+
readonly items: ISuperMenuItem[];
16+
}[];
17+
18+
type ISuperMenuItem = ISuperMenuItemButton | ISuperMenuItemA | ISuperMenuItemLink;
19+
20+
type ISuperMenuItemBase = {
21+
readonly icon: string;
22+
readonly text: string;
23+
readonly active?: boolean;
24+
readonly danger?: boolean;
25+
};
26+
27+
type ISuperMenuItemButton = ISuperMenuItemBase & {
28+
readonly type: 'button';
29+
readonly action: (ev: MouseEvent) => void;
30+
};
31+
32+
type ISuperMenuItemA = ISuperMenuItemBase & {
33+
readonly type: 'a';
34+
readonly href: string;
35+
readonly target: string;
36+
};
37+
38+
type ISuperMenuItemLink = ISuperMenuItemBase & {
39+
readonly type?: 'link';
40+
readonly to: string;
41+
};

packages/frontend/src/components/MkSuperMenu.vue renamed to packages/frontend/src/components/TmsSuperMenu.vue

+2-5
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,9 @@ SPDX-License-Identifier: AGPL-3.0-only
7272

7373
<script lang="ts" setup>
7474
import { tmsStore } from '@/tms/store.js';
75-
import { SuperMenuDef } from '@/types/tms/super-menu.js';
75+
import { type TmsSuperMenuProps } from '@/components/TmsSuperMenu.impl.js';
7676

77-
const props = defineProps<{
78-
def: SuperMenuDef;
79-
wideMode?: boolean;
80-
}>();
77+
const props = defineProps<TmsSuperMenuProps>();
8178
</script>
8279

8380
<style lang="scss" module>

packages/frontend/src/pages/admin/index.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ SPDX-License-Identifier: AGPL-3.0-only
2323
<MkInfo v-if="noEmailServer" warn>{{ i18n.ts.noEmailServerWarning }} <MkA to="/admin/email-settings" class="_link">{{ i18n.ts.configure }}</MkA></MkInfo>
2424
</div>
2525

26-
<MkSuperMenu :def="menuDef" :wideMode="isWide"></MkSuperMenu>
26+
<TmsSuperMenu :def="menuDef" :wideMode="isWide"></TmsSuperMenu>
2727
</div>
2828
</MkSpacer>
2929
</div>
@@ -48,9 +48,9 @@ import { lookup } from '@/scripts/lookup.js';
4848
import { misskeyApi } from '@/scripts/misskey-api.js';
4949
import { PageMetadata, definePageMetadata, provideMetadataReceiver, provideReactiveMetadata } from '@/scripts/page-metadata.js';
5050
import { useRouter } from '@/router/supplier.js';
51-
import { SuperMenuDef } from '@/types/tms/super-menu.js';
5251
import MkInfo from '@/components/MkInfo.vue';
53-
import MkSuperMenu from '@/components/MkSuperMenu.vue';
52+
import TmsSuperMenu from '@/components/TmsSuperMenu.vue';
53+
import { type ISuperMenuDefinitions } from '@/components/TmsSuperMenu.impl.js';
5454

5555
const ROOT_PAGE_PATH = '/admin' as const;
5656
const INITIAL_PAGE_PATH = '/admin/overview' as const;
@@ -168,7 +168,7 @@ provideReactiveMetadata(pageMetadata);
168168
definePageMetadata(() => pageMetadata.value);
169169

170170
//#region menuDef
171-
const menuDef = computed<SuperMenuDef>(() => [{
171+
const menuDef = computed<ISuperMenuDefinitions>(() => [{
172172
title: i18n.ts.quickAction,
173173
items: [{
174174
type: 'button' as const,

packages/frontend/src/pages/settings/index.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ SPDX-License-Identifier: AGPL-3.0-only
1515
<MkInfo v-if="emailNotConfigured" warn>{{ i18n.ts.emailNotConfiguredWarning }} <MkA to="/settings/email" class="_link">{{ i18n.ts.configure }}</MkA></MkInfo>
1616
</div>
1717

18-
<MkSuperMenu :def="menuDef" :wideMode="isWide"></MkSuperMenu>
18+
<TmsSuperMenu :def="menuDef" :wideMode="isWide"></TmsSuperMenu>
1919
</div>
2020
</MkSpacer>
2121
</div>
@@ -39,9 +39,9 @@ import * as os from '@/os.js';
3939
import { clearCache } from '@/scripts/clear-cache.js';
4040
import { PageMetadata, definePageMetadata, provideMetadataReceiver, provideReactiveMetadata } from '@/scripts/page-metadata.js';
4141
import { useRouter } from '@/router/supplier.js';
42-
import { SuperMenuDef } from '@/types/tms/super-menu.js';
4342
import MkInfo from '@/components/MkInfo.vue';
44-
import MkSuperMenu from '@/components/MkSuperMenu.vue';
43+
import TmsSuperMenu from '@/components/TmsSuperMenu.vue';
44+
import { type ISuperMenuDefinitions } from '@/components/TmsSuperMenu.impl.js';
4545

4646
const ROOT_PAGE_PATH = '/settings' as const;
4747
const INITIAL_PAGE_PATH = '/settings/profile' as const;
@@ -145,7 +145,7 @@ provideReactiveMetadata(pageMetadata);
145145
definePageMetadata(() => pageMetadata.value);
146146

147147
//#region menuDef
148-
const menuDef = computed<SuperMenuDef>(() => [{
148+
const menuDef = computed<ISuperMenuDefinitions>(() => [{
149149
title: i18n.ts.basicSettings,
150150
items: [{
151151
icon: 'ti ti-user',

packages/frontend/src/tms/store.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const tmsStore = markRaw(new Storage('tmsMain', {
1616
},
1717
superMenuDisplayMode: {
1818
where: 'deviceAccount',
19-
default: 'default' as 'default' | 'classic' | 'forceList',
19+
default: 'default' as import('@/components/TmsSuperMenu.impl.js').SuperMenuDisplayMode,
2020
},
2121
pullToRefreshSensitivity: {
2222
where: 'device',

packages/frontend/src/types/tms/super-menu.ts

-36
This file was deleted.

0 commit comments

Comments
 (0)