Skip to content

Commit

Permalink
fix: use tag-i instead of tag-img to show expressions as tag-img with…
Browse files Browse the repository at this point in the history
…out src will show a default border
  • Loading branch information
hello-astar committed Apr 1, 2021
1 parent 340d516 commit e0b4253
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
- [x] 同端登录互踢
- [x] 表情包功能
- [ ] change log
- [ ] 抽出layout,使用qiankun重构,以支持不同应用展示
- [x] 开发webpack loader-将内联样式的px转换为rem
- [ ] 艾特@功能
- [ ] 抽出下拉上拉逻辑,重构pullRefresh组件

# 安装运行
1. 拉取项目
Expand Down
11 changes: 8 additions & 3 deletions src/views/chat/components/expression/expressionItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
* @Author: astar
* @Date: 2021-03-04 10:11:57
* @LastEditors: astar
* @LastEditTime: 2021-03-04 10:30:35
* @LastEditTime: 2021-04-01 14:48:05
* @Description: 单个表情渲染
* @FilePath: \vue-chat\src\views\chat\components\expression\expressionItem.vue
-->
<template>
<span
<i
contenteditable="false"
class="emoji-icon"
:data-name="iconName"
:style="{ 'background-position': `0 ${-30 * index}px` }"
></span>
></i>
</template>
<script>
import expressions from './config.js';
Expand All @@ -24,6 +26,9 @@ export default {
computed: {
index () {
return expressions.findIndex(item => item === this.value)
},
iconName () {
return `emoji-${this.value}`
}
}
}
Expand Down
12 changes: 4 additions & 8 deletions src/views/chat/components/expression/index.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!--
* @Author: astar
* @Date: 2021-01-30 14:59:41
* @LastEditors: astar
* @LastEditTime: 2021-03-04 10:28:21
* @LastEditors: cmx
* @LastEditTime: 2021-04-01 14:52:30
* @Description: 表情包popup
* @FilePath: \vue-chat\src\views\chat\components\expression\index.vue
-->
Expand All @@ -12,7 +12,6 @@
v-for="(item, index) in expressions"
:key="index"
:value="item"
:data-index="index"
></expression-item>
</div>
</template>
Expand All @@ -34,11 +33,8 @@ export default {
},
methods: {
selectExpression ({ target }) {
if (target.nodeName.toLowerCase() === 'span') {
const index = target.dataset.index
if (this.expressions[index]) {
this.onSelectExpression(`<img name="emoji-${this.expressions[index]}" class="emoji-icon" style="background-position: 0 ${-30 * index}px"/>`)
}
if (target.nodeName.toLowerCase() === 'i' && target.dataset.name) {
this.onSelectExpression(target.outerHTML)
}
}
},
Expand Down
8 changes: 4 additions & 4 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-03-27 23:01:41
* @LastEditTime: 2021-04-01 14:50:21
* @Description: 聊天输入框
* @FilePath: \vue-chat\src\views\chat\components\inputBox.vue
-->
Expand Down Expand Up @@ -159,12 +159,12 @@ export default {
})
console.log(child.textContent)
} else if (nodeType === 1) { // 元素节点, 目前只有emoji类型,后期考虑其他
if ((new RegExp(/^emoji-.*/)).test(child.name)) {
if ((new RegExp(/^emoji-.*/)).test(child.dataset.name)) {
result.push({
kind: 'emoji',
value: child.name.replace(/^emoji-/, '')
value: child.dataset.name.replace(/^emoji-/, '')
})
console.log(child.name)
console.log(child.dataset.name)
}
}
})
Expand Down

0 comments on commit e0b4253

Please sign in to comment.