🦋 Adds location for socket connection
This commit is contained in:
+5
-5
@@ -6,13 +6,13 @@
|
|||||||
import Controller from './routes/Controller.svelte';
|
import Controller from './routes/Controller.svelte';
|
||||||
import Config from './routes/Config.svelte';
|
import Config from './routes/Config.svelte';
|
||||||
import Health from './routes/SystemHealth.svelte';
|
import Health from './routes/SystemHealth.svelte';
|
||||||
import location from './lib/location';
|
|
||||||
import Sidebar from './components/Sidebar.svelte';
|
import Sidebar from './components/Sidebar.svelte';
|
||||||
import FileCache from './lib/cache';
|
import FileCache from './lib/cache';
|
||||||
|
import { socketLocation } from './lib/location';
|
||||||
|
|
||||||
export let url = window.location.pathname;
|
export let url = window.location.pathname
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
connect(`ws://${location}`);
|
connect(socketLocation);
|
||||||
registerFetchIntercept()
|
registerFetchIntercept()
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -21,9 +21,9 @@
|
|||||||
window.fetch = async (...args) => {
|
window.fetch = async (...args) => {
|
||||||
const [resource, config] = args;
|
const [resource, config] = args;
|
||||||
await FileCache.openDatabase();
|
await FileCache.openDatabase();
|
||||||
let file;
|
let file: BodyInit | Uint8Array | undefined | null;
|
||||||
try {
|
try {
|
||||||
file = await FileCache.getFile(resource.url);
|
file = await FileCache.getFile(resource.toString());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
const location = import.meta.env.DEV ? "leika.local" : window.location.host
|
const forWeb = import.meta.env.MODE === "WEB"
|
||||||
|
const mock = import.meta.env.MODE === "MOCK"
|
||||||
|
|
||||||
|
const location = mock ? `${window.location.hostname}:2096` : "leika.local"
|
||||||
|
|
||||||
|
export const socketLocation = forWeb ? `wss://${window.location.hostname}:2096` : `ws://${location}`
|
||||||
|
|
||||||
export default location;
|
export default location;
|
||||||
Reference in New Issue
Block a user