vue-intergrall-plugins 0.0.189 → 0.0.192

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-intergrall-plugins",
3
- "version": "0.0.189",
3
+ "version": "0.0.192",
4
4
  "description": "",
5
5
  "main": "dist/vue-intergrall-plugins.ssr.js",
6
6
  "browser": "dist/vue-intergrall-plugins.esm.js",
@@ -6,6 +6,7 @@
6
6
  :dictionary="dictionary"
7
7
  />
8
8
  <div v-else class="mensagem" :class="{mapa, 'hist-msg' : histMsg}">
9
+ <LinkPreview v-if="link && !mapa" :message="message" />
9
10
  <template v-if="anexos && anexos.length">
10
11
  <div class="mensagem-anexo" v-for="(anexo, index) in anexos" :key="index">
11
12
  <AnexoMensagem :dictionary="dictionary" :anexo="anexo" :origemExterna="origemExterna" :dominio="dominio" @abrir-imagem="abrirImagem"/>
@@ -60,7 +61,7 @@
60
61
  <span class="check vermelho" v-else-if="status == 'T'" :content="contentTooltip" v-tippy key="hourglass"> <fa-icon :icon="['fas', 'hourglass']" /> </span> <!-- Status finalizador -->
61
62
  </transition>
62
63
 
63
- <span class="autor-mensagem" v-html="autor"></span>
64
+ <span class="autor-mensagem" v-text="autor"></span>
64
65
  </div>
65
66
  </div>
66
67
  </template>
@@ -70,9 +71,10 @@ import AnexoMensagem from "./AnexoMensagem"
70
71
  import InteratividadeBotoes from "./InteratividadeBotoes"
71
72
  import InteratividadeFormulario from "./InteratividadeFormulario"
72
73
  import { formataTimezoneData } from "../../services/textFormatting"
74
+ import LinkPreview from './LinkPreview'
73
75
 
74
76
  export default {
75
- components: { AnexoMensagem, InteratividadeBotoes, InteratividadeFormulario },
77
+ components: { AnexoMensagem, InteratividadeBotoes, InteratividadeFormulario, LinkPreview },
76
78
  props: ["smartchannel", "messageIndex", "dictionary", "autor", "origem", "msg", "link", "anexo", "imgAnexo", "tipoDoc", "docAnexo", "nomeArquivo", "audio", "video", "horario", "status", "logo", "msgTooltip", "seq", "mapa", "histMsg", "erro", "msgErro", "origemExterna", "anexos", "dominio", "corMsg", "interatividade", "msgReply", "hasReply", "iniDialogo", "dialogoId", "dialogoOrigem", "expSessao"],
77
79
  data(){
78
80
  return{
@@ -409,9 +411,9 @@ export default {
409
411
  left: -10px;
410
412
  transform: rotate(90deg);
411
413
  }
412
- /* .mensagem__outros .check{
414
+ .mensagem__outros .check{
413
415
  display: none
414
- } */
416
+ }
415
417
  .mensagem__outros > .autor-mensagem{
416
418
  left: 5px;
417
419
  color: #333;
@@ -0,0 +1,103 @@
1
+ <template>
2
+ <div v-if="linkPreview.isValid" class="link-preview">
3
+ <div
4
+ v-if="linkPreview.imageSource"
5
+ :style="linkPreview.colorTheme ? `background-color: ${linkPreview.colorTheme}` : ''"
6
+ class="link-preview-image"
7
+ >
8
+ <img :src="linkPreview.imageSource" alt="Imagem referente ao link" />
9
+ </div>
10
+ <div v-if="linkPreview.description" class="link-preview-infos">
11
+ <p v-if="linkPreview.description" v-text="linkPreview.description"></p>
12
+ </div>
13
+ </div>
14
+ </template>
15
+
16
+ <script>
17
+ import { dev, baseURL } from '@/services/smartChannelAxios'
18
+
19
+ export default {
20
+ props: {
21
+ message: {
22
+ type: String,
23
+ default: ""
24
+ }
25
+ },
26
+ data() {
27
+ return {
28
+ linkPreview: {
29
+ description: "",
30
+ imageSource: "",
31
+ colorTheme: "",
32
+ isValid: false
33
+ }
34
+ }
35
+ },
36
+ mounted() {
37
+ this.$nextTick(() => { this.gerarPreview() })
38
+ },
39
+ methods: {
40
+ async gerarPreview() {
41
+ try {
42
+ if(!this.message) return
43
+ const isSticker = this.message.indexOf("KSTICKERK") < 0 ? false : true
44
+ if(isSticker) return
45
+ 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
46
+ const url = regex.exec(this.message)
47
+ if(!url || !url[0]) return console.warn("URL invalida para gerar preview")
48
+ const encodedURL = Buffer(url[0]).toString("base64")
49
+ const response = await this.$httpRequest(
50
+ {
51
+ method: 'get',
52
+ url: `${baseURL}/preview?url=${encodedURL}${dev}`,
53
+ // headers: {
54
+ // Authorization: "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdGQiOiJNS1VuNENMdFVlYTVZeDA4VmltQmgwQWN6Rkp0Y3pIUjZBTXd3eGI0NGF3d1ZTTTh2ZFhPS1pnIiwibWFuYWdlciI6Ik1LVVZkRm8zWmFreGJOUHd6bjNBRjVmVnF1MmVReFEyTUh2ZVloZ3V3SzJMbzU1IiwiaGFzX2luZm9zIjp0cnVlLCJucm9zIjpbIjEwIiwiMjYzIl0sImF1dGgiOiJNS1U3YzZNQnBJWTkyamFKbFZJTXQxd3dpbTRsNXd3Mjc4SU0wdkpRT0JnV3lTeHZZM3k0dmRYIiwiaWF0IjoxNjQ4MTQ2MzEwLCJleHAiOjE2NDgyMzI3MTB9.JSgv4e0DY0gkWaz6u9yBSH2P507zBZoTRKf9ki7TP_M"
55
+ // }
56
+ })
57
+ if(typeof response != "object" || typeof response.data != "object") throw "Retorno incorreto"
58
+ const { data } = response
59
+ const { st_ret, msg_ret, raspagem } = data
60
+ if(st_ret != "OK") throw `${st_ret} - ${msg_ret}`
61
+ if(!raspagem) throw `${st_ret} - ${msg_ret} | (Raspagem nao encontrada no retorno)`
62
+ const { description, og, theme_color } = raspagem
63
+ if(description) this.linkPreview.description = description
64
+ if(og && og.image) this.linkPreview.imageSource = og.image
65
+ if(theme_color) this.linkPreview.colorTheme = theme_color
66
+
67
+ if(this.linkPreview.description || this.linkPreview.imageSource) this.linkPreview.isValid = true
68
+ }catch(e) {
69
+ console.error("Erro ao gerar o preview do link: ", e)
70
+ }
71
+ },
72
+
73
+ }
74
+ }
75
+ </script>
76
+
77
+ <style scoped>
78
+ .link-preview {
79
+ display: flex;
80
+ flex-direction: column;
81
+ background-color: #EEE;
82
+ color: #333;
83
+ }
84
+
85
+ .link-preview-image {
86
+ display: flex;
87
+ justify-content: center;
88
+ align-items: center;
89
+ padding: 10px;
90
+ }
91
+
92
+ .link-preview-image img {
93
+ min-width: 100px;
94
+ max-width: 200px;
95
+ }
96
+
97
+ .link-preview-infos {
98
+ background-color: rgba(38, 38, 38, 10%);
99
+ padding: 5px;
100
+ margin: 5px;
101
+ font-size: .8rem;
102
+ }
103
+ </style>