refactor(frontend): popupMenuの項目作成時に三項演算子をなるべく使わないように (#14554)
* refactor(frontend): popupMenuの項目作成時に三項演算子をなるべく使わないように * type import * fix * lint
This commit is contained in:
@@ -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;
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user