feat(i18n): 支持通过URL参数设置语言

- 新增从URL查询参数中读取lang值的功能
- 支持lang参数为zh或en时设置并存储语言
- 保留原有的本地存储语言获取逻辑作为备用方案
- 添加错误处理防止URL解析异常

chore(assets): 更新微信二维码图片路径

- 将about.html中的微信二维码图片地址改为相对路径
- 将index.html中的微信二维码图片地址改为相对路径
- 移除远程CDN备用加载逻辑,统一使用本地资源
This commit is contained in:
hehh
2025-11-26 17:18:54 +08:00
parent 9f0d3d0a2a
commit 747021c259
6 changed files with 19 additions and 3 deletions

View File

@@ -63,7 +63,23 @@ class AppCore {
=========================== */
class I18nManager {
constructor() {
this.lang = getStoredLanguage();
// 获取当前请求参数有无 lang 参数
try {
this.query = new URLSearchParams(window.location.search);
if (this.query.has('lang')) {
let lang = this.query.get('lang');
if (lang === 'zh' || lang === 'en') {
this.lang = lang;
setStoredLanguage(lang);
}
}
} catch (e) {
console.error(e);
}
if (!this.lang) {
this.lang = getStoredLanguage();
}
this.dict = {
zh: {
"nav.home": "首页",