Skip to content

Commit

Permalink
feat: agreement differentiate between regions and language types (#2158)
Browse files Browse the repository at this point in the history
  • Loading branch information
hqer927 authored Sep 10, 2024
1 parent bc104b7 commit d0d4a2c
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 25 deletions.
1 change: 1 addition & 0 deletions cspell.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
version: "0.1",
language: "en",
words: [
"apprtc",
"cspell",
"vite",
"vitejs",
Expand Down
16 changes: 12 additions & 4 deletions desktop/renderer-app/src/constants/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,13 @@ export async function getPrivacy(props: {
serviceURL: string;
}): Promise<PrivacyAgreementData | undefined> {
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) {
Expand Down
31 changes: 25 additions & 6 deletions packages/flat-pages/src/AppRoutes/WeChatRedirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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";
Expand Down
30 changes: 27 additions & 3 deletions packages/flat-pages/src/JoinPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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 (
<div>
Expand Down
33 changes: 30 additions & 3 deletions packages/flat-pages/src/LoginPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -39,6 +48,7 @@ import {
registerPhoneSendCode,
rebindingPhoneSendCode,
rebindingPhone,
FLAT_REGION,
} from "@netless/flat-server-api";
import { globalStore } from "@netless/flat-stores";

Expand All @@ -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 = {
Expand Down
22 changes: 18 additions & 4 deletions packages/flat-pages/src/constants/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
33 changes: 29 additions & 4 deletions packages/flat-pages/src/utils/join-room-handler.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -23,8 +32,24 @@ export const joinRoomHandler = async (
const promise = await new Promise<boolean>(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: `<a href='${serviceURL}'>《${FlatI18n.t("cross-region-auth.serviceAgreement")}》</a>`,
Expand Down

0 comments on commit d0d4a2c

Please sign in to comment.