From 92cc75b51636fe5c2ce3fb81c87d1ea204cd2f08 Mon Sep 17 00:00:00 2001 From: hqer927 <285569480@qq.com> Date: Tue, 10 Sep 2024 17:15:50 +0800 Subject: [PATCH] feat: agreement differentiate between regions and language types --- desktop/renderer-app/src/constants/process.ts | 16 ++++++--- .../LoginPage/LoginWithCode/index.tsx | 7 +++- .../src/AppRoutes/WeChatRedirect.tsx | 31 +++++++++++++---- packages/flat-pages/src/JoinPage/index.tsx | 30 +++++++++++++++-- packages/flat-pages/src/LoginPage/index.tsx | 33 +++++++++++++++++-- packages/flat-pages/src/constants/process.ts | 22 ++++++++++--- .../src/utils/join-room-handler.tsx | 33 ++++++++++++++++--- 7 files changed, 147 insertions(+), 25 deletions(-) diff --git a/desktop/renderer-app/src/constants/process.ts b/desktop/renderer-app/src/constants/process.ts index 6d4f512fa3b..24d5daf757d 100644 --- a/desktop/renderer-app/src/constants/process.ts +++ b/desktop/renderer-app/src/constants/process.ts @@ -5,8 +5,16 @@ export const FLAT_WEB_DOMAIN = process.env.FLAT_WEB_DOMAIN; export const FLAT_WEB_BASE_URL = `https://${FLAT_WEB_DOMAIN}`; -export const PRIVACY_URL_CN = "https://www.flat.apprtc.cn/privacy.html"; -export const PRIVACY_URL_EN = "https://flat.whiteboard.agora.io/en/privacy.html"; +export const FLAT_REGION = process.env.FLAT_REGION; -export const SERVICE_URL_CN = "https://www.flat.apprtc.cn/service.html"; -export const SERVICE_URL_EN = "https://flat.whiteboard.agora.io/en/service.html"; +export const PRIVACY_URL_CN_CN = "https://www.flat.apprtc.cn/privacy.html"; +export const PRIVACY_URL_CN_EN = "https://www.flat.apprtc.cn/en/privacy.html"; + +export const PRIVACY_URL_EN_CN = "https://flat.agora.io/zh/privacy.html"; +export const PRIVACY_URL_EN_EN = "https://flat.agora.io/privacy.html"; + +export const SERVICE_URL_CN_CN = "https://www.flat.apprtc.cn/service.html"; +export const SERVICE_URL_CN_EN = "https://www.flat.apprtc.cn/en/service.html"; + +export const SERVICE_URL_EN_CN = "https://flat.agora.io/zh/service.html"; +export const SERVICE_URL_EN_EN = "https://flat.agora.io/service.html"; diff --git a/packages/flat-components/src/components/LoginPage/LoginWithCode/index.tsx b/packages/flat-components/src/components/LoginPage/LoginWithCode/index.tsx index 3c441700e3e..8ece3d82ac1 100644 --- a/packages/flat-components/src/components/LoginPage/LoginWithCode/index.tsx +++ b/packages/flat-components/src/components/LoginPage/LoginWithCode/index.tsx @@ -241,8 +241,13 @@ export async function getPrivacy(props: { serviceURL: string; }): Promise { const { privacyURL, serviceURL } = props; + // 仅中国地区,language为zh的情况下,使用中文隐私协议 + const isZh = serviceURL.indexOf("apprtc.cn") > -1 && privacyURL.indexOf("/en") === -1; if (FLAT_AGREEMENT_URL) { - const data = await fetch(FLAT_AGREEMENT_URL).then(response => { + const url = isZh + ? FLAT_AGREEMENT_URL + : FLAT_AGREEMENT_URL.replace("privacy.json", "privacy_en.json"); + const data = await fetch(url).then(response => { return response.json(); }); if (data.content) { diff --git a/packages/flat-pages/src/AppRoutes/WeChatRedirect.tsx b/packages/flat-pages/src/AppRoutes/WeChatRedirect.tsx index e634b79d3df..c8b4d4eab27 100644 --- a/packages/flat-pages/src/AppRoutes/WeChatRedirect.tsx +++ b/packages/flat-pages/src/AppRoutes/WeChatRedirect.tsx @@ -7,10 +7,15 @@ import React, { useCallback, useEffect, useState } from "react"; import { useLanguage, useTranslate } from "@netless/flat-i18n"; import { FLAT_DOWNLOAD_URL, - PRIVACY_URL, - PRIVACY_URL_CN, - SERVICE_URL, - SERVICE_URL_CN, + FLAT_REGION, + PRIVACY_URL_CN_CN, + PRIVACY_URL_CN_EN, + PRIVACY_URL_EN_CN, + PRIVACY_URL_EN_EN, + SERVICE_URL_CN_CN, + SERVICE_URL_CN_EN, + SERVICE_URL_EN_CN, + SERVICE_URL_EN_EN, } from "../constants/process"; import { isWeChatBrowser } from "../utils/user-agent"; @@ -25,8 +30,22 @@ export const WeChatRedirect = ({ url, open }: WeChatRedirectProps): React.ReactE const language = useLanguage(); const [openCount, setOpenCount] = useState(0); - const privacyURL = language.startsWith("zh") ? PRIVACY_URL_CN : PRIVACY_URL; - const serviceURL = language.startsWith("zh") ? SERVICE_URL_CN : SERVICE_URL; + const privacyURL = + FLAT_REGION === "CN" + ? language.startsWith("zh") + ? PRIVACY_URL_CN_CN + : PRIVACY_URL_CN_EN + : language.startsWith("zh") + ? PRIVACY_URL_EN_CN + : PRIVACY_URL_EN_EN; + const serviceURL = + FLAT_REGION === "CN" + ? language.startsWith("zh") + ? SERVICE_URL_CN_CN + : SERVICE_URL_CN_EN + : language.startsWith("zh") + ? SERVICE_URL_EN_CN + : SERVICE_URL_EN_EN; const openApp = useCallback((): void => { window.location.href = url || "x-agora-flat-client://active"; diff --git a/packages/flat-pages/src/JoinPage/index.tsx b/packages/flat-pages/src/JoinPage/index.tsx index 7b33f4f4086..92cdb0ad1e0 100644 --- a/packages/flat-pages/src/JoinPage/index.tsx +++ b/packages/flat-pages/src/JoinPage/index.tsx @@ -10,7 +10,17 @@ import { RouteNameType, RouteParams, usePushHistory } from "../utils/routes"; import { GlobalStoreContext, PageStoreContext } from "../components/StoreProvider"; import { loginCheck } from "@netless/flat-server-api"; import { joinRoomHandler } from "../utils/join-room-handler"; -import { PRIVACY_URL, PRIVACY_URL_CN, SERVICE_URL, SERVICE_URL_CN } from "../constants/process"; +import { + FLAT_REGION, + PRIVACY_URL_CN_CN, + PRIVACY_URL_CN_EN, + PRIVACY_URL_EN_CN, + PRIVACY_URL_EN_EN, + SERVICE_URL_CN_CN, + SERVICE_URL_CN_EN, + SERVICE_URL_EN_CN, + SERVICE_URL_EN_EN, +} from "../constants/process"; import JoinPageDesktop from "./JoinPageDesktop"; import JoinPageMobile from "./JoinPageMobile"; @@ -61,8 +71,22 @@ export const JoinPage = observer(function JoinPage() { const isMobile = width <= 480; - const privacyURL = language.startsWith("zh") ? PRIVACY_URL_CN : PRIVACY_URL; - const serviceURL = language.startsWith("zh") ? SERVICE_URL_CN : SERVICE_URL; + const privacyURL = + FLAT_REGION === "CN" + ? language.startsWith("zh") + ? PRIVACY_URL_CN_CN + : PRIVACY_URL_CN_EN + : language.startsWith("zh") + ? PRIVACY_URL_EN_CN + : PRIVACY_URL_EN_EN; + const serviceURL = + FLAT_REGION === "CN" + ? language.startsWith("zh") + ? SERVICE_URL_CN_CN + : SERVICE_URL_CN_EN + : language.startsWith("zh") + ? SERVICE_URL_EN_CN + : SERVICE_URL_EN_EN; return (
diff --git a/packages/flat-pages/src/LoginPage/index.tsx b/packages/flat-pages/src/LoginPage/index.tsx index a12ca35efdc..efef124f3ec 100644 --- a/packages/flat-pages/src/LoginPage/index.tsx +++ b/packages/flat-pages/src/LoginPage/index.tsx @@ -6,7 +6,16 @@ import { observer } from "mobx-react-lite"; import { wrap } from "./utils/disposer"; import { useLoginState } from "./utils/state"; import { WeChatLogin } from "./WeChatLogin"; -import { PRIVACY_URL, PRIVACY_URL_CN, SERVICE_URL, SERVICE_URL_CN } from "../constants/process"; +import { + PRIVACY_URL_CN_CN, + PRIVACY_URL_CN_EN, + PRIVACY_URL_EN_CN, + PRIVACY_URL_EN_EN, + SERVICE_URL_CN_CN, + SERVICE_URL_CN_EN, + SERVICE_URL_EN_CN, + SERVICE_URL_EN_EN, +} from "../constants/process"; import { useSafePromise } from "../utils/hooks/lifecycle"; import { AppUpgradeModal } from "../components/AppUpgradeModal"; @@ -39,6 +48,7 @@ import { registerPhoneSendCode, rebindingPhoneSendCode, rebindingPhone, + FLAT_REGION, } from "@netless/flat-server-api"; import { globalStore } from "@netless/flat-stores"; @@ -51,8 +61,25 @@ export const LoginPage = observer(function LoginPage() { useLoginState(); const panel = useMemo(() => { - const privacyURL = language.startsWith("zh") ? PRIVACY_URL_CN : PRIVACY_URL; - const serviceURL = language.startsWith("zh") ? SERVICE_URL_CN : SERVICE_URL; + // const privacyURL = language.startsWith("zh") ? PRIVACY_URL_CN : PRIVACY_URL; + // const serviceURL = language.startsWith("zh") ? SERVICE_URL_CN : SERVICE_URL; + + const privacyURL = + FLAT_REGION === "CN" + ? language.startsWith("zh") + ? PRIVACY_URL_CN_CN + : PRIVACY_URL_CN_EN + : language.startsWith("zh") + ? PRIVACY_URL_EN_CN + : PRIVACY_URL_EN_EN; + const serviceURL = + FLAT_REGION === "CN" + ? language.startsWith("zh") + ? SERVICE_URL_CN_CN + : SERVICE_URL_CN_EN + : language.startsWith("zh") + ? SERVICE_URL_EN_CN + : SERVICE_URL_EN_EN; const emailLanguage = language.startsWith("zh") ? "zh" : "en"; const loginProps = { diff --git a/packages/flat-pages/src/constants/process.ts b/packages/flat-pages/src/constants/process.ts index fee65bfb44d..bac59b7a632 100644 --- a/packages/flat-pages/src/constants/process.ts +++ b/packages/flat-pages/src/constants/process.ts @@ -2,10 +2,24 @@ export const NODE_ENV = process.env.NODE_ENV; export const FLAT_DOWNLOAD_URL = process.env.FLAT_DOWNLOAD_URL; -export const PRIVACY_URL_CN = "https://www.flat.apprtc.cn/privacy.html"; -export const PRIVACY_URL = "https://flat.whiteboard.agora.io/en/privacy.html"; +// export const PRIVACY_URL_CN = "https://www.flat.apprtc.cn/privacy.html"; +// export const PRIVACY_URL = "https://flat.agora.io/privacy.html"; -export const SERVICE_URL_CN = "https://www.flat.apprtc.cn/service.html"; -export const SERVICE_URL = "https://flat.whiteboard.agora.io/en/service.html"; +// export const SERVICE_URL_CN = "https://www.flat.apprtc.cn/service.html"; +// export const SERVICE_URL = "https://flat.agora.io/service.html"; + +export const FLAT_REGION = process.env.FLAT_REGION; + +export const PRIVACY_URL_CN_CN = "https://www.flat.apprtc.cn/privacy.html"; +export const PRIVACY_URL_CN_EN = "https://www.flat.apprtc.cn/en/privacy.html"; + +export const PRIVACY_URL_EN_CN = "https://flat.agora.io/zh/privacy.html"; +export const PRIVACY_URL_EN_EN = "https://flat.agora.io/privacy.html"; + +export const SERVICE_URL_CN_CN = "https://www.flat.apprtc.cn/service.html"; +export const SERVICE_URL_CN_EN = "https://www.flat.apprtc.cn/en/service.html"; + +export const SERVICE_URL_EN_CN = "https://flat.agora.io/zh/service.html"; +export const SERVICE_URL_EN_EN = "https://flat.agora.io/service.html"; export const FLAT_WEB_BASE_URL = `https://${process.env.FLAT_WEB_DOMAIN}`; diff --git a/packages/flat-pages/src/utils/join-room-handler.tsx b/packages/flat-pages/src/utils/join-room-handler.tsx index f93d2ad2739..9c5439f709f 100644 --- a/packages/flat-pages/src/utils/join-room-handler.tsx +++ b/packages/flat-pages/src/utils/join-room-handler.tsx @@ -1,10 +1,19 @@ import { RouteNameType } from "./routes"; import { roomStore, globalStore } from "@netless/flat-stores"; -import { RequestErrorCode, RoomType } from "@netless/flat-server-api"; +import { FLAT_REGION, RequestErrorCode, RoomType } from "@netless/flat-server-api"; import { errorTips, message, Modal } from "flat-components"; import { FlatI18n } from "@netless/flat-i18n"; import React from "react"; -import { PRIVACY_URL, PRIVACY_URL_CN, SERVICE_URL, SERVICE_URL_CN } from "../constants/process"; +import { + PRIVACY_URL_CN_CN, + PRIVACY_URL_CN_EN, + PRIVACY_URL_EN_CN, + PRIVACY_URL_EN_EN, + SERVICE_URL_CN_CN, + SERVICE_URL_CN_EN, + SERVICE_URL_EN_CN, + SERVICE_URL_EN_EN, +} from "../constants/process"; const { confirm } = Modal; export enum Region { @@ -23,8 +32,24 @@ export const joinRoomHandler = async ( const promise = await new Promise(resolve => { if (serverRegion && checkCrossRegionAuth(formatRoomUUID, serverRegion)) { const language = FlatI18n.getInstance().language; - const privacyURL = language.startsWith("zh") ? PRIVACY_URL_CN : PRIVACY_URL; - const serviceURL = language.startsWith("zh") ? SERVICE_URL_CN : SERVICE_URL; + // const privacyURL = language.startsWith("zh") ? PRIVACY_URL_CN : PRIVACY_URL; + // const serviceURL = language.startsWith("zh") ? SERVICE_URL_CN : SERVICE_URL; + const privacyURL = + FLAT_REGION === "CN" + ? language.startsWith("zh") + ? PRIVACY_URL_CN_CN + : PRIVACY_URL_CN_EN + : language.startsWith("zh") + ? PRIVACY_URL_EN_CN + : PRIVACY_URL_EN_EN; + const serviceURL = + FLAT_REGION === "CN" + ? language.startsWith("zh") + ? SERVICE_URL_CN_CN + : SERVICE_URL_CN_EN + : language.startsWith("zh") + ? SERVICE_URL_EN_CN + : SERVICE_URL_EN_EN; const context = FlatI18n.t("cross-region-auth.desc", { serviceAgreement: `《${FlatI18n.t("cross-region-auth.serviceAgreement")}》`,