vue-intergrall-plugins 0.0.274 → 0.0.280
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +185 -185
- package/dist/vue-intergrall-plugins.esm.js +79 -60
- package/dist/vue-intergrall-plugins.min.js +1 -1
- package/dist/vue-intergrall-plugins.ssr.js +146 -127
- package/package.json +66 -66
- package/src/lib-components/Buttons/IconButton.vue +27 -27
- package/src/lib-components/Buttons/SimpleButton.vue +140 -140
- package/src/lib-components/Cards/Card.vue +412 -412
- package/src/lib-components/Cards/CardCheck.vue +35 -35
- package/src/lib-components/Cards/CardFile.vue +157 -157
- package/src/lib-components/Chat/BtnDownloadAllFiles.vue +32 -32
- package/src/lib-components/Chat/BtnEmojis.vue +124 -124
- package/src/lib-components/Chat/BtnExpand.vue +17 -17
- package/src/lib-components/Chat/BtnFiles.vue +415 -415
- package/src/lib-components/Chat/BtnMic.vue +60 -60
- package/src/lib-components/Chat/BtnScreenShare.vue +32 -32
- package/src/lib-components/Chat/BtnStandardMessages.vue +17 -17
- package/src/lib-components/Chat/ExpandTextarea.vue +410 -410
- package/src/lib-components/Chat/MultipleFilePreview.vue +266 -266
- package/src/lib-components/Chat/Picker.vue +368 -368
- package/src/lib-components/Chat/RemainingCharacters.vue +28 -28
- package/src/lib-components/Chat/SingleFilePreview.vue +94 -94
- package/src/lib-components/Chat/SkeletonPicker.vue +110 -110
- package/src/lib-components/Chat/StandardMessages.vue +245 -245
- package/src/lib-components/Chat/TextFooter.vue +817 -817
- package/src/lib-components/Email/EmailFile.vue +125 -125
- package/src/lib-components/Email/EmailItem.vue +185 -185
- package/src/lib-components/Loader/Loader.vue +78 -78
- package/src/lib-components/Messages/AnexoMensagem.vue +385 -366
- package/src/lib-components/Messages/CardAttachment.vue +61 -61
- package/src/lib-components/Messages/CardMessages.vue +393 -393
- package/src/lib-components/Messages/ChatMessages.vue +573 -571
- package/src/lib-components/Messages/InteratividadeBotoes.vue +165 -165
- package/src/lib-components/Messages/InteratividadeFormulario.vue +392 -392
- package/src/lib-components/Messages/InteratividadePopup.vue +88 -88
- package/src/lib-components/Messages/LinkPreview.vue +163 -163
- package/src/lib-components/Scroll/ScrollContent.vue +150 -150
- package/src/lib-components/Templates/TemplateGenerator.vue +576 -576
- package/src/lib-components/Templates/TemplateMessage.vue +83 -83
- package/src/lib-components/Templates/TemplateSingle.vue +481 -481
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="interatividade-popup box-shadow" v-on-clickaway="away">
|
|
3
|
-
<div class="interatividade-popup-titulo" v-if="titulo">
|
|
4
|
-
<h1>
|
|
5
|
-
<span v-html="titulo"></span>
|
|
6
|
-
<fa-icon :icon="['fas', 'times-circle']" @click="away" />
|
|
7
|
-
</h1>
|
|
8
|
-
</div>
|
|
9
|
-
<div class="interatividade-popup-conteudo" v-for="(objItem, index) in lista" :key="index">
|
|
10
|
-
<template v-if="objItem.items && objItem.items.length">
|
|
11
|
-
<div class="interatividade-popup-item" v-for="(item, indexItem) in objItem.items" :key="`${index}${indexItem}`">
|
|
12
|
-
<p v-if="item.title" v-html="item.title" class="interatividade-popup-item-titulo"></p>
|
|
13
|
-
<p v-if="item.description" v-html="item.description" class="interatividade-popup-item-desc"></p>
|
|
14
|
-
</div>
|
|
15
|
-
</template>
|
|
16
|
-
</div>
|
|
17
|
-
</div>
|
|
18
|
-
</template>
|
|
19
|
-
|
|
20
|
-
<script>
|
|
21
|
-
import { mixin as clickaway } from 'vue-clickaway'
|
|
22
|
-
|
|
23
|
-
export default {
|
|
24
|
-
mixins: [ clickaway ],
|
|
25
|
-
props: {
|
|
26
|
-
lista: {
|
|
27
|
-
type: [Array, Object],
|
|
28
|
-
required: true
|
|
29
|
-
},
|
|
30
|
-
titulo: {
|
|
31
|
-
type: String,
|
|
32
|
-
required: false
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
methods: {
|
|
36
|
-
away() {
|
|
37
|
-
this.$emit("close")
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
<style>
|
|
44
|
-
.box-shadow {
|
|
45
|
-
-webkit-box-shadow: 0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12);
|
|
46
|
-
-moz-box-shadow: 0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12);
|
|
47
|
-
box-shadow: 0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.interatividade-popup {
|
|
51
|
-
position: absolute;
|
|
52
|
-
top: 15px;
|
|
53
|
-
right: 0;
|
|
54
|
-
width: 250px;
|
|
55
|
-
height: auto;
|
|
56
|
-
max-height: 300px;
|
|
57
|
-
overflow-y: auto;
|
|
58
|
-
overflow-x: hidden;
|
|
59
|
-
background-color: #FFF;
|
|
60
|
-
border-radius: 15px;
|
|
61
|
-
color: #333;
|
|
62
|
-
font-size: .875rem;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.interatividade-popup-titulo h1 {
|
|
66
|
-
padding: 4px 10px;
|
|
67
|
-
background-color: #333;
|
|
68
|
-
color: #FFF;
|
|
69
|
-
font-size: 1.2em;
|
|
70
|
-
display: flex;
|
|
71
|
-
justify-content: space-between;
|
|
72
|
-
align-items: center;
|
|
73
|
-
}
|
|
74
|
-
.interatividade-popup-titulo h1 svg{
|
|
75
|
-
color: #E74C3C;
|
|
76
|
-
cursor: pointer;
|
|
77
|
-
font-size: .9em;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.interatividade-popup-item {
|
|
81
|
-
padding: 10px;
|
|
82
|
-
border-bottom: 1px solid #D7D7D7;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.interatividade-popup-item-desc {
|
|
86
|
-
font-size: .9em;
|
|
87
|
-
color: #767676;
|
|
88
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<div class="interatividade-popup box-shadow" v-on-clickaway="away">
|
|
3
|
+
<div class="interatividade-popup-titulo" v-if="titulo">
|
|
4
|
+
<h1>
|
|
5
|
+
<span v-html="titulo"></span>
|
|
6
|
+
<fa-icon :icon="['fas', 'times-circle']" @click="away" />
|
|
7
|
+
</h1>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="interatividade-popup-conteudo" v-for="(objItem, index) in lista" :key="index">
|
|
10
|
+
<template v-if="objItem.items && objItem.items.length">
|
|
11
|
+
<div class="interatividade-popup-item" v-for="(item, indexItem) in objItem.items" :key="`${index}${indexItem}`">
|
|
12
|
+
<p v-if="item.title" v-html="item.title" class="interatividade-popup-item-titulo"></p>
|
|
13
|
+
<p v-if="item.description" v-html="item.description" class="interatividade-popup-item-desc"></p>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
import { mixin as clickaway } from 'vue-clickaway'
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
mixins: [ clickaway ],
|
|
25
|
+
props: {
|
|
26
|
+
lista: {
|
|
27
|
+
type: [Array, Object],
|
|
28
|
+
required: true
|
|
29
|
+
},
|
|
30
|
+
titulo: {
|
|
31
|
+
type: String,
|
|
32
|
+
required: false
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
methods: {
|
|
36
|
+
away() {
|
|
37
|
+
this.$emit("close")
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<style>
|
|
44
|
+
.box-shadow {
|
|
45
|
+
-webkit-box-shadow: 0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12);
|
|
46
|
+
-moz-box-shadow: 0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12);
|
|
47
|
+
box-shadow: 0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.interatividade-popup {
|
|
51
|
+
position: absolute;
|
|
52
|
+
top: 15px;
|
|
53
|
+
right: 0;
|
|
54
|
+
width: 250px;
|
|
55
|
+
height: auto;
|
|
56
|
+
max-height: 300px;
|
|
57
|
+
overflow-y: auto;
|
|
58
|
+
overflow-x: hidden;
|
|
59
|
+
background-color: #FFF;
|
|
60
|
+
border-radius: 15px;
|
|
61
|
+
color: #333;
|
|
62
|
+
font-size: .875rem;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.interatividade-popup-titulo h1 {
|
|
66
|
+
padding: 4px 10px;
|
|
67
|
+
background-color: #333;
|
|
68
|
+
color: #FFF;
|
|
69
|
+
font-size: 1.2em;
|
|
70
|
+
display: flex;
|
|
71
|
+
justify-content: space-between;
|
|
72
|
+
align-items: center;
|
|
73
|
+
}
|
|
74
|
+
.interatividade-popup-titulo h1 svg{
|
|
75
|
+
color: #E74C3C;
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
font-size: .9em;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.interatividade-popup-item {
|
|
81
|
+
padding: 10px;
|
|
82
|
+
border-bottom: 1px solid #D7D7D7;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.interatividade-popup-item-desc {
|
|
86
|
+
font-size: .9em;
|
|
87
|
+
color: #767676;
|
|
88
|
+
}
|
|
89
89
|
</style>
|
|
@@ -1,164 +1,164 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
v-if="linkPreview.isValid"
|
|
4
|
-
class="link-preview"
|
|
5
|
-
@click="openUrl()"
|
|
6
|
-
:title="`Abrir ${returnURL()} em uma nova guia`"
|
|
7
|
-
>
|
|
8
|
-
<div
|
|
9
|
-
v-if="linkPreview.imageSource"
|
|
10
|
-
:style="linkPreview.colorTheme ? `background-color: ${linkPreview.colorTheme}` : ''"
|
|
11
|
-
class="link-preview-image"
|
|
12
|
-
>
|
|
13
|
-
<img :src="linkPreview.imageSource" alt="Imagem referente ao link" />
|
|
14
|
-
</div>
|
|
15
|
-
<div class="link-preview-author" :class="{'mb-0' : linkPreview.description}" v-if="linkPreview.author">
|
|
16
|
-
<h1 v-text="linkPreview.author"></h1>
|
|
17
|
-
</div>
|
|
18
|
-
<div v-if="linkPreview.description" class="link-preview-infos">
|
|
19
|
-
<p v-if="linkPreview.description" v-text="linkPreview.description"></p>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
</template>
|
|
23
|
-
|
|
24
|
-
<script>
|
|
25
|
-
import { dev, baseURL } from '@/services/smartChannelAxios'
|
|
26
|
-
|
|
27
|
-
export default {
|
|
28
|
-
props: {
|
|
29
|
-
message: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: ""
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
data() {
|
|
35
|
-
return {
|
|
36
|
-
linkPreview: {
|
|
37
|
-
author: "",
|
|
38
|
-
description: "",
|
|
39
|
-
imageSource: "",
|
|
40
|
-
colorTheme: "",
|
|
41
|
-
isValid: false
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
mounted() {
|
|
46
|
-
this.$nextTick(() => { this.gerarPreview() })
|
|
47
|
-
},
|
|
48
|
-
methods: {
|
|
49
|
-
returnURL() {
|
|
50
|
-
if(!this.message) return ""
|
|
51
|
-
const isSticker = this.message.indexOf("KSTICKERK") < 0 ? false : true
|
|
52
|
-
if(isSticker) return ""
|
|
53
|
-
const regex = /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/g
|
|
54
|
-
const url = regex.exec(this.message)
|
|
55
|
-
if(!url || !url[0]) {
|
|
56
|
-
console.warn("URL invalida para gerar preview")
|
|
57
|
-
return ""
|
|
58
|
-
}
|
|
59
|
-
const finalUrl = url[0].replace(/["'*]/g, "")
|
|
60
|
-
if(/((https?|ftp):\/\/.)?(www\.)?(?:([-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6})|(linux07|linux03))\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/gi.test(finalUrl)) return finalUrl
|
|
61
|
-
return false
|
|
62
|
-
},
|
|
63
|
-
async gerarPreview() {
|
|
64
|
-
try {
|
|
65
|
-
const url = this.returnURL()
|
|
66
|
-
if(!url) return
|
|
67
|
-
const encodedURL = Buffer(url).toString("base64")
|
|
68
|
-
const response = await this.$httpRequest(
|
|
69
|
-
{
|
|
70
|
-
method: 'get',
|
|
71
|
-
url: `${baseURL}/preview?url=${encodedURL}${dev}`,
|
|
72
|
-
// headers: {
|
|
73
|
-
// Authorization: "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdGQiOiJNS1VGWnBQeEV1UHc5UXdvN21HU2tWNEl4VHN0blM3MHNyZUJTTWt3d3hiNDRhd3dDcWwxd09jIiwibWFuYWdlciI6Ik1LVXRhd3dpbTRsNXd3WW1LMWFJYXd3aW00bDV3d3d3eGI0NGF3d0s0a2pveHBPMnl6TFZ3dXBud3d4YjQ0YXd3cmxNNHRqZ3FKTExsTjMiLCJoYXNfaW5mb3MiOnRydWUsIm5yb3MiOlsiMjczIl0sImF1dGgiOiJNS1VncmxDdkdRbElGbXZVTERCSGplV0wyOXFVUHdyOVlSMVMyeXdJanlLOUNteCIsImlhdCI6MTY0ODQ3MzYxNSwiZXhwIjoxNjQ4NTYwMDE1fQ.KSG_6_9NfQhk5br7hnXzeLyVZuT69XLaEYF9XkdgmmQ"
|
|
74
|
-
// }
|
|
75
|
-
})
|
|
76
|
-
if(typeof response != "object" || typeof response.data != "object") throw "Retorno incorreto"
|
|
77
|
-
const { data } = response
|
|
78
|
-
const { st_ret, msg_ret, raspagem } = data
|
|
79
|
-
if(st_ret != "OK") throw `${st_ret} - ${msg_ret}`
|
|
80
|
-
if(!raspagem) throw `${st_ret} - ${msg_ret} | (Raspagem nao encontrada no retorno)`
|
|
81
|
-
const { description, og, theme_color } = raspagem
|
|
82
|
-
if(description) this.linkPreview.description = description
|
|
83
|
-
if(raspagem.author) this.linkPreview.author = raspagem.author
|
|
84
|
-
if(og) {
|
|
85
|
-
const { image, site_name, title, author } = og
|
|
86
|
-
if(image) this.linkPreview.imageSource = image.url ? image.url : image.url == "" ? "" : image
|
|
87
|
-
if(author || site_name || title) this.linkPreview.author = title ? title : author ? author : site_name ? site_name : ""
|
|
88
|
-
if(og.description) this.linkPreview.description = og.description
|
|
89
|
-
}
|
|
90
|
-
if(theme_color) this.linkPreview.colorTheme = theme_color
|
|
91
|
-
|
|
92
|
-
if(this.linkPreview.description || this.linkPreview.imageSource) this.linkPreview.isValid = true
|
|
93
|
-
}catch(e) {
|
|
94
|
-
console.error("Erro ao gerar o preview do link: ", e)
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
openUrl() {
|
|
98
|
-
const url = this.returnURL()
|
|
99
|
-
if(!url) return
|
|
100
|
-
window.open(url, "_blank")
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
</script>
|
|
105
|
-
|
|
106
|
-
<style scoped>
|
|
107
|
-
.link-preview {
|
|
108
|
-
display: flex;
|
|
109
|
-
flex-direction: column;
|
|
110
|
-
background-color: #EEE;
|
|
111
|
-
color: #333;
|
|
112
|
-
cursor: pointer;
|
|
113
|
-
margin: 5px 0;
|
|
114
|
-
border-radius: 5px;
|
|
115
|
-
opacity: .95;
|
|
116
|
-
transition: opacity 300ms ease-in-out;
|
|
117
|
-
font-size: .85rem;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.link-preview-image {
|
|
121
|
-
display: flex;
|
|
122
|
-
justify-content: center;
|
|
123
|
-
align-items: center;
|
|
124
|
-
padding: 1px;
|
|
125
|
-
border-top-left-radius: 5px;
|
|
126
|
-
border-top-right-radius: 5px;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
.link-preview-author {
|
|
130
|
-
margin: 5px;
|
|
131
|
-
font-size: .615em;
|
|
132
|
-
font-weight: bold;
|
|
133
|
-
}
|
|
134
|
-
.link-preview-author.mb-0 {
|
|
135
|
-
margin-bottom: 0;
|
|
136
|
-
}
|
|
137
|
-
.link-preview-author h1 {
|
|
138
|
-
overflow: hidden;
|
|
139
|
-
text-overflow: ellipsis;
|
|
140
|
-
white-space: nowrap;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.link-preview-image img {
|
|
144
|
-
min-width: 100px;
|
|
145
|
-
max-width: 200px;
|
|
146
|
-
border-top-left-radius: 5px;
|
|
147
|
-
border-top-right-radius: 5px;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.link-preview-infos {
|
|
151
|
-
background-color: #2626261a;
|
|
152
|
-
padding: 5px;
|
|
153
|
-
margin: 5px;
|
|
154
|
-
font-size: .83em;
|
|
155
|
-
border-radius: 5px;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.link-preview:hover {
|
|
159
|
-
opacity: 1;
|
|
160
|
-
}
|
|
161
|
-
.link-preview:hover .link-preview-infos p {
|
|
162
|
-
text-decoration: underline;
|
|
163
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-if="linkPreview.isValid"
|
|
4
|
+
class="link-preview"
|
|
5
|
+
@click="openUrl()"
|
|
6
|
+
:title="`Abrir ${returnURL()} em uma nova guia`"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
v-if="linkPreview.imageSource"
|
|
10
|
+
:style="linkPreview.colorTheme ? `background-color: ${linkPreview.colorTheme}` : ''"
|
|
11
|
+
class="link-preview-image"
|
|
12
|
+
>
|
|
13
|
+
<img :src="linkPreview.imageSource" alt="Imagem referente ao link" />
|
|
14
|
+
</div>
|
|
15
|
+
<div class="link-preview-author" :class="{'mb-0' : linkPreview.description}" v-if="linkPreview.author">
|
|
16
|
+
<h1 v-text="linkPreview.author"></h1>
|
|
17
|
+
</div>
|
|
18
|
+
<div v-if="linkPreview.description" class="link-preview-infos">
|
|
19
|
+
<p v-if="linkPreview.description" v-text="linkPreview.description"></p>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import { dev, baseURL } from '@/services/smartChannelAxios'
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
props: {
|
|
29
|
+
message: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: ""
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
data() {
|
|
35
|
+
return {
|
|
36
|
+
linkPreview: {
|
|
37
|
+
author: "",
|
|
38
|
+
description: "",
|
|
39
|
+
imageSource: "",
|
|
40
|
+
colorTheme: "",
|
|
41
|
+
isValid: false
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
mounted() {
|
|
46
|
+
this.$nextTick(() => { this.gerarPreview() })
|
|
47
|
+
},
|
|
48
|
+
methods: {
|
|
49
|
+
returnURL() {
|
|
50
|
+
if(!this.message) return ""
|
|
51
|
+
const isSticker = this.message.indexOf("KSTICKERK") < 0 ? false : true
|
|
52
|
+
if(isSticker) return ""
|
|
53
|
+
const regex = /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/g
|
|
54
|
+
const url = regex.exec(this.message)
|
|
55
|
+
if(!url || !url[0]) {
|
|
56
|
+
console.warn("URL invalida para gerar preview")
|
|
57
|
+
return ""
|
|
58
|
+
}
|
|
59
|
+
const finalUrl = url[0].replace(/["'*]/g, "")
|
|
60
|
+
if(/((https?|ftp):\/\/.)?(www\.)?(?:([-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6})|(linux07|linux03))\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/gi.test(finalUrl)) return finalUrl
|
|
61
|
+
return false
|
|
62
|
+
},
|
|
63
|
+
async gerarPreview() {
|
|
64
|
+
try {
|
|
65
|
+
const url = this.returnURL()
|
|
66
|
+
if(!url) return
|
|
67
|
+
const encodedURL = Buffer(url).toString("base64")
|
|
68
|
+
const response = await this.$httpRequest(
|
|
69
|
+
{
|
|
70
|
+
method: 'get',
|
|
71
|
+
url: `${baseURL}/preview?url=${encodedURL}${dev}`,
|
|
72
|
+
// headers: {
|
|
73
|
+
// Authorization: "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdGQiOiJNS1VGWnBQeEV1UHc5UXdvN21HU2tWNEl4VHN0blM3MHNyZUJTTWt3d3hiNDRhd3dDcWwxd09jIiwibWFuYWdlciI6Ik1LVXRhd3dpbTRsNXd3WW1LMWFJYXd3aW00bDV3d3d3eGI0NGF3d0s0a2pveHBPMnl6TFZ3dXBud3d4YjQ0YXd3cmxNNHRqZ3FKTExsTjMiLCJoYXNfaW5mb3MiOnRydWUsIm5yb3MiOlsiMjczIl0sImF1dGgiOiJNS1VncmxDdkdRbElGbXZVTERCSGplV0wyOXFVUHdyOVlSMVMyeXdJanlLOUNteCIsImlhdCI6MTY0ODQ3MzYxNSwiZXhwIjoxNjQ4NTYwMDE1fQ.KSG_6_9NfQhk5br7hnXzeLyVZuT69XLaEYF9XkdgmmQ"
|
|
74
|
+
// }
|
|
75
|
+
})
|
|
76
|
+
if(typeof response != "object" || typeof response.data != "object") throw "Retorno incorreto"
|
|
77
|
+
const { data } = response
|
|
78
|
+
const { st_ret, msg_ret, raspagem } = data
|
|
79
|
+
if(st_ret != "OK") throw `${st_ret} - ${msg_ret}`
|
|
80
|
+
if(!raspagem) throw `${st_ret} - ${msg_ret} | (Raspagem nao encontrada no retorno)`
|
|
81
|
+
const { description, og, theme_color } = raspagem
|
|
82
|
+
if(description) this.linkPreview.description = description
|
|
83
|
+
if(raspagem.author) this.linkPreview.author = raspagem.author
|
|
84
|
+
if(og) {
|
|
85
|
+
const { image, site_name, title, author } = og
|
|
86
|
+
if(image) this.linkPreview.imageSource = image.url ? image.url : image.url == "" ? "" : image
|
|
87
|
+
if(author || site_name || title) this.linkPreview.author = title ? title : author ? author : site_name ? site_name : ""
|
|
88
|
+
if(og.description) this.linkPreview.description = og.description
|
|
89
|
+
}
|
|
90
|
+
if(theme_color) this.linkPreview.colorTheme = theme_color
|
|
91
|
+
|
|
92
|
+
if(this.linkPreview.description || this.linkPreview.imageSource) this.linkPreview.isValid = true
|
|
93
|
+
}catch(e) {
|
|
94
|
+
console.error("Erro ao gerar o preview do link: ", e)
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
openUrl() {
|
|
98
|
+
const url = this.returnURL()
|
|
99
|
+
if(!url) return
|
|
100
|
+
window.open(url, "_blank")
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
</script>
|
|
105
|
+
|
|
106
|
+
<style scoped>
|
|
107
|
+
.link-preview {
|
|
108
|
+
display: flex;
|
|
109
|
+
flex-direction: column;
|
|
110
|
+
background-color: #EEE;
|
|
111
|
+
color: #333;
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
margin: 5px 0;
|
|
114
|
+
border-radius: 5px;
|
|
115
|
+
opacity: .95;
|
|
116
|
+
transition: opacity 300ms ease-in-out;
|
|
117
|
+
font-size: .85rem;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.link-preview-image {
|
|
121
|
+
display: flex;
|
|
122
|
+
justify-content: center;
|
|
123
|
+
align-items: center;
|
|
124
|
+
padding: 1px;
|
|
125
|
+
border-top-left-radius: 5px;
|
|
126
|
+
border-top-right-radius: 5px;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.link-preview-author {
|
|
130
|
+
margin: 5px;
|
|
131
|
+
font-size: .615em;
|
|
132
|
+
font-weight: bold;
|
|
133
|
+
}
|
|
134
|
+
.link-preview-author.mb-0 {
|
|
135
|
+
margin-bottom: 0;
|
|
136
|
+
}
|
|
137
|
+
.link-preview-author h1 {
|
|
138
|
+
overflow: hidden;
|
|
139
|
+
text-overflow: ellipsis;
|
|
140
|
+
white-space: nowrap;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.link-preview-image img {
|
|
144
|
+
min-width: 100px;
|
|
145
|
+
max-width: 200px;
|
|
146
|
+
border-top-left-radius: 5px;
|
|
147
|
+
border-top-right-radius: 5px;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.link-preview-infos {
|
|
151
|
+
background-color: #2626261a;
|
|
152
|
+
padding: 5px;
|
|
153
|
+
margin: 5px;
|
|
154
|
+
font-size: .83em;
|
|
155
|
+
border-radius: 5px;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.link-preview:hover {
|
|
159
|
+
opacity: 1;
|
|
160
|
+
}
|
|
161
|
+
.link-preview:hover .link-preview-infos p {
|
|
162
|
+
text-decoration: underline;
|
|
163
|
+
}
|
|
164
164
|
</style>
|