fix preload

This commit is contained in:
ArjixWasTaken
2025-10-11 18:18:36 +03:00
parent 9b8daac28c
commit cbc6449621
4 changed files with 37 additions and 35 deletions

View File

@ -8,18 +8,18 @@ import is from 'electron-is';
import * as config from './config';
import mduiStyleSheet from '@assets/mdui.css?inline';
import {
forceLoadPreloadPlugin,
forceUnloadPreloadPlugin,
loadAllPreloadPlugins,
} from './loader/preload';
import { loadI18n, setLanguage } from '@/i18n';
contextBridge.exposeInMainWorld(
'litIssuedWarnings',
new Set([
'Lit is in dev mode. Not recommended for production! See https://lit.dev/msg/dev-mode for more information.',
'Shadow DOM is being polyfilled via `ShadyDOM` but the `polyfill-support` module has not been loaded. See https://lit.dev/msg/polyfill-support-missing for more information.',
]),
);
// @ts-expect-error dummy
globalThis.customElements = { define() {} };
new MutationObserver((mutations, observer) => {
outer: for (const mutation of mutations) {
for (const mutation of mutations) {
for (const node of mutation.addedNodes) {
const elem = node as HTMLElement;
if (elem.tagName !== 'SCRIPT') continue;
@ -32,23 +32,12 @@ new MutationObserver((mutations, observer) => {
script.remove();
const styleSheet = new CSSStyleSheet();
styleSheet.replaceSync(mduiStyleSheet);
document.adoptedStyleSheets.push(styleSheet);
observer.disconnect();
break outer;
return;
}
}
}).observe(document, { subtree: true, childList: true });
import {
forceLoadPreloadPlugin,
forceUnloadPreloadPlugin,
loadAllPreloadPlugins,
} from './loader/preload';
import { loadI18n, setLanguage } from '@/i18n';
loadI18n().then(async () => {
await setLanguage(config.get('options.language') ?? 'en');
await loadAllPreloadPlugins();