Explorar el Código

!136 修复小程序表情不显示的bug
Merge pull request !136 from blue/v_3.0.0

blue hace 1 año
padre
commit
b4ad05ef53

+ 11 - 4
im-uniapp/common/emotion.js

@@ -13,23 +13,30 @@ let containEmoji = (content) => {
 }
 
 let transform = (content, extClass) => {
-	return content.replace(regex, (emoText)=>{
+	return content.replace(regex, (emoText) => {
 		// 将匹配结果替换表情图片
 		let word = emoText.replace(/\#|\;/gi, '');
 		let idx = emoTextList.indexOf(word);
 		if (idx == -1) {
 			return emoText;
 		}
-		let path = textToPath(emoText);
+		let path = textToPath(emoText, true);
 		let img = `<img src="${path}" class="${extClass}"/>`;
 		return img;
 	});
 }
 
-let textToPath = (emoText) => {
+let textToPath = (emoText, isRichText) => {
 	let word = emoText.replace(/\#|\;/gi, '');
 	let idx = emoTextList.indexOf(word);
-	return `/static/emoji/${idx}.gif`;
+	let path = `/static/emoji/${idx}.gif`;
+	// #ifdef MP-WEIXIN	
+	// 小程序的表情要去掉最前面"/"(但有的时候又不能去掉,十分奇怪)
+	if (isRichText) {
+		path = path.slice(1);
+	}
+	// #endif
+	return path;
 }
 
 export default {

+ 4 - 2
im-uniapp/manifest.json

@@ -106,9 +106,11 @@
         "appid" : "wxda94f40bfad0262c",
         "libVersion" : "latest",
         "setting" : {
-            "urlCheck" : false
+            "urlCheck" : false,
+            "minified" : true
         },
-        "usingComponents" : true
+        "usingComponents" : true,
+        "lazyCodeLoading" : "requiredComponents"
     },
     "mp-alipay" : {
         "usingComponents" : true

+ 7 - 6
im-uniapp/pages/chat/chat-box.vue

@@ -32,7 +32,8 @@
 				<chat-record v-if="showRecord" class="chat-record" @send="onSendRecord"></chat-record>
 				<view v-else class="send-text">
 					<editor id="editor" class="send-text-area" :placeholder="isReceipt ? '[回执消息]' : ''"
-						:read-only="isReadOnly" @focus="onEditorFocus" @blur="onEditorBlur" @ready="onEditorReady" @input="onTextInput">
+						:read-only="isReadOnly" @focus="onEditorFocus" @blur="onEditorBlur" @ready="onEditorReady"
+						@input="onTextInput">
 					</editor>
 				</view>
 				<view v-if="chat && chat.type == 'GROUP'" class="iconfont icon-at" @click="openAtBox()"></view>
@@ -93,7 +94,7 @@
 			<scroll-view v-if="chatTabBox === 'emo'" class="chat-emotion" scroll-y="true"
 				:style="{height: keyboardHeight+'px'}">
 				<view class="emotion-item-list">
-					<image class="emotion-item emoji-large" :title="emoText" :src="$emo.textToPath(emoText)"
+					<image class="emotion-item emoji-large" :title="emoText" :src="$emo.textToPath(emoText,false)"
 						v-for="(emoText, i) in $emo.emoTextList" :key="i" @click="selectEmoji(emoText)" mode="aspectFit"
 						lazy-load="true"></image>
 				</view>
@@ -369,7 +370,7 @@ export default {
 			}
 		},
 		selectEmoji(emoText) {
-			let path = this.$emo.textToPath(emoText)
+			let path = this.$emo.textToPath(emoText, true)
 			// 先把键盘禁用了,否则会重新弹出键盘
 			this.isReadOnly = true;
 			this.isEmpty = false;
@@ -588,7 +589,7 @@ export default {
 			this.isEmpty = e.detail.html == '<p><br></p>'
 		},
 		onEditorReady() {
-			this.$nextTick(()=>{
+			this.$nextTick(() => {
 				const query = uni.createSelectorQuery().in(this);
 				query.select('#editor').context((res) => {
 					this.editorCtx = res.context
@@ -741,7 +742,7 @@ export default {
 		},
 		listenKeyBoard() {
 			// #ifdef H5	
-			if (navigator.platform == "Win32" || navigator.platform == "MacIntel" ) {
+			if (navigator.platform == "Win32" || navigator.platform == "MacIntel") {
 				// 电脑端不需要弹出键盘
 				console.log("navigator.platform:", navigator.platform)
 				return;
@@ -751,7 +752,7 @@ export default {
 				window.addEventListener('focusin', this.focusInListener);
 				window.addEventListener('focusout', this.focusOutListener);
 				// 监听键盘高度,ios13以上开始支持
-				if(window.visualViewport){
+				if (window.visualViewport) {
 					window.visualViewport.addEventListener('resize', this.resizeListener);
 				}
 			} else {

BIN
im-uniapp/static/logo/logo.png