Feat: proxy
This commit is contained in:
+28
-2
@@ -21,9 +21,35 @@ const randomSplash = genSplash();
|
||||
</div>
|
||||
<div class="flex flex-row items-center gap-2 w-4/5 md:w-[26rem] border border-(--input) rounded-lg h-12 p-2">
|
||||
<Icon name="lucide:search" />
|
||||
<input type="text" name="Search" class="text-md md:text-sm focus-visible:outline-none w-full h-full placeholder:text-(--muted-foreground)" id="search" placeholder="Search the web">
|
||||
<input id="input" type="text" name="Search" class="text-md md:text-sm focus-visible:outline-none w-full h-full placeholder:text-(--muted-foreground)" id="search" placeholder="Search the web">
|
||||
</div>
|
||||
<p class="text-base"> { randomSplash } </p>
|
||||
<p class="text-sm text-center sm:text-base whitespace-nowrap"> { randomSplash } </p>
|
||||
</div>
|
||||
<iframe id="iframe" class="fixed h-[calc(100%-3.5rem)] mt-14 w-full hidden" src="https://example.com" />
|
||||
</div>
|
||||
</Layout>
|
||||
<script>
|
||||
import { SW } from "@utils/proxy.ts";
|
||||
import { Settings } from "@utils/settings.ts";
|
||||
|
||||
const init = async () => {
|
||||
const input = document.getElementById("input") as HTMLInputElement;
|
||||
const iframe = document.getElementById("iframe") as HTMLIFrameElement;
|
||||
input.addEventListener("keypress", async (event: any) => {
|
||||
if (event.key === "Enter") {
|
||||
const sw = SW.getInstance().next().value!;
|
||||
const settings = await Settings.getInstance();
|
||||
await sw.setTransport();
|
||||
iframe.classList.remove("hidden");
|
||||
iframe.src = sw.encodeURL(input.value, 'uv');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener("astro:page-load", async () => {
|
||||
try {
|
||||
await init();
|
||||
}
|
||||
catch (_) {}
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user