You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
export function getMenuItems(moduleData) {
|
|
|
|
const menuMeta = moduleData.map(item => item.meta);
|
|
|
|
const menuItems = {};
|
|
|
|
menuMeta.sort(
|
|
|
|
(a, b) => (a.order || 0) - (b.order || 0)
|
|
|
|
).forEach((meta) => {
|
|
|
|
const category = meta.category || 'topLevel';
|
|
|
|
if (!menuItems[category]) {
|
|
|
|
menuItems[category] = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
const type = meta.type || 'topLevel';
|
|
|
|
if (!menuItems[category][type]) {
|
|
|
|
menuItems[category][type] = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
menuItems[category][type].push(meta);
|
|
|
|
});
|
|
|
|
return menuItems;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function ping(url, callback) {
|
|
|
|
const img = new Image();
|
|
|
|
let done;
|
|
|
|
const finish = (status) => {
|
|
|
|
if (!done) {
|
|
|
|
done = true;
|
|
|
|
img.src = '';
|
|
|
|
callback(status);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
img.onload = () => finish('responded');
|
|
|
|
img.onerror = () => finish('error');
|
|
|
|
img.src = url;
|
|
|
|
return setTimeout(() => finish('timeout'), 1500);
|
|
|
|
}
|