feat:添加按钮显示 + 触发切换逻辑
This commit is contained in:
@@ -131,12 +131,20 @@
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
|
||||
<!-- 👇 新增:语言切换按钮 -->
|
||||
<view class="lang-switch-wrap" @click="toggleLang">
|
||||
<text class="lang-text">{{ $lang('common.langSwitchBtn') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<hover-nav></hover-nav>
|
||||
<diy-bottom-nav></diy-bottom-nav>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// 👇 引入语言工具文件
|
||||
import langUtil from '@/common/js/lang.js';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -194,6 +202,13 @@ export default {
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
// 👇 新增:语言切换方法
|
||||
toggleLang() {
|
||||
const currentLang = this.$lang?.locale || 'zh-cn';
|
||||
const targetLang = currentLang === 'zh-cn' ? 'en-us' : 'zh-cn';
|
||||
langUtil.change(targetLang);
|
||||
},
|
||||
|
||||
test(){
|
||||
// channelReady(function(bAvailable) {
|
||||
// alert('是否存在框架服务:' + bAvailable)
|
||||
@@ -508,4 +523,30 @@ image {
|
||||
width: 90rpx;
|
||||
z-index: 9999;
|
||||
}
|
||||
</style>
|
||||
|
||||
/* 👇 新增:语言切换按钮样式 */
|
||||
.lang-switch-wrap {
|
||||
position: fixed !important;
|
||||
bottom: 120rpx !important; /* 避开底部tabBar */
|
||||
right: 30rpx !important;
|
||||
z-index: 99999 !important; /* 层级拉满 */
|
||||
width: 120rpx;
|
||||
height: 60rpx;
|
||||
background-color: #ffffff !important;
|
||||
border: 1px solid #e5e5e5 !important;
|
||||
border-radius: 30rpx !important;
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1) !important;
|
||||
}
|
||||
.lang-text {
|
||||
font-size: 28rpx !important;
|
||||
color: #333333 !important;
|
||||
font-weight: 500 !important;
|
||||
}
|
||||
.lang-switch-wrap:active {
|
||||
transform: scale(0.95) !important;
|
||||
transition: transform 0.1s ease !important;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user