2023-07-27 14:31:52 +09:00
|
|
|
/*
|
2024-02-13 15:59:27 +00:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 14:31:52 +09:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-11-03 15:35:07 +09:00
|
|
|
import { defineAsyncComponent } from 'vue';
|
2023-10-31 17:28:13 +09:00
|
|
|
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 '@/config.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { $i } from '@/account.js';
|
2022-12-28 13:29:42 +09:00
|
|
|
|
2023-10-31 17:28:13 +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) {
|
|
|
|
os.popupMenu([{
|
|
|
|
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',
|
2023-12-12 10:26:37 +09:00
|
|
|
}, { type: 'divider' }, {
|
2023-03-18 14:30:16 +09:00
|
|
|
type: 'link',
|
|
|
|
text: i18n.ts.ads,
|
|
|
|
icon: 'ti ti-ad',
|
|
|
|
to: '/ads',
|
2023-07-15 09:57:58 +09:00
|
|
|
}, ($i && ($i.isAdmin || $i.policies.canInvite) && instance.disableRegistration) ? {
|
|
|
|
type: 'link',
|
|
|
|
to: '/invite',
|
|
|
|
text: i18n.ts.invite,
|
|
|
|
icon: 'ti ti-user-plus',
|
|
|
|
} : undefined, {
|
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',
|
2023-10-31 17:28:13 +09:00
|
|
|
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',
|
|
|
|
}, (instance.impressumUrl) ? {
|
2023-10-07 13:13:13 +09:00
|
|
|
text: i18n.ts.impressum,
|
|
|
|
icon: 'ti ti-file-invoice',
|
|
|
|
action: () => {
|
2023-12-08 17:48:18 +09:00
|
|
|
window.open(instance.impressumUrl, '_blank', 'noopener');
|
2023-10-07 13:13:13 +09:00
|
|
|
},
|
|
|
|
} : undefined, (instance.tosUrl) ? {
|
|
|
|
text: i18n.ts.termsOfService,
|
|
|
|
icon: 'ti ti-notebook',
|
|
|
|
action: () => {
|
2023-12-08 17:48:18 +09:00
|
|
|
window.open(instance.tosUrl, '_blank', 'noopener');
|
2023-10-07 13:13:13 +09:00
|
|
|
},
|
|
|
|
} : undefined, (instance.privacyPolicyUrl) ? {
|
|
|
|
text: i18n.ts.privacyPolicy,
|
|
|
|
icon: 'ti ti-shield-lock',
|
|
|
|
action: () => {
|
2023-12-08 17:48:18 +09:00
|
|
|
window.open(instance.privacyPolicyUrl, '_blank', 'noopener');
|
2023-10-07 13:13:13 +09:00
|
|
|
},
|
2023-12-12 10:26:37 +09:00
|
|
|
} : undefined, (!instance.impressumUrl && !instance.tosUrl && !instance.privacyPolicyUrl) ? undefined : { type: 'divider' }, {
|
2024-05-01 14:12:36 +09:00
|
|
|
text: i18n.ts.document,
|
|
|
|
icon: 'ti ti-bulb',
|
2023-01-09 13:39:16 +09:00
|
|
|
action: () => {
|
2023-12-22 20:16:31 +09:00
|
|
|
window.open('https://misskey-hub.net/docs/for-users/', '_blank', 'noopener');
|
2023-01-09 13:39:16 +09:00
|
|
|
},
|
2023-11-03 15:35:07 +09:00
|
|
|
}, ($i) ? {
|
|
|
|
text: i18n.ts._initialTutorial.launchTutorial,
|
|
|
|
icon: 'ti ti-presentation',
|
|
|
|
action: () => {
|
2024-07-04 13:14:49 +09:00
|
|
|
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkTutorialDialog.vue')), {}, {
|
|
|
|
closed: () => dispose(),
|
|
|
|
});
|
2023-11-03 15:35:07 +09:00
|
|
|
},
|
|
|
|
} : undefined, {
|
2022-12-28 13:29:42 +09:00
|
|
|
type: 'link',
|
|
|
|
text: i18n.ts.aboutMisskey,
|
|
|
|
to: '/about-misskey',
|
|
|
|
}], ev.currentTarget ?? ev.target, {
|
|
|
|
align: 'left',
|
|
|
|
});
|
|
|
|
}
|
2023-10-31 17:28:13 +09:00
|
|
|
|
|
|
|
export function openToolsMenu(ev: MouseEvent) {
|
|
|
|
os.popupMenu(toolsMenuItems(), ev.currentTarget ?? ev.target, {
|
|
|
|
align: 'left',
|
|
|
|
});
|
|
|
|
}
|