feat: redirect page
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
"@electron-toolkit/utils": "^3.0.0",
|
||||
"@fontsource/sn-pro": "5.0.1",
|
||||
"@hono/auth-js": "1.0.4",
|
||||
"@radix-ui/react-avatar": "1.0.4",
|
||||
"@radix-ui/react-collapsible": "1.0.3",
|
||||
"@radix-ui/react-slot": "1.0.2",
|
||||
"@radix-ui/react-tabs": "1.0.4",
|
||||
|
||||
Generated
+29
@@ -20,6 +20,9 @@ importers:
|
||||
'@hono/auth-js':
|
||||
specifier: 1.0.4
|
||||
version: 1.0.4(@auth/core@0.30.0)(hono@4.2.7)(react@18.3.0)
|
||||
'@radix-ui/react-avatar':
|
||||
specifier: 1.0.4
|
||||
version: 1.0.4(@types/react-dom@18.3.0)(@types/react@18.3.0)(react-dom@18.3.0(react@18.3.0))(react@18.3.0)
|
||||
'@radix-ui/react-collapsible':
|
||||
specifier: 1.0.3
|
||||
version: 1.0.3(@types/react-dom@18.3.0)(@types/react@18.3.0)(react-dom@18.3.0(react@18.3.0))(react@18.3.0)
|
||||
@@ -813,6 +816,19 @@ packages:
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-avatar@1.0.4':
|
||||
resolution: {integrity: sha512-kVK2K7ZD3wwj3qhle0ElXhOjbezIgyl2hVvgwfIdexL3rN6zJmy5AqqIf+D31lxVppdzV8CjAfZ6PklkmInZLw==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
'@types/react-dom': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0
|
||||
react-dom: ^16.8 || ^17.0 || ^18.0
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-collapsible@1.0.3':
|
||||
resolution: {integrity: sha512-UBmVDkmR6IvDsloHVN+3rtx4Mi5TFvylYXpluuv0f37dtaz3H99bp8No0LGXRigVpl3UAT4l9j6bIchh42S/Gg==}
|
||||
peerDependencies:
|
||||
@@ -4628,6 +4644,19 @@ snapshots:
|
||||
'@types/react': 18.3.0
|
||||
'@types/react-dom': 18.3.0
|
||||
|
||||
'@radix-ui/react-avatar@1.0.4(@types/react-dom@18.3.0)(@types/react@18.3.0)(react-dom@18.3.0(react@18.3.0))(react@18.3.0)':
|
||||
dependencies:
|
||||
'@babel/runtime': 7.24.4
|
||||
'@radix-ui/react-context': 1.0.1(@types/react@18.3.0)(react@18.3.0)
|
||||
'@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.3.0)(@types/react@18.3.0)(react-dom@18.3.0(react@18.3.0))(react@18.3.0)
|
||||
'@radix-ui/react-use-callback-ref': 1.0.1(@types/react@18.3.0)(react@18.3.0)
|
||||
'@radix-ui/react-use-layout-effect': 1.0.1(@types/react@18.3.0)(react@18.3.0)
|
||||
react: 18.3.0
|
||||
react-dom: 18.3.0(react@18.3.0)
|
||||
optionalDependencies:
|
||||
'@types/react': 18.3.0
|
||||
'@types/react-dom': 18.3.0
|
||||
|
||||
'@radix-ui/react-collapsible@1.0.3(@types/react-dom@18.3.0)(@types/react@18.3.0)(react-dom@18.3.0(react@18.3.0))(react@18.3.0)':
|
||||
dependencies:
|
||||
'@babel/runtime': 7.24.4
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import * as React from "react"
|
||||
import * as AvatarPrimitive from "@radix-ui/react-avatar"
|
||||
|
||||
import { cn } from "@renderer/lib/utils"
|
||||
|
||||
const Avatar = React.forwardRef<
|
||||
React.ElementRef<typeof AvatarPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AvatarPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
Avatar.displayName = AvatarPrimitive.Root.displayName
|
||||
|
||||
const AvatarImage = React.forwardRef<
|
||||
React.ElementRef<typeof AvatarPrimitive.Image>,
|
||||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AvatarPrimitive.Image
|
||||
ref={ref}
|
||||
className={cn("aspect-square h-full w-full", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AvatarImage.displayName = AvatarPrimitive.Image.displayName
|
||||
|
||||
const AvatarFallback = React.forwardRef<
|
||||
React.ElementRef<typeof AvatarPrimitive.Fallback>,
|
||||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AvatarPrimitive.Fallback
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex h-full w-full items-center justify-center rounded-full bg-muted",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName
|
||||
|
||||
export { Avatar, AvatarImage, AvatarFallback }
|
||||
@@ -0,0 +1,21 @@
|
||||
import {
|
||||
Avatar,
|
||||
AvatarFallback,
|
||||
AvatarImage,
|
||||
} from "@renderer/components/ui/avatar"
|
||||
import { useSession } from "@hono/auth-js/react"
|
||||
|
||||
export function UserButton() {
|
||||
const { data: session, status } = useSession()
|
||||
|
||||
if (status !== "authenticated") {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<Avatar className="size-20">
|
||||
<AvatarImage src={session?.user?.image || undefined} />
|
||||
<AvatarFallback>{session?.user?.name}</AvatarFallback>
|
||||
</Avatar>
|
||||
)
|
||||
}
|
||||
@@ -21,6 +21,10 @@ const router = createBrowserRouter([
|
||||
path: "login",
|
||||
lazy: () => import("./pages/login"),
|
||||
},
|
||||
{
|
||||
path: "redirect",
|
||||
lazy: () => import("./pages/redirect"),
|
||||
},
|
||||
{
|
||||
path: "debug",
|
||||
lazy: () => import("./pages/debug"),
|
||||
|
||||
@@ -2,6 +2,8 @@ import { Button } from "@renderer/components/ui/button"
|
||||
import { signIn } from "@hono/auth-js/react"
|
||||
|
||||
export function Component() {
|
||||
const callbackUrl = `${import.meta.env.VITE_ELECTRON_REMOTE_URL}/redirect?app=readok`
|
||||
|
||||
return (
|
||||
<div className="h-screen w-full flex items-center justify-center flex-col gap-10">
|
||||
<h1 className="text-3xl font-bold">Log in to ReadOK</h1>
|
||||
@@ -9,17 +11,24 @@ export function Component() {
|
||||
<Button
|
||||
className="text-lg"
|
||||
size="xl"
|
||||
type="submit"
|
||||
onClick={() =>
|
||||
signIn("github", {
|
||||
redirectUrl: `${import.meta.env.VITE_ELECTRON_REMOTE_URL}/login`,
|
||||
callbackUrl,
|
||||
})
|
||||
}
|
||||
>
|
||||
<i className="i-mingcute-github-fill mr-2 text-xl" /> Continue with
|
||||
GitHub
|
||||
</Button>
|
||||
<Button className="text-lg bg-blue-500 hover:bg-blue-500/90" size="xl">
|
||||
<Button
|
||||
className="text-lg bg-blue-500 hover:bg-blue-500/90"
|
||||
size="xl"
|
||||
onClick={() =>
|
||||
signIn("google", {
|
||||
callbackUrl,
|
||||
})
|
||||
}
|
||||
>
|
||||
<i className="i-mingcute-google-fill mr-2 text-xl" /> Continue with
|
||||
Google
|
||||
</Button>
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Button } from "@renderer/components/ui/button"
|
||||
import { UserButton } from "@renderer/components/user-button"
|
||||
|
||||
export function Component() {
|
||||
const app = new URLSearchParams(window.location.search).get("app")
|
||||
console.log(app)
|
||||
|
||||
return (
|
||||
<div className="h-screen w-full flex items-center justify-center flex-col gap-10">
|
||||
<UserButton />
|
||||
<h1 className="text-3xl font-bold">
|
||||
Successfully connected to ReadOK Account
|
||||
</h1>
|
||||
<h2>
|
||||
You have successfully connected to ReadOK Account. Now is the time to
|
||||
open ReadOK and safely close this page.
|
||||
</h2>
|
||||
<div className="flex flex-col gap-3">
|
||||
<Button className="text-lg" size="xl">
|
||||
Open ReadOK
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user