fix: getRoute within envoy
This commit is contained in:
parent
cf1add07cb
commit
287666e560
@ -1,23 +0,0 @@
|
||||
window.orbit.getRoute = (type, returnFirst = false) => {
|
||||
let availables = window.orbit.components.filter(c => c.type == type || c.uniq == type);
|
||||
window.orbit.components.forEach(c => {
|
||||
if (c.extensions) {
|
||||
c.extensions.forEach(e => {
|
||||
if (e.type == type || e.uniq == type) {
|
||||
availables.push(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (availables.length > 1) {
|
||||
if (returnFirst) {
|
||||
return availables[0].route;
|
||||
} else {
|
||||
return availables[availables.length - 1].route;
|
||||
}
|
||||
} else if (availables.length < 1) {
|
||||
console.error(`No component found for route ${type}`);
|
||||
} else {
|
||||
return availables[0].route;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import(`https://storage.googleapis.com/workbox-cdn/releases/6.1.1/workbox-window.prod.mjs`).then(workboxWindow => {
|
||||
import(`https://storage.googleapis.com/workbox-cdn/releases/6.1.5/workbox-window.prod.mjs`).then(workboxWindow => {
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', function () {
|
||||
|
||||
|
@ -196,5 +196,29 @@ for component of components
|
||||
defaultRoute = defaultComponent[0].uniq;
|
||||
}
|
||||
|
||||
- const orbitComponents = `window.orbit={};window.orbit.components = ${JSON.stringify(components)};window.orbit.federations = ${JSON.stringify(federations)};window.orbit.defaultRoute = "${defaultRoute}";window.orbit.client = ${JSON.stringify(client)};window.hubl = window.orbit;`;
|
||||
script!=orbitComponents
|
||||
- const orbitComponents = `window.orbit={};window.orbit.components = ${JSON.stringify(components)};window.orbit.federations = ${JSON.stringify(federations)};window.orbit.defaultRoute = "${defaultRoute}";window.orbit.client = ${JSON.stringify(client)};`;
|
||||
script!=orbitComponents
|
||||
| window.orbit.getRoute = (type, returnFirst = false) => {
|
||||
| let availables = window.orbit.components.filter(c => c.type == type || c.uniq == type);
|
||||
| window.orbit.components.forEach(c => {
|
||||
| if (c.extensions) {
|
||||
| c.extensions.forEach(e => {
|
||||
| if (e.type == type || e.uniq == type) {
|
||||
| availables.push(e);
|
||||
| }
|
||||
| });
|
||||
| }
|
||||
| });
|
||||
| if (availables.length > 1) {
|
||||
| if (returnFirst) {
|
||||
| return availables[0].route;
|
||||
| } else {
|
||||
| return availables[availables.length - 1].route;
|
||||
| }
|
||||
| } else if (availables.length < 1) {
|
||||
| console.error(`No component found for route ${type}`);
|
||||
| } else {
|
||||
| return availables[0].route;
|
||||
| }
|
||||
| }
|
||||
| window.hubl = window.orbit;
|
@ -36,7 +36,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
}
|
||||
});
|
||||
window.addEventListener("navigate", e => {
|
||||
if (e.detail.route == "login" && !window.requestLogin) {
|
||||
if (e.detail.route == "login" && !window.requestLogin && window.orbit.getRoute) {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('requestNavigation', {
|
||||
detail: {
|
||||
|
Loading…
Reference in New Issue
Block a user