167 lines
3.5 KiB
TypeScript
Raw Normal View History

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { defineAsyncComponent } from 'vue';
import type { MenuItem } from '@/types/menu.js';
2023-09-19 16:37:43 +09:00
import * as os from '@/os.js';
import { instance } from '@/instance.js';
import { host } from '@@/js/config.js';
2023-09-19 16:37:43 +09:00
import { i18n } from '@/i18n.js';
import { $i } from '@/account.js';
2022-12-28 13:29:42 +09:00
function toolsMenuItems(): MenuItem[] {
return [{
type: 'link',
to: '/scratchpad',
text: i18n.ts.scratchpad,
icon: 'ti ti-terminal-2',
}, {
type: 'link',
to: '/api-console',
text: 'API Console',
icon: 'ti ti-terminal-2',
}, {
type: 'link',
to: '/clicker',
text: '🍪👈',
icon: 'ti ti-cookie',
}, ($i && ($i.isAdmin || $i.policies.canManageCustomEmojis)) ? {
type: 'link',
to: '/custom-emojis-manager',
text: i18n.ts.manageCustomEmojis,
icon: 'ti ti-icons',
} : undefined, ($i && ($i.isAdmin || $i.policies.canManageAvatarDecorations)) ? {
type: 'link',
to: '/avatar-decorations',
text: i18n.ts.manageAvatarDecorations,
icon: 'ti ti-sparkles',
} : undefined];
}
2022-12-28 13:29:42 +09:00
export function openInstanceMenu(ev: MouseEvent) {
const menuItems: MenuItem[] = [];
menuItems.push({
2022-12-28 13:29:42 +09:00
text: instance.name ?? host,
type: 'label',
}, {
type: 'link',
text: i18n.ts.instanceInfo,
icon: 'ti ti-info-circle',
to: '/about',
}, {
type: 'link',
text: i18n.ts.customEmojis,
2022-12-31 20:36:49 +09:00
icon: 'ti ti-icons',
2022-12-28 13:29:42 +09:00
to: '/about#emojis',
}, {
type: 'link',
text: i18n.ts.federation,
icon: 'ti ti-whirl',
to: '/about#federation',
}, {
type: 'link',
text: i18n.ts.charts,
icon: 'ti ti-chart-line',
to: '/about#charts',
}, { type: 'divider' }, {
2023-03-18 14:30:16 +09:00
type: 'link',
text: i18n.ts.ads,
icon: 'ti ti-ad',
to: '/ads',
});
if ($i && ($i.isAdmin || $i.policies.canInvite) && instance.disableRegistration) {
menuItems.push({
type: 'link',
to: '/invite',
text: i18n.ts.invite,
icon: 'ti ti-user-plus',
});
}
menuItems.push({
2022-12-28 13:29:42 +09:00
type: 'parent',
2022-12-28 13:34:47 +09:00
text: i18n.ts.tools,
icon: 'ti ti-tool',
children: toolsMenuItems(),
2024-05-01 14:12:36 +09:00
}, { type: 'divider' }, {
type: 'link',
text: i18n.ts.inquiry,
icon: 'ti ti-help-circle',
to: '/contact',
});
if (instance.impressumUrl) {
menuItems.push({
type: 'a',
text: i18n.ts.impressum,
icon: 'ti ti-file-invoice',
href: instance.impressumUrl,
target: '_blank',
});
}
if (instance.tosUrl) {
menuItems.push({
type: 'a',
text: i18n.ts.termsOfService,
icon: 'ti ti-notebook',
href: instance.tosUrl,
target: '_blank',
});
}
if (instance.privacyPolicyUrl) {
menuItems.push({
type: 'a',
text: i18n.ts.privacyPolicy,
icon: 'ti ti-shield-lock',
href: instance.privacyPolicyUrl,
target: '_blank',
});
}
if (!instance.impressumUrl && !instance.tosUrl && !instance.privacyPolicyUrl) {
menuItems.push({ type: 'divider' });
}
menuItems.push({
type: 'a',
2024-05-01 14:12:36 +09:00
text: i18n.ts.document,
icon: 'ti ti-bulb',
href: 'https://misskey-hub.net/docs/for-users/',
target: '_blank',
});
if ($i) {
menuItems.push({
text: i18n.ts._initialTutorial.launchTutorial,
icon: 'ti ti-presentation',
action: () => {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkTutorialDialog.vue')), {}, {
closed: () => dispose(),
});
},
});
}
menuItems.push({
2022-12-28 13:29:42 +09:00
type: 'link',
text: i18n.ts.aboutMisskey,
to: '/about-misskey',
});
os.popupMenu(menuItems, ev.currentTarget ?? ev.target, {
2022-12-28 13:29:42 +09:00
align: 'left',
});
}
export function openToolsMenu(ev: MouseEvent) {
os.popupMenu(toolsMenuItems(), ev.currentTarget ?? ev.target, {
align: 'left',
});
}