Files
liandClaude Sonnet 4.5 8b736be67b feat(i18n): 添加主页国际化支持并优化语言切换
- 添加主页相关翻译键(guest, onlineCount, loading等)
- 修改主页使用 $lang 动态显示文本
- 分类名称改为使用 nameKey 映射到语言文件
- 添加 URL 参数语言检测(App.vue onLaunch)
- GamePortrait 返回时保留语言参数

支持语言:cn, tw, en, yn, kr, tl, in

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-17 23:26:20 +08:00

48 lines
1.1 KiB
Vue

<template>
<!-- 页面结构 -->
<view class="container">
<!-- 页面内容 -->
<router-view />
<u-toast ref="uToast"></u-toast>
<!-- TabBar -->
<tab-bar />
</view>
</template>
<script>
import Vue from "vue";
export default {
mounted() {
this.$nextTick(() => {
Vue.prototype.$toast = this.$refs.uToast.show;
Vue.prototype.$toastHide = this.$refs.uToast.hide;
});
},
onLaunch: function () {
// 检查 URL 参数中的语言设置
// #ifdef H5
const urlParams = new URLSearchParams(window.location.search);
const language = urlParams.get('language');
if (language && ['cn', 'tw', 'en', 'yn', 'kr', 'tl', 'in'].includes(language)) {
// 更新语言设置
this.$store.commit('app/setState', {
state: 'language',
value: language
});
localStorage.setItem('language', language);
}
// #endif
},
onShow: function () {
// this.setLanguage();
},
onHide: function () {
// console.log("App Hide");
},
};
</script>
<style lang="scss">
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
@import "uview-ui/index.scss";
</style>