vue-intergrall-plugins 0.0.187 → 0.0.190

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.187",
3
+ "version": "0.0.190",
4
4
  "description": "",
5
5
  "main": "dist/vue-intergrall-plugins.ssr.js",
6
6
  "browser": "dist/vue-intergrall-plugins.esm.js",
@@ -61,7 +61,6 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "axios": "^0.26.0",
64
- "kind-of": "^6.0.3",
65
- "link-prevue": "^1.2.0"
64
+ "kind-of": "^6.0.3"
66
65
  }
67
66
  }
@@ -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"/>
@@ -29,7 +30,6 @@
29
30
  </li>
30
31
  </ul>
31
32
  </div>
32
- <!-- <LinkPrevue v-if="linkPreview && link" :url="linkPreview" /> -->
33
33
  <p v-html="validateInterativity() ? '' : formatMsg(message)"></p>
34
34
  <InteratividadeBotoes
35
35
  v-if="interatividade"
@@ -71,10 +71,10 @@ import AnexoMensagem from "./AnexoMensagem"
71
71
  import InteratividadeBotoes from "./InteratividadeBotoes"
72
72
  import InteratividadeFormulario from "./InteratividadeFormulario"
73
73
  import { formataTimezoneData } from "../../services/textFormatting"
74
- import LinkPrevue from "link-prevue"
74
+ import LinkPreview from './LinkPreview'
75
75
 
76
76
  export default {
77
- components: { AnexoMensagem, InteratividadeBotoes, InteratividadeFormulario, LinkPrevue },
77
+ components: { AnexoMensagem, InteratividadeBotoes, InteratividadeFormulario, LinkPreview },
78
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"],
79
79
  data(){
80
80
  return{
@@ -95,8 +95,7 @@ export default {
95
95
  rotateControl: false,
96
96
  fullscreenControl: false,
97
97
  disableDefaultUI: false
98
- },
99
- linkPreview: ""
98
+ }
100
99
  }
101
100
  },
102
101
  computed: {
@@ -171,7 +170,7 @@ export default {
171
170
  this.message = this.removeUrlStickerByString(this.urlSticker)
172
171
  }
173
172
  } catch (error) {
174
-
173
+ console.error("Error validating url to msg: ", error)
175
174
  }
176
175
  },
177
176
  getUrlFileName(){
@@ -189,10 +188,8 @@ export default {
189
188
  return url;
190
189
  },
191
190
  validadeIfExistsSticker(){
192
- if(this.message && this.message.indexOf("KSTICKERK https://smarters") === 0){
193
- return true;
194
- }
195
- return false;
191
+ if(this.message && this.message.indexOf("KSTICKERK https://") === 0) return true
192
+ return false
196
193
  },
197
194
  setCorMsg() {
198
195
  try {
@@ -231,7 +228,6 @@ export default {
231
228
  formatMsg(msg) {
232
229
  const regex = /(\n|&nbsp;)/g
233
230
  if(regex.test(msg)) msg = msg.replace(regex, "<br>")
234
- // if(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/gi.test(msg) && this.link) this.setLinkPreview(msg)
235
231
  return msg
236
232
  },
237
233
  }
@@ -0,0 +1,99 @@
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[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
+ }
82
+
83
+ .link-preview-image {
84
+ display: flex;
85
+ justify-content: center;
86
+ align-items: center;
87
+ padding: 10px;
88
+ }
89
+
90
+ .link-preview-image img {
91
+ max-width: 250px;
92
+ }
93
+
94
+ .link-preview-infos {
95
+ background-color: rgba(0, 0, 0, .1);
96
+ padding: 10px;
97
+ font-size: .8rem;
98
+ }
99
+ </style>