refactor(globalConfig&member): 重构多端按钮显示逻辑

1. 新增全局配置方法getAppType用于获取当前平台类型,对齐服务端$app_type
2. 将会员页按钮显示判断改为基于当前平台的配置校验
3. 简化模板中的条件判断代码
This commit is contained in:
2026-06-18 17:09:34 +08:00
parent 17864427c1
commit 06e3a4d796
2 changed files with 17 additions and 2 deletions

View File

@@ -1,3 +1,5 @@
import { Platform } from './platform.js';
// 内部 helper:获取当前页面实例
const _getCurrentPage = () => {
const pages = getCurrentPages();
@@ -186,6 +188,13 @@ export default {
}
},
methods: {
/**
* 当前平台类型(多端翻译隔离)
* 复用 Platform.getAppType(),与服务端 /api/BaseApi 的 $app_type 对齐
*/
getAppType() {
try { return Platform.getAppType() || '*'; } catch (e) { return '*'; }
},
// 颜色变浅(>0)、变深函数(<0)
lightenDarkenColor(color, amount) {

View File

@@ -28,9 +28,9 @@
<!-- 退出登录和账号注销按钮 -->
<view class="action-buttons" v-if="storeToken">
<view class="action-btn cancel-btn" v-if="!diyData.global || diyData.global.isShowCancelButton !== 0"
<view class="action-btn cancel-btn" v-if="isShowCancelButton"
@click="cancellation">{{ $lang('cancellation', '账号注销') }}</view>
<view class="action-btn logout-btn" v-if="!diyData.global || diyData.global.isShowLogoutButton !== 0"
<view class="action-btn logout-btn" v-if="isShowLogoutButton"
@click="logout">{{ $lang('logout', '退出登录') }}</view>
</view>
</view>
@@ -95,6 +95,12 @@ export default {
backgroundColor: this.bgColor,
minHeight: this.openBottomNav ? 'calc(100vh - 55px)' : ''
};
},
isShowCancelButton() {
return this.diyData?.global?.isShowCancelButton[`${this.getAppType()}`] !== 0
},
isShowLogoutButton() {
return this.diyData?.global?.isShowLogoutButton[`${this.getAppType()}`] !== 0
}
},
onLoad() {