mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-16 15:40:01 -04:00
add url bar and fix corium invocation for single-file mode
This commit is contained in:
parent
a5840d54dc
commit
099b191981
3 changed files with 54 additions and 21 deletions
|
@ -1,14 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
<head>
|
||||
<title></title>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<script type="module" src="src/entry.ts"></script>
|
||||
</head>
|
||||
<script src="uv/uv.bundle.js"></script>
|
||||
<script src="uv.config.js"></script>
|
||||
|
||||
<body>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -16,7 +16,7 @@
|
|||
import { getDatabase, onValue, ref, set } from "firebase/database";
|
||||
import type { Transport } from "protocol";
|
||||
|
||||
import { openWindow } from "../../corium";
|
||||
import { Win, openWindow } from "../../corium";
|
||||
|
||||
let transport: Transport;
|
||||
|
||||
|
@ -124,17 +124,32 @@
|
|||
);
|
||||
}
|
||||
|
||||
function visitURL() {
|
||||
function visitURL(url: string) {
|
||||
if (!import.meta.env.VITE_ADRIFT_SINGLEFILE) {
|
||||
alert("TODO");
|
||||
let path = `${__uv$config.prefix}${__uv$config.encodeUrl(url)}`;
|
||||
proxyIframe.src = path;
|
||||
} else {
|
||||
let bare = new BareClient();
|
||||
openWindow(new Request(url), "_self", bare, "replace");
|
||||
openWindow(
|
||||
new Request(url),
|
||||
"_self",
|
||||
proxyIframe.contentWindow! as unknown as Win,
|
||||
bare,
|
||||
"replace"
|
||||
);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if !import.meta.env.VITE_ADRIFT_DEV}
|
||||
{#if ready}
|
||||
<div class="container h-full w-full">
|
||||
<div class="container">
|
||||
<input bind:value={url} type="text" />
|
||||
<button on:click={() => visitURL(url)}>Go!</button>
|
||||
</div>
|
||||
<iframe class="h-full w-full" bind:this={proxyIframe} />
|
||||
</div>
|
||||
{:else if !import.meta.env.VITE_ADRIFT_DEV}
|
||||
<div class="container">
|
||||
<label for="email">email</label>
|
||||
<input name="email" type="text" bind:value={email} />
|
||||
|
@ -149,16 +164,26 @@
|
|||
<button on:click={connectDevWS}>Connect with dev websocket</button>
|
||||
{/if}
|
||||
|
||||
{#if ready}
|
||||
<input bind:value={url} type="text" />
|
||||
<button on:click={visitURL}>Go!</button>
|
||||
<iframe bind:this={proxyIframe} />
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
:global(body, html, #app) {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
iframe {
|
||||
outline: none;
|
||||
border: none;
|
||||
}
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: max-content;
|
||||
}
|
||||
.h-full {
|
||||
height: 100%;
|
||||
}
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
|
3
frontend/src/env.d.ts
vendored
3
frontend/src/env.d.ts
vendored
|
@ -7,3 +7,6 @@ interface ImportMetaEnv {
|
|||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
|
||||
declare const Ultraviolet: any;
|
||||
declare const __uv$config: any;
|
Loading…
Add table
Add a link
Reference in a new issue