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>
This commit is contained in:
@@ -17,7 +17,21 @@ export default {
|
||||
Vue.prototype.$toastHide = this.$refs.uToast.hide;
|
||||
});
|
||||
},
|
||||
onLaunch: function () {},
|
||||
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();
|
||||
},
|
||||
|
||||
@@ -38,6 +38,16 @@ var cn = {
|
||||
buyu: "捕鱼游戏",
|
||||
qipai: "棋牌游戏",
|
||||
|
||||
// 主页
|
||||
guest: "游客",
|
||||
onlineCount: "在线人数",
|
||||
loading: "加载中...",
|
||||
maxLimit: "上限",
|
||||
minLimit: "下限",
|
||||
betting: "下注中",
|
||||
dealing: "发牌中",
|
||||
preparing: "准备中",
|
||||
|
||||
recharge: "存款",
|
||||
rechargeWithdrawNetwork: "充/提币网络",
|
||||
pleaseChoose: "请选择",
|
||||
|
||||
@@ -38,6 +38,16 @@ var en = {
|
||||
buyu: "Fishing",
|
||||
qipai: "Slots",
|
||||
|
||||
// Home page
|
||||
guest: "Guest",
|
||||
onlineCount: "Online",
|
||||
loading: "Loading...",
|
||||
maxLimit: "Max",
|
||||
minLimit: "Min",
|
||||
betting: "Betting",
|
||||
dealing: "Dealing",
|
||||
preparing: "Preparing",
|
||||
|
||||
recharge: "Recharge",
|
||||
rechargeWithdrawNetwork: "Recharge / Withdraw Network",
|
||||
pleaseChoose: "Please Choose",
|
||||
|
||||
+12
-16
@@ -11,7 +11,7 @@
|
||||
<view class="user-avatar">
|
||||
<u-icon name="account-fill" color="#fff" size="24"></u-icon>
|
||||
</view>
|
||||
<text class="username">{{ userInfo.username || 'Guest' }}</text>
|
||||
<text class="username">{{ userInfo.username || $lang.guest }}</text>
|
||||
<view class="balance-pill">
|
||||
<u-icon name="rmb-circle-fill" color="#f4c46f" size="16"></u-icon>
|
||||
<text class="balance-text">{{ userInfo.money || '0.00' }}</text>
|
||||
@@ -45,13 +45,13 @@
|
||||
<image :src="cat.icon" mode="widthFix" style="width: 24px; height: 24px;" v-if="cat.icon" />
|
||||
<u-icon :name="cat.uIcon" color="#ccc" size="28" v-else></u-icon>
|
||||
</view>
|
||||
<text class="cat-name">{{ cat.name }}</text>
|
||||
<text class="cat-name">{{ $lang[cat.nameKey] }}</text>
|
||||
<text class="cat-count">({{ getCategoryCount(cat.id) }})</text>
|
||||
</view>
|
||||
|
||||
<!-- Online Count Bottom -->
|
||||
<view class="online-count-box">
|
||||
<text class="label">在线人数</text>
|
||||
<text class="label">{{ $lang.onlineCount }}</text>
|
||||
<text class="count">2506</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@@ -60,7 +60,7 @@
|
||||
<scroll-view scroll-y class="content-area">
|
||||
<view class="table-list">
|
||||
<view class="loading-state" v-if="loading">
|
||||
<u-loading-icon color="#f4c46f" vertical text="Loading..."></u-loading-icon>
|
||||
<u-loading-icon color="#f4c46f" vertical :text="$lang.loading"></u-loading-icon>
|
||||
</view>
|
||||
|
||||
<view
|
||||
@@ -75,7 +75,7 @@
|
||||
<text class="table-name">{{ item.table_name }}</text>
|
||||
</view>
|
||||
<view class="header-right">
|
||||
<text class="limit-info">上限:50000 下限:20</text>
|
||||
<text class="limit-info">{{ $lang.maxLimit }}:50000 {{ $lang.minLimit }}:20</text>
|
||||
<view class="status-dot" :class="{ 'is-live': item.status===1 }"></view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -138,15 +138,10 @@ export default {
|
||||
],
|
||||
currentCategory: 0, // 0 = All or default category
|
||||
categories: [
|
||||
/*
|
||||
{ id: 0, name: '国际厅', uIcon: 'grid', gameIds: [1,2,3,4,5] },
|
||||
{ id: 1, name: '旗舰厅', uIcon: 'star', gameIds: [1] },
|
||||
*/
|
||||
// Mapping based on common IDs: 1=Baccarat, 2=DT, 4=Bull, 5=ThreeCard
|
||||
{ id: 1, name: '百家乐', uIcon: 'chrome-circle-fill', gameIds: [1] },
|
||||
{ id: 2, name: '龙虎', uIcon: 'heart-fill', gameIds: [2] },
|
||||
{ id: 4, name: '牛牛', uIcon: 'thumb-up-fill', gameIds: [4] },
|
||||
// { id: 5, name: '金花/其他', uIcon: 'plus-circle-fill', gameIds: [5] }, // Grouping others
|
||||
{ id: 1, nameKey: 'baccarat', uIcon: 'chrome-circle-fill', gameIds: [1] },
|
||||
{ id: 2, nameKey: 'longhu', uIcon: 'heart-fill', gameIds: [2] },
|
||||
{ id: 4, nameKey: 'niuniu', uIcon: 'thumb-up-fill', gameIds: [4] },
|
||||
],
|
||||
allTables: [],
|
||||
loading: false,
|
||||
@@ -161,6 +156,7 @@ export default {
|
||||
...mapState({
|
||||
storeUserInfo: (state) => state.app.userInfo,
|
||||
language: (state) => state.app.language,
|
||||
$lang: (state) => state.app.lang[state.app.language],
|
||||
}),
|
||||
filteredTables() {
|
||||
if (!this.allTables.length) return [];
|
||||
@@ -261,9 +257,9 @@ export default {
|
||||
return 'status-dealing';
|
||||
},
|
||||
getStatusText(status) {
|
||||
if (status === 1) return '下注中';
|
||||
if (status === 2) return '发牌中';
|
||||
return '准备中';
|
||||
if (status === 1) return this.$lang.betting;
|
||||
if (status === 2) return this.$lang.dealing;
|
||||
return this.$lang.preparing;
|
||||
},
|
||||
enterGame(item) {
|
||||
// 跳转到同域名下的 /game 子目录
|
||||
|
||||
Reference in New Issue
Block a user