Skip to content

Commit

Permalink
fix: bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hello-astar committed Apr 17, 2021
1 parent d0cbf77 commit d941f5a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/utils/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: astar
* @Date: 2021-04-01 16:02:08
* @LastEditors: astar
* @LastEditTime: 2021-04-17 13:34:43
* @LastEditTime: 2021-04-17 14:07:22
* @Description: 文件描述
* @FilePath: \vue-chat\src\utils\editor.js
*/
Expand Down Expand Up @@ -89,11 +89,13 @@ export function getJSONFromInput ($ele) {
value: child.textContent // 还需转义,到时候再说吧
})
} else if (nodeType === 1) { // 元素节点, 目前只有emoji和at类型,后期考虑其他
let options = child.dataset
result.push({
kind: options.kind,
value: options.value
})
let options = child.dataset;
if (options.kind && options.value) {
result.push({
kind: options.kind,
value: options.value
});
}
}
})
return result
Expand Down
5 changes: 3 additions & 2 deletions src/views/chat/components/inputBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: astar
* @Date: 2021-01-30 15:21:05
* @LastEditors: astar
* @LastEditTime: 2021-04-17 13:40:26
* @LastEditTime: 2021-04-17 14:02:23
* @Description: 聊天输入框
* @FilePath: \vue-chat\src\views\chat\components\inputBox.vue
-->
Expand All @@ -23,7 +23,7 @@
<message v-for="(item, idx) in EMOJIS" :key="idx" :item="{ kind: KINDS.EMOJI, value: item }" @click.native="insertHTMLFromJson({ kind: KINDS.EMOJI, value: item })"></message>
</div>
</s-popup>
<s-popup v-model="showGifs" place="bottom" :x="pos.x" :y="pos.y" :width="popupWidth" max-height="150px">
<s-popup v-model="showGifs" place="bottom" :x="pos.x" :y="pos.y" :width="popupWidth">
<message @click.native="onSelectImg(item.url)" v-for="item in gifs" :key="item.id" :item="{ kind: KINDS.IMG, value: item.url }" />
</s-popup>
</div>
Expand Down Expand Up @@ -133,6 +133,7 @@ export default {
this.$emit('send', getJSONFromInput(this.$refs.input));
this.$refs.input.innerHTML = null;
this.showEmojis = false;
this.showGifs = false;
},
/**
* 保存输入框光标最后所在位置,存入insertAtCursor函数
Expand Down

0 comments on commit d941f5a

Please sign in to comment.