feat(i18n): 支持通过URL参数设置语言
- 新增从URL查询参数中读取lang值的功能 - 支持lang参数为zh或en时设置并存储语言 - 保留原有的本地存储语言获取逻辑作为备用方案 - 添加错误处理防止URL解析异常 chore(assets): 更新微信二维码图片路径 - 将about.html中的微信二维码图片地址改为相对路径 - 将index.html中的微信二维码图片地址改为相对路径 - 移除远程CDN备用加载逻辑,统一使用本地资源
This commit is contained in:
@@ -306,7 +306,7 @@
|
|||||||
<button class="modal-close" onclick="toggleWechat()"><i class="ri-close-line"></i></button>
|
<button class="modal-close" onclick="toggleWechat()"><i class="ri-close-line"></i></button>
|
||||||
<h3 data-i18n="modal.wechat">Official Account</h3>
|
<h3 data-i18n="modal.wechat">Official Account</h3>
|
||||||
<div class="qr-box">
|
<div class="qr-box">
|
||||||
<img src="https://blog-file.hehouhui.cn/wechat/mp-honesy.jpg" alt="WeChat QR" onerror="this.style.display='none';this.nextElementSibling.style.display='block'">
|
<img src="./images/mp-honesy.jpg" alt="WeChat QR" onerror="this.style.display='none';this.nextElementSibling.style.display='block'">
|
||||||
<!-- <div class="qr-fallback">QR Load Failed</div>-->
|
<!-- <div class="qr-fallback">QR Load Failed</div>-->
|
||||||
</div>
|
</div>
|
||||||
<p data-i18n="modal.desc">Scan to follow Tech Share</p>
|
<p data-i18n="modal.desc">Scan to follow Tech Share</p>
|
||||||
|
|||||||
BIN
images/bj/10.jpg
BIN
images/bj/10.jpg
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 MiB |
BIN
images/bj/9.jpg
BIN
images/bj/9.jpg
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 MiB |
BIN
images/mp-honesy.jpg
Normal file
BIN
images/mp-honesy.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
@@ -263,7 +263,7 @@
|
|||||||
<div class="weixin-qrcode-container">
|
<div class="weixin-qrcode-container">
|
||||||
<div class="weixin-qrcode-title">扫描二维码</div>
|
<div class="weixin-qrcode-title">扫描二维码</div>
|
||||||
<div class="weixin-qrcode-desc">请使用微信扫一扫添加关注</div>
|
<div class="weixin-qrcode-desc">请使用微信扫一扫添加关注</div>
|
||||||
<img src="https://blog-file.hehouhui.cn/wechat/mp-honesy.jpg" alt="微信二维码"
|
<img src="./images/mp-honesy.jpg" alt="微信二维码"
|
||||||
class="weixin-qrcode-image"
|
class="weixin-qrcode-image"
|
||||||
onerror="this.src='https://cdn.jsdmirror.com/gh/listener-He/Home/images/logo.png'; this.alt='二维码加载失败'">
|
onerror="this.src='https://cdn.jsdmirror.com/gh/listener-He/Home/images/logo.png'; this.alt='二维码加载失败'">
|
||||||
<button class="weixin-qrcode-close" onclick="closeWeixin()">关闭</button>
|
<button class="weixin-qrcode-close" onclick="closeWeixin()">关闭</button>
|
||||||
|
|||||||
18
js/about.js
18
js/about.js
@@ -63,7 +63,23 @@ class AppCore {
|
|||||||
=========================== */
|
=========================== */
|
||||||
class I18nManager {
|
class I18nManager {
|
||||||
constructor() {
|
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 = {
|
this.dict = {
|
||||||
zh: {
|
zh: {
|
||||||
"nav.home": "首页",
|
"nav.home": "首页",
|
||||||
|
|||||||
Reference in New Issue
Block a user