refactor(frontend): popupMenuの項目作成時に三項演算子をなるべく使わないように (#14554)

* refactor(frontend): popupMenuの項目作成時に三項演算子をなるべく使わないように

* type import

* fix

* lint
This commit is contained in:
かっこかり
2024-09-23 21:50:30 +09:00
committed by GitHub
parent e673c143a9
commit 0c6d1ec524
36 changed files with 851 additions and 614 deletions

View File

@@ -40,6 +40,7 @@ import MkContainer from '@/components/MkContainer.vue';
import MkTimeline from '@/components/MkTimeline.vue';
import { i18n } from '@/i18n.js';
import { availableBasicTimelines, isAvailableBasicTimeline, isBasicTimeline, basicTimelineIconClass } from '@/timelines.js';
import type { MenuItem } from '@/types/menu.js';
const name = 'timeline';
@@ -109,11 +110,26 @@ const choose = async (ev) => {
setSrc('list');
},
}));
os.popupMenu([...availableBasicTimelines().map(tl => ({
const menuItems: MenuItem[] = [];
menuItems.push(...availableBasicTimelines().map(tl => ({
text: i18n.ts._timelines[tl],
icon: basicTimelineIconClass(tl),
action: () => { setSrc(tl); },
})), antennaItems.length > 0 ? { type: 'divider' } : undefined, ...antennaItems, listItems.length > 0 ? { type: 'divider' } : undefined, ...listItems], ev.currentTarget ?? ev.target).then(() => {
})));
if (antennaItems.length > 0) {
menuItems.push({ type: 'divider' });
menuItems.push(...antennaItems);
}
if (listItems.length > 0) {
menuItems.push({ type: 'divider' });
menuItems.push(...listItems);
}
os.popupMenu(menuItems, ev.currentTarget ?? ev.target).then(() => {
menuOpened.value = false;
});
};