mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: add provideFeature/getFeature API
This commit is contained in:
5 files changed
+34
-21
No files matched your search
@@ -77,21 +77,6 @@ export function mongoId(idstring: string) {
|
||||
};
|
||||
}
|
||||
|
||||
const loaded = {};
|
||||
|
||||
export async function loadExternalModule(target: string) {
|
||||
if (loaded[target]) return loaded[target];
|
||||
const ele = document.createElement('script');
|
||||
ele.src = target;
|
||||
await new Promise((resolve, reject) => {
|
||||
ele.onload = resolve;
|
||||
ele.onerror = reject;
|
||||
document.head.appendChild(ele);
|
||||
});
|
||||
loaded[target] = window.exports;
|
||||
return loaded[target];
|
||||
}
|
||||
|
||||
export function emulateAnchorClick(ev: KeyboardEvent, targetUrl: string, alwaysOpenInNewWindow = false) {
|
||||
let openInNewWindow;
|
||||
if (alwaysOpenInNewWindow) openInNewWindow = true;
|
||||
@@ -112,6 +97,5 @@ Object.assign(window.Hydro.utils, {
|
||||
zip,
|
||||
pipeStream,
|
||||
mongoId,
|
||||
loadExternalModule,
|
||||
emulateAnchorClick,
|
||||
});
|
||||
Reference in new issue
Block a user