1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
| <template>
| <div class="text-message" :class="{
| left: float == 'left',
| right: float == 'right',
| 'max-width': !fullWidth,
| }">
| <div v-if="arrow" class="arrow"></div>
| <pre v-html="html" />
| </div>
| </template>
| <script>
| import { textReplaceLink } from "@/utils/functions";
| import { textReplaceEmoji } from "@/utils/emojis";
|
| export default {
| name: "TextMessage",
| props: {
| content: {
| type: [String, Number],
| default: "",
| },
| float: {
| type: String,
| default: "left",
| },
| fullWidth: {
| type: Boolean,
| default: true,
| },
| arrow: {
| type: Boolean,
| default: false,
| },
| },
| data () {
| return {
| html: "",
| };
| },
| created () {
| const text = textReplaceLink(
| this.content,
| this.float == "right" ? "#ffffff" : "rgb(9 149 208)"
| );
|
| this.html = textReplaceEmoji(text);
| },
| };
| </script>
| <style lang="less" scoped>
| @bg-left-color: #f5f5f5;
| @bg-right-color: #1ebafc;
|
| .text-message {
| position: relative;
| min-width: 30px;
| min-height: 30px;
| border-radius: 5px;
| padding: 5px;
|
| .arrow {
| position: absolute;
| width: 0;
| height: 0;
| font-size: 0;
| border: 5px solid;
| top: 6px;
| left: -10px;
| }
|
| &.max-width {
| max-width: calc(100% - 50px);
| }
|
| &.left {
| color: #3a3a3a;
| background: @bg-left-color;
|
| .arrow {
| border-color: transparent @bg-left-color transparent transparent;
| }
| }
|
| &.right {
| color: #fff;
| background: @bg-right-color;
|
| .arrow {
| right: -10px;
| left: unset;
| border-color: transparent transparent transparent @bg-right-color;
| }
| }
|
| pre {
| white-space: pre-wrap;
| overflow: hidden;
| word-break: break-word;
| word-wrap: break-word;
| font-size: 15px;
| padding: 3px 10px;
| font-family: "Microsoft YaHei";
| line-height: 25px;
| }
| }
| </style>
|
|