返回 AiToEarn
domain.ts
根目录 / project / aitoearn-web / src / utils / region / domain.ts
1 /**
2 * regionDomain - 区域域名切换工具
3 * 获取并跳转到当前站点对应的区域切换目标域名。
4 */
5
6 import { isChina } from '@/constant'
7
8 /** 获取当前区域对应的切换目标域名 */
9 function getRegionSwitchDomain() {
10 return isChina
11 ? process.env.NEXT_PUBLIC_ABROAD_DOMAIN || 'https://aitoearn.ai/'
12 : process.env.NEXT_PUBLIC_CHINA_DOMAIN || 'https://aitoearn.cn/'
13 }
14
15 /** 跳转到当前区域对应的切换目标域名 */
16 export function switchRegionDomain() {
17 if (typeof window === 'undefined')
18 return
19
20 window.location.href = getRegionSwitchDomain()
21 }
22
22 lines TYPESCRIPT