feat(js入口文件): 设置固定布局的页面检测并设置对应语言

This commit is contained in:
hzj 2025-11-26 16:59:14 +08:00
parent 09b82d03df
commit f56586745d

View File

@ -37,7 +37,41 @@ const langStore = useLangStore() // 直接使用 import 的函数
// 检测URL参数并设置语言
const urlParams = new URLSearchParams(window.location.search)
const langParam = urlParams.get('lang')
if (langParam) {
//排行榜
const RankingPage = [
'/top-list', //排行榜
'/weekly-star', //每周明星
'/ranking', //总排行榜
]
// 活动页面
const ACTIVITIES = [
'/invitation-to-register', //邀请新用户(邀请码)
'/recharge-reward', //充值奖励页面
'/Lebanon-independence-day', //黎巴嫩独立日
]
// 固定语言(布局)的页面
const enPages = [...RankingPage, ...ACTIVITIES]
const arPages = []
// 获取当前页面路径
const currentPage = window.location.pathname
// 检查当前页面是否在固定英语的页面列表中
if (enPages.includes(currentPage)) {
// 强制设置为英语不受URL参数影响
setLocale(langStore, 'en')
}
// 检查当前页面是否在固定阿拉伯语的页面列表中
else if (arPages.includes(currentPage)) {
// 强制设置为阿拉伯语不受URL参数影响
setLocale(langStore, 'ar')
}
// 对于其他页面如果有URL参数则按参数设置语言
else if (langParam) {
setLocale(langStore, langParam)
}