-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclientRootMixin.js
56 lines (52 loc) · 1.51 KB
/
clientRootMixin.js
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
import QrCode from "./QrCode.vue";
import Vue from "vue";
export default {
data() {
return {
qr: null,
};
},
updated() {
// get this.$localePath
// Execute after waiting for dom to load
const navlink = document.querySelector(".nav-links");
const qrcodeBtn = document.querySelector(".qrcodeBtn");
if (navlink != null && qrcodeBtn == null) {
this.$nextTick(() => {
const navItem = document.createElement("DIV");
navItem.className += "nav-item";
navItem.appendChild(this.qr.$el);
navlink.appendChild(navItem);
});
} else if (qrcodeBtn != null) {
this.transformLabel();
this.qr.$el.querySelector('.labelText').innerText = this.currentLabel;
}
},
mounted() {
// Create qrcode component
const C = Vue.extend(QrCode);
const qr = new C();
// The following are the props of the component and some private properties
this.transformLabel();
qr.labelText = this.currentLabel;
qr.size = size;
qr.channel = channel;
qr.$mount();
this.qr = qr;
},
methods: {
transformLabel() {
this.currentLabel = "Mobile Read";
if (typeof labelText === "string") {
this.currentLabel = labelText;
} else if (typeof labelText === "object" && labelText != null) {
if (!labelText.hasOwnProperty("/")) {
console.error('Please provide at least "/" for the "labelText" ');
return;
}
this.currentLabel = labelText[this.$localePath];
}
},
},
};