feat: add external resource

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei 2024-09-12 23:49:23 +08:00
parent 5be2e9aad4
commit abec0ef191
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
3 changed files with 16 additions and 4 deletions

8
locales/external/en.json vendored Normal file
View File

@ -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}}"
}
}

View File

@ -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"
/**
@ -16,6 +17,7 @@ export const defaultResources = {
app: en,
lang: lang_en,
common: common_en,
external: external_en,
},
zh_CN: {

View File

@ -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({})
@ -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" />