refactor: 统一将微信小程序条件编译替换为全小程序平台

将项目中所有`MP-WEIXIN`条件编译标识替换为通用的`MP`,适配所有字节小程序平台,减少重复的平台特化代码。
This commit is contained in:
2026-06-04 16:41:13 +08:00
parent 6690788a17
commit 5a0c903346
8 changed files with 16 additions and 16 deletions

View File

@@ -30,7 +30,7 @@ image {
/* #ifdef H5 */
height: calc(100vh - 88rpx);
/* #endif */
/* #ifdef MP-WEIXIN */
/* #ifdef MP */
height: 100vh;
/* #endif */
}

View File

@@ -25,7 +25,7 @@ view {
background-size: 100% 260rpx;
background-repeat: no-repeat;
// #ifdef MP-WEIXIN
// #ifdef MP
background-size: 100% 380rpx;
// #endif
@@ -52,7 +52,7 @@ view {
background: linear-gradient(180deg, $base-color 10%, $color-bg 100%);
background-size: 100% 260rpx;
// #ifdef MP-WEIXIN
// #ifdef MP
background-size: 100% 380rpx;
// #endif

View File

@@ -50,7 +50,7 @@ function getUserId() {
return guestId;
}
// #ifdef MP-WEIXIN
// #ifdef MP
// ================================
// WebSocket 长连接管理(微信小程序)
// ================================
@@ -283,7 +283,7 @@ export default {
* 微信小程序:复用长连接 WebSocket
*/
async sendStreamMessage(message, onChunk, onComplete) {
// #ifdef MP-WEIXIN
// #ifdef MP
// 先确保连接已就绪
try {
await ensureWebSocketConnected();
@@ -676,7 +676,7 @@ export default {
return null;
}
// #endif
// #ifdef MP-WEIXIN
// #ifdef MP
console.warn('chatWithEventSource 不支持微信小程序');
return null;
// #endif
@@ -692,13 +692,13 @@ export default {
onComplete?.({ message: res.content, conversation_id: res.conversation_id });
});
// #endif
// #ifdef MP-WEIXIN
// #ifdef MP
console.warn('chatWithFetchStream 不支持微信小程序');
return null;
// #endif
},
// #ifdef MP-WEIXIN
// #ifdef MP
/**
* [微信小程序] 断开 WebSocket 长连接(页面离开时调用)
*/

View File

@@ -282,7 +282,7 @@ export class CustomerService {
// #ifdef H5
window.location.href = config.third_url;
// #endif
// #ifdef MP-WEIXIN
// #ifdef MP
uni.setClipboardData({
data: config.third_url,
success: () => {
@@ -350,7 +350,7 @@ export class CustomerService {
// #ifdef H5
window.open(serviceUrl, '_blank');
// #endif
// #ifdef MP-WEIXIN
// #ifdef MP
uni.setClipboardData({ data: serviceUrl });
uni.showToast({ title: '客服链接已复制', icon: 'none' });
// #endif

View File

@@ -104,7 +104,7 @@
/* #ifndef MP-WEIXIN */
height: 64rpx;
/* #endif */
/* #ifdef MP-WEIXIN */
/* #ifdef MP */
height: 100%;
/* #endif */
border-radius: 40rpx;

View File

@@ -47,7 +47,7 @@
</view>
</uni-popup>
<!-- #ifdef MP-WEIXIN -->
<!-- #ifdef MP -->
<!-- 小程序隐私协议 -->
<privacy-popup ref="privacyPopup"></privacy-popup>
<!-- #endif -->

View File

@@ -7,7 +7,7 @@
z-index: 100;
background: unset;
// #ifdef MP-WEIXIN
// #ifdef MP
background-size: 100% 380rpx;
// #endif
@@ -47,7 +47,7 @@
overflow: hidden;
margin: 24rpx 28rpx;
border-radius: 24rpx;
// #ifdef MP-WEIXIN
// #ifdef MP
padding-top: 160rpx;
// #endif
height: 352rpx;

View File

@@ -7,7 +7,7 @@
z-index: 100;
background: unset;
// #ifdef MP-WEIXIN
// #ifdef MP
background-size: 100% 380rpx;
// #endif
@@ -47,7 +47,7 @@
border-radius: 0 0 100% 100%/0 0 70rpx 70rpx;
overflow: hidden;
// #ifdef MP-WEIXIN
// #ifdef MP
padding-top: 160rpx;
// #endif