Browse Source

修复表情显示的bug

master
xie.bx 2 years ago
parent
commit
594737af3a
  1. 3
      im-ui/src/api/emotion.js
  2. 2
      im-uniapp/common/emotion.js
  3. 2
      im-uniapp/components/chat-item/chat-item.vue

3
im-ui/src/api/emotion.js

@ -16,8 +16,9 @@ let textToImg = (emoText) => {
let word = emoText.replace(/\#|\;/gi, ''); let word = emoText.replace(/\#|\;/gi, '');
let idx = emoTextList.indexOf(word); let idx = emoTextList.indexOf(word);
if(idx==-1){ if(idx==-1){
return ""; return emoText;
} }
return emoText;
let url = require(`@/assets/emoji/${idx}.gif`); let url = require(`@/assets/emoji/${idx}.gif`);
return `<img src="${url}" style="width:40px;height:40px;vertical-align:bottom;"/>` return `<img src="${url}" style="width:40px;height:40px;vertical-align:bottom;"/>`
} }

2
im-uniapp/common/emotion.js

@ -18,7 +18,7 @@ let textToImg = (emoText) => {
let word = emoText.replace(/\#|\;/gi, ''); let word = emoText.replace(/\#|\;/gi, '');
let idx = emoTextList.indexOf(word); let idx = emoTextList.indexOf(word);
if (idx == -1) { if (idx == -1) {
return ""; return emoText;
} }
let path = textToPath(emoText); let path = textToPath(emoText);
// #ifdef MP // #ifdef MP

2
im-uniapp/components/chat-item/chat-item.vue

@ -9,7 +9,7 @@
{{ chat.showName}} {{ chat.showName}}
</view> </view>
<view class="chat-content"> <view class="chat-content">
<view class="chat-content-text" v-html="$emo.transform(chat.lastContent)"></view> <rich-text class="chat-content-text" :nodes="$emo.transform(chat.lastContent)"></rich-text>
<view class="chat-time">{{$date.toTimeText(chat.lastSendTime)}}</view> <view class="chat-time">{{$date.toTimeText(chat.lastSendTime)}}</view>
</view> </view>
</view> </view>

Loading…
Cancel
Save