refactor: 统一将微信小程序条件编译替换为全小程序平台
将项目中所有`MP-WEIXIN`条件编译标识替换为通用的`MP`,适配所有字节小程序平台,减少重复的平台特化代码。
This commit is contained in:
@@ -30,7 +30,7 @@ image {
|
|||||||
/* #ifdef H5 */
|
/* #ifdef H5 */
|
||||||
height: calc(100vh - 88rpx);
|
height: calc(100vh - 88rpx);
|
||||||
/* #endif */
|
/* #endif */
|
||||||
/* #ifdef MP-WEIXIN */
|
/* #ifdef MP */
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ view {
|
|||||||
background-size: 100% 260rpx;
|
background-size: 100% 260rpx;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP
|
||||||
background-size: 100% 380rpx;
|
background-size: 100% 380rpx;
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ view {
|
|||||||
background: linear-gradient(180deg, $base-color 10%, $color-bg 100%);
|
background: linear-gradient(180deg, $base-color 10%, $color-bg 100%);
|
||||||
background-size: 100% 260rpx;
|
background-size: 100% 260rpx;
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP
|
||||||
background-size: 100% 380rpx;
|
background-size: 100% 380rpx;
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ function getUserId() {
|
|||||||
return guestId;
|
return guestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP
|
||||||
// ================================
|
// ================================
|
||||||
// WebSocket 长连接管理(微信小程序)
|
// WebSocket 长连接管理(微信小程序)
|
||||||
// ================================
|
// ================================
|
||||||
@@ -283,7 +283,7 @@ export default {
|
|||||||
* 微信小程序:复用长连接 WebSocket
|
* 微信小程序:复用长连接 WebSocket
|
||||||
*/
|
*/
|
||||||
async sendStreamMessage(message, onChunk, onComplete) {
|
async sendStreamMessage(message, onChunk, onComplete) {
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP
|
||||||
// 先确保连接已就绪
|
// 先确保连接已就绪
|
||||||
try {
|
try {
|
||||||
await ensureWebSocketConnected();
|
await ensureWebSocketConnected();
|
||||||
@@ -676,7 +676,7 @@ export default {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP
|
||||||
console.warn('chatWithEventSource 不支持微信小程序');
|
console.warn('chatWithEventSource 不支持微信小程序');
|
||||||
return null;
|
return null;
|
||||||
// #endif
|
// #endif
|
||||||
@@ -692,13 +692,13 @@ export default {
|
|||||||
onComplete?.({ message: res.content, conversation_id: res.conversation_id });
|
onComplete?.({ message: res.content, conversation_id: res.conversation_id });
|
||||||
});
|
});
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP
|
||||||
console.warn('chatWithFetchStream 不支持微信小程序');
|
console.warn('chatWithFetchStream 不支持微信小程序');
|
||||||
return null;
|
return null;
|
||||||
// #endif
|
// #endif
|
||||||
},
|
},
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP
|
||||||
/**
|
/**
|
||||||
* [微信小程序] 断开 WebSocket 长连接(页面离开时调用)
|
* [微信小程序] 断开 WebSocket 长连接(页面离开时调用)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ export class CustomerService {
|
|||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
window.location.href = config.third_url;
|
window.location.href = config.third_url;
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP
|
||||||
uni.setClipboardData({
|
uni.setClipboardData({
|
||||||
data: config.third_url,
|
data: config.third_url,
|
||||||
success: () => {
|
success: () => {
|
||||||
@@ -350,7 +350,7 @@ export class CustomerService {
|
|||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
window.open(serviceUrl, '_blank');
|
window.open(serviceUrl, '_blank');
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP
|
||||||
uni.setClipboardData({ data: serviceUrl });
|
uni.setClipboardData({ data: serviceUrl });
|
||||||
uni.showToast({ title: '客服链接已复制', icon: 'none' });
|
uni.showToast({ title: '客服链接已复制', icon: 'none' });
|
||||||
// #endif
|
// #endif
|
||||||
|
|||||||
@@ -104,7 +104,7 @@
|
|||||||
/* #ifndef MP-WEIXIN */
|
/* #ifndef MP-WEIXIN */
|
||||||
height: 64rpx;
|
height: 64rpx;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
/* #ifdef MP-WEIXIN */
|
/* #ifdef MP */
|
||||||
height: 100%;
|
height: 100%;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
border-radius: 40rpx;
|
border-radius: 40rpx;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</uni-popup>
|
</uni-popup>
|
||||||
|
|
||||||
<!-- #ifdef MP-WEIXIN -->
|
<!-- #ifdef MP -->
|
||||||
<!-- 小程序隐私协议 -->
|
<!-- 小程序隐私协议 -->
|
||||||
<privacy-popup ref="privacyPopup"></privacy-popup>
|
<privacy-popup ref="privacyPopup"></privacy-popup>
|
||||||
<!-- #endif -->
|
<!-- #endif -->
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
z-index: 100;
|
z-index: 100;
|
||||||
background: unset;
|
background: unset;
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP
|
||||||
background-size: 100% 380rpx;
|
background-size: 100% 380rpx;
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin: 24rpx 28rpx;
|
margin: 24rpx 28rpx;
|
||||||
border-radius: 24rpx;
|
border-radius: 24rpx;
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP
|
||||||
padding-top: 160rpx;
|
padding-top: 160rpx;
|
||||||
// #endif
|
// #endif
|
||||||
height: 352rpx;
|
height: 352rpx;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
z-index: 100;
|
z-index: 100;
|
||||||
background: unset;
|
background: unset;
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP
|
||||||
background-size: 100% 380rpx;
|
background-size: 100% 380rpx;
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
border-radius: 0 0 100% 100%/0 0 70rpx 70rpx;
|
border-radius: 0 0 100% 100%/0 0 70rpx 70rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP
|
||||||
padding-top: 160rpx;
|
padding-top: 160rpx;
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user