proxy switcher + change wisp settings to proxy settings

This commit is contained in:
Nebelung 2024-10-14 23:00:56 +00:00
parent 6c65689b1a
commit 3c127ad2af
6 changed files with 52 additions and 18 deletions

View file

@ -5,7 +5,7 @@ const nextConfig = {
return [
{
source: '/settings',
destination: '/settings/appearance',
destination: '/settings/proxy',
permanent: false
}
]

6
pnpm-lock.yaml generated
View file

@ -3402,7 +3402,7 @@ snapshots:
agent-base@6.0.2:
dependencies:
debug: 4.3.1
debug: 4.3.7
transitivePeerDependencies:
- supports-color
optional: true
@ -4076,7 +4076,7 @@ snapshots:
dependencies:
'@tootallnate/once': 1.1.2
agent-base: 6.0.2
debug: 4.3.1
debug: 4.3.7
transitivePeerDependencies:
- supports-color
optional: true
@ -4084,7 +4084,7 @@ snapshots:
https-proxy-agent@5.0.1:
dependencies:
agent-base: 6.0.2
debug: 4.3.1
debug: 4.3.7
transitivePeerDependencies:
- supports-color
optional: true

View file

@ -37,6 +37,7 @@ export default function Route({ params }: { params: { route: string[] } }) {
ref.current.src = await window.chemical.encode(
atob(decodeURIComponent(route)),
{
service: window.chemical.getStore("service"),
autoHttps: true,
searchEngine: "https://www.google.com/search?q=%s",
}

View file

@ -20,7 +20,7 @@ export default function RootLayout({
<html lang="en">
<head>
<link rel="icon" href="/icon.png" />
<script data-wisp-store src="/chemical.js"></script>
<script data-wisp-store data-transport-store src="/chemical.js"></script>
</head>
<body className={inter.className}>
<Themes>

View file

@ -1,7 +1,7 @@
"use client";
import { Button } from "@/components/ui/button";
import { Users, Link, Palette, ArrowRightLeft } from "lucide-react";
import { Users, Link, Palette, LockIcon } from "lucide-react";
import NextLink from "next/link";
import { usePathname } from "next/navigation";
@ -13,6 +13,16 @@ export default function SettingsLayout({
return (
<div className="flex">
<div className="flex w-1/4 flex-col gap-2 p-4 pl-8 pt-8">
<NextLink href="/settings/proxy/">
<Button
variant={
pathname?.includes("/settings/proxy/") ? "secondary" : "ghost"
}
className="w-full items-center justify-start gap-2"
>
<LockIcon className="h-5 w-5" /> Proxy
</Button>
</NextLink>
<NextLink href="/settings/appearance/">
<Button
variant={
@ -23,16 +33,6 @@ export default function SettingsLayout({
<Palette className="h-5 w-5" /> Appearance
</Button>
</NextLink>
<NextLink href="/settings/wisp/">
<Button
variant={
pathname?.includes("/settings/wisp/") ? "secondary" : "ghost"
}
className="w-full items-center justify-start gap-2"
>
<ArrowRightLeft className="h-5 w-5" /> Wisp
</Button>
</NextLink>
<NextLink href="/settings/credits/">
<Button
variant={

View file

@ -19,13 +19,21 @@ import { Separator } from "@/components/ui/separator";
import { Save, RotateCcw } from "lucide-react";
import { useEffect, useState } from "react";
import { toast } from "sonner";
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
const formSchema = z.object({
wispServer: z.string().url("Please provide a valid URL"),
description: z.string().optional(),
});
export default function WispSwitcher() {
export default function ProxyOptions() {
const [submitting, setSubmitting] = useState(false);
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
@ -61,11 +69,36 @@ export default function WispSwitcher() {
toast("Settings reset");
}
const [proxy, setProxy] = useState("");
useEffect(() => {
setProxy(window.chemical.getStore("service"));
}, []);
const proxyChanged = (service: string) => {
setProxy(service);
window.chemical.setStore("service", service);
};
return (
<div>
<h1 className="text-4xl font-semibold">Wisp</h1>
<h1 className="text-4xl font-semibold">Proxy</h1>
<Separator />
<div className="mt-4">
<p>Proxy Switcher</p>
<Select value={proxy} onValueChange={proxyChanged}>
<SelectTrigger className="w-[180px]">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectItem value="uv">Ultraviolet</SelectItem>
<SelectItem value="rammerhead">Rammerhead</SelectItem>
<SelectItem value="scramjet">Scramjet (old broken version)</SelectItem>
<SelectItem value="meteor">Meteor</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}