Skip to content

Commit

Permalink
feat: add external resource
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Sep 12, 2024
1 parent 5be2e9a commit abec0ef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 8 additions & 0 deletions locales/external/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"redirect": {
"successMessage": "You have successfully connected to {{APP_NAME}} Account.",
"instruction": "Now is the time to open {{APP_NAME}} and safely close this page.",
"continueInBrowser": "Continue in Browser",
"openApp": "Open {{APP_NAME}}"
}
}
2 changes: 2 additions & 0 deletions src/renderer/src/@types/default-resource.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import en from "../../../../locales/app/en.json"
import common_en from "../../../../locales/common/en.json"
import common_zhCN from "../../../../locales/common/zh_CN.json"
import external_en from "../../../../locales/external/en.json"
import lang_en from "../../../../locales/lang/en.json"

/**
Expand All @@ -16,6 +17,7 @@ export const defaultResources = {
app: en,
lang: lang_en,
common: common_en,
external: external_en,
},

zh_CN: {
Expand Down
10 changes: 6 additions & 4 deletions src/renderer/src/pages/(external)/redirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { UserAvatar } from "@renderer/components/user-button"
import { apiClient } from "@renderer/lib/api-fetch"
import { DEEPLINK_SCHEME } from "@shared/constants"
import { useEffect, useRef } from "react"
import { useTranslation } from "react-i18next"
import { useNavigate } from "react-router-dom"

export function Component() {
const navigate = useNavigate()
const { t } = useTranslation("external")

const getCallbackUrl = async () => {
const { data } = await apiClient["auth-app"]["new-session"].$post({})
Expand All @@ -31,20 +33,20 @@ export function Component() {
<div className="flex h-screen w-full flex-col items-center justify-center gap-10 px-4 pb-12 pt-[30vh]">
<UserAvatar className="gap-8 px-10 py-4 text-2xl" />
<h2 className="text-center">
You have successfully connected to {APP_NAME} Account. <br />
{t("redirect.successMessage", { APP_NAME })} <br />
<br />
Now is the time to open {APP_NAME} and safely close this page.
{t("redirect.instruction", { APP_NAME })}
</h2>
<div className="center flex flex-col gap-4 sm:flex-row">
<Button variant="text" className="h-14 px-10 text-base" onClick={() => navigate("/")}>
Continue in Browser
{t("redirect.continueInBrowser")}
</Button>

<Button
className="h-14 !rounded-full px-5 text-lg"
onClick={async () => window.open(await getCallbackUrl(), "_top")}
>
Open {APP_NAME}
{t("redirect.openApp", { APP_NAME })}
</Button>
</div>
<div className="grow" />
Expand Down

0 comments on commit abec0ef

Please sign in to comment.