2021-12-03 13:09:40 +00:00
|
|
|
import { computed, ref, reactive } from 'vue';
|
2021-11-11 17:02:25 +00:00
|
|
|
import { search } from '@/scripts/search';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import { ui } from '@/config';
|
2020-12-19 01:55:52 +00:00
|
|
|
import { $i } from './account';
|
2021-11-11 17:02:25 +00:00
|
|
|
import { unisonReload } from '@/scripts/unison-reload';
|
2021-09-21 12:04:59 +00:00
|
|
|
import { router } from './router';
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2021-12-03 13:09:40 +00:00
|
|
|
export const menuDef = reactive({
|
2020-10-17 11:12:00 +00:00
|
|
|
notifications: {
|
|
|
|
title: 'notifications',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-bell',
|
2020-12-19 01:55:52 +00:00
|
|
|
show: computed(() => $i != null),
|
|
|
|
indicated: computed(() => $i != null && $i.hasUnreadNotification),
|
2020-10-17 11:12:00 +00:00
|
|
|
to: '/my/notifications',
|
|
|
|
},
|
|
|
|
messaging: {
|
|
|
|
title: 'messaging',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-comments',
|
2020-12-19 01:55:52 +00:00
|
|
|
show: computed(() => $i != null),
|
|
|
|
indicated: computed(() => $i != null && $i.hasUnreadMessagingMessage),
|
2020-11-03 01:43:50 +00:00
|
|
|
to: '/my/messaging',
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
drive: {
|
|
|
|
title: 'drive',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-cloud',
|
2020-12-19 01:55:52 +00:00
|
|
|
show: computed(() => $i != null),
|
2020-10-17 11:12:00 +00:00
|
|
|
to: '/my/drive',
|
|
|
|
},
|
|
|
|
followRequests: {
|
|
|
|
title: 'followRequests',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-user-clock',
|
2020-12-19 01:55:52 +00:00
|
|
|
show: computed(() => $i != null && $i.isLocked),
|
|
|
|
indicated: computed(() => $i != null && $i.hasPendingReceivedFollowRequest),
|
2020-10-17 11:12:00 +00:00
|
|
|
to: '/my/follow-requests',
|
|
|
|
},
|
|
|
|
featured: {
|
|
|
|
title: 'featured',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-fire-alt',
|
2020-10-17 11:12:00 +00:00
|
|
|
to: '/featured',
|
|
|
|
},
|
|
|
|
explore: {
|
|
|
|
title: 'explore',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-hashtag',
|
2020-10-17 11:12:00 +00:00
|
|
|
to: '/explore',
|
|
|
|
},
|
|
|
|
announcements: {
|
|
|
|
title: 'announcements',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-broadcast-tower',
|
2020-12-19 01:55:52 +00:00
|
|
|
indicated: computed(() => $i != null && $i.hasUnreadAnnouncement),
|
2020-10-17 11:12:00 +00:00
|
|
|
to: '/announcements',
|
|
|
|
},
|
|
|
|
search: {
|
|
|
|
title: 'search',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-search',
|
2020-10-17 11:12:00 +00:00
|
|
|
action: () => search(),
|
|
|
|
},
|
|
|
|
lists: {
|
|
|
|
title: 'lists',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-list-ul',
|
2020-12-19 01:55:52 +00:00
|
|
|
show: computed(() => $i != null),
|
2021-09-21 12:04:59 +00:00
|
|
|
active: computed(() => router.currentRoute.value.path.startsWith('/timeline/list/') || router.currentRoute.value.path === '/my/lists' || router.currentRoute.value.path.startsWith('/my/lists/')),
|
|
|
|
action: (ev) => {
|
|
|
|
const items = ref([{
|
|
|
|
type: 'pending'
|
|
|
|
}]);
|
|
|
|
os.api('users/lists/list').then(lists => {
|
|
|
|
const _items = [...lists.map(list => ({
|
|
|
|
type: 'link',
|
|
|
|
text: list.name,
|
|
|
|
to: `/timeline/list/${list.id}`
|
|
|
|
})), null, {
|
|
|
|
type: 'link',
|
|
|
|
to: '/my/lists',
|
|
|
|
text: i18n.locale.manageLists,
|
|
|
|
icon: 'fas fa-cog',
|
|
|
|
}];
|
|
|
|
items.value = _items;
|
|
|
|
});
|
|
|
|
os.popupMenu(items, ev.currentTarget || ev.target);
|
|
|
|
},
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
groups: {
|
|
|
|
title: 'groups',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-users',
|
2020-12-19 01:55:52 +00:00
|
|
|
show: computed(() => $i != null),
|
2020-10-17 11:12:00 +00:00
|
|
|
to: '/my/groups',
|
|
|
|
},
|
|
|
|
antennas: {
|
|
|
|
title: 'antennas',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-satellite',
|
2020-12-19 01:55:52 +00:00
|
|
|
show: computed(() => $i != null),
|
2021-09-22 12:42:07 +00:00
|
|
|
active: computed(() => router.currentRoute.value.path.startsWith('/timeline/antenna/') || router.currentRoute.value.path === '/my/antennas' || router.currentRoute.value.path.startsWith('/my/antennas/')),
|
|
|
|
action: (ev) => {
|
|
|
|
const items = ref([{
|
|
|
|
type: 'pending'
|
|
|
|
}]);
|
|
|
|
os.api('antennas/list').then(antennas => {
|
|
|
|
const _items = [...antennas.map(antenna => ({
|
|
|
|
type: 'link',
|
|
|
|
text: antenna.name,
|
|
|
|
to: `/timeline/antenna/${antenna.id}`
|
|
|
|
})), null, {
|
|
|
|
type: 'link',
|
|
|
|
to: '/my/antennas',
|
|
|
|
text: i18n.locale.manageAntennas,
|
|
|
|
icon: 'fas fa-cog',
|
|
|
|
}];
|
|
|
|
items.value = _items;
|
|
|
|
});
|
|
|
|
os.popupMenu(items, ev.currentTarget || ev.target);
|
|
|
|
},
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
mentions: {
|
|
|
|
title: 'mentions',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-at',
|
2020-12-19 01:55:52 +00:00
|
|
|
show: computed(() => $i != null),
|
|
|
|
indicated: computed(() => $i != null && $i.hasUnreadMentions),
|
2020-10-17 11:12:00 +00:00
|
|
|
to: '/my/mentions',
|
|
|
|
},
|
|
|
|
messages: {
|
|
|
|
title: 'directNotes',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-envelope',
|
2020-12-19 01:55:52 +00:00
|
|
|
show: computed(() => $i != null),
|
|
|
|
indicated: computed(() => $i != null && $i.hasUnreadSpecifiedNotes),
|
2020-10-17 11:12:00 +00:00
|
|
|
to: '/my/messages',
|
|
|
|
},
|
|
|
|
favorites: {
|
|
|
|
title: 'favorites',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-star',
|
2020-12-19 01:55:52 +00:00
|
|
|
show: computed(() => $i != null),
|
2020-10-17 11:12:00 +00:00
|
|
|
to: '/my/favorites',
|
|
|
|
},
|
|
|
|
pages: {
|
|
|
|
title: 'pages',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-file-alt',
|
2020-11-17 05:59:15 +00:00
|
|
|
to: '/pages',
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
2021-04-24 13:38:24 +00:00
|
|
|
gallery: {
|
|
|
|
title: 'gallery',
|
|
|
|
icon: 'fas fa-icons',
|
|
|
|
to: '/gallery',
|
|
|
|
},
|
2020-11-15 03:04:54 +00:00
|
|
|
clips: {
|
|
|
|
title: 'clip',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-paperclip',
|
2020-12-19 01:55:52 +00:00
|
|
|
show: computed(() => $i != null),
|
2020-11-15 03:04:54 +00:00
|
|
|
to: '/my/clips',
|
|
|
|
},
|
2020-10-17 11:12:00 +00:00
|
|
|
channels: {
|
|
|
|
title: 'channel',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-satellite-dish',
|
2020-10-17 11:12:00 +00:00
|
|
|
to: '/channels',
|
|
|
|
},
|
2021-08-07 01:24:50 +00:00
|
|
|
federation: {
|
|
|
|
title: 'federation',
|
|
|
|
icon: 'fas fa-globe',
|
|
|
|
to: '/federation',
|
|
|
|
},
|
2021-08-07 01:23:59 +00:00
|
|
|
emojis: {
|
|
|
|
title: 'emojis',
|
|
|
|
icon: 'fas fa-laugh',
|
|
|
|
to: '/emojis',
|
|
|
|
},
|
2020-10-17 11:12:00 +00:00
|
|
|
games: {
|
|
|
|
title: 'games',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-gamepad',
|
2020-10-27 09:11:41 +00:00
|
|
|
to: '/games/reversi',
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
scratchpad: {
|
|
|
|
title: 'scratchpad',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-terminal',
|
2020-10-17 11:12:00 +00:00
|
|
|
to: '/scratchpad',
|
|
|
|
},
|
2020-11-03 08:00:47 +00:00
|
|
|
ui: {
|
|
|
|
title: 'switchUi',
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-columns',
|
2020-11-03 08:00:47 +00:00
|
|
|
action: (ev) => {
|
2021-08-08 03:19:10 +00:00
|
|
|
os.popupMenu([{
|
2020-12-26 01:51:00 +00:00
|
|
|
text: i18n.locale.default,
|
2021-10-24 05:50:00 +00:00
|
|
|
active: ui === 'default' || ui === null,
|
2020-11-03 08:00:47 +00:00
|
|
|
action: () => {
|
|
|
|
localStorage.setItem('ui', 'default');
|
2021-02-17 12:36:56 +00:00
|
|
|
unisonReload();
|
2020-11-03 08:00:47 +00:00
|
|
|
}
|
|
|
|
}, {
|
2020-12-26 01:51:00 +00:00
|
|
|
text: i18n.locale.deck,
|
2021-10-24 05:50:00 +00:00
|
|
|
active: ui === 'deck',
|
2020-11-03 08:00:47 +00:00
|
|
|
action: () => {
|
|
|
|
localStorage.setItem('ui', 'deck');
|
2021-02-17 12:36:56 +00:00
|
|
|
unisonReload();
|
2020-11-03 08:00:47 +00:00
|
|
|
}
|
2021-04-10 03:40:50 +00:00
|
|
|
}, {
|
2021-10-24 05:50:00 +00:00
|
|
|
text: i18n.locale.classic,
|
|
|
|
active: ui === 'classic',
|
2021-04-10 03:40:50 +00:00
|
|
|
action: () => {
|
2021-10-24 05:50:00 +00:00
|
|
|
localStorage.setItem('ui', 'classic');
|
2021-04-10 03:40:50 +00:00
|
|
|
unisonReload();
|
|
|
|
}
|
2021-10-24 05:50:00 +00:00
|
|
|
}, /*{
|
2020-12-26 01:51:00 +00:00
|
|
|
text: i18n.locale.desktop + ' (β)',
|
2021-10-24 05:50:00 +00:00
|
|
|
active: ui === 'desktop',
|
2020-11-03 08:00:47 +00:00
|
|
|
action: () => {
|
|
|
|
localStorage.setItem('ui', 'desktop');
|
2021-02-17 12:36:56 +00:00
|
|
|
unisonReload();
|
2020-11-03 08:00:47 +00:00
|
|
|
}
|
2021-10-24 05:50:00 +00:00
|
|
|
}*/], ev.currentTarget || ev.target);
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
},
|
2021-12-03 13:09:40 +00:00
|
|
|
});
|