feat: VnLv
This commit is contained in:
parent
ea92e13b78
commit
155a0b6440
|
@ -37,8 +37,9 @@ module.exports = configure(function (/* ctx */) {
|
|||
'quasar',
|
||||
'quasar.defaults',
|
||||
'customQTh',
|
||||
'customQInput',
|
||||
'customQSelect',
|
||||
// 'customQInput',
|
||||
// 'customQSelect',
|
||||
'vnTranslate',
|
||||
],
|
||||
|
||||
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
import { boot } from 'quasar/wrappers';
|
||||
import i18n from 'src/i18n';
|
||||
import { QInput, QSelect } from 'quasar';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
|
||||
const VALID_QUASAR_ELEMENTS = [QSelect.name, QInput.name];
|
||||
const VALID_VN_ELEMENTS = [VnLv.__name];
|
||||
export default boot(({ app }) => {
|
||||
// Usar vue-i18n en la aplicación
|
||||
app.use(i18n);
|
||||
app.mixin({
|
||||
mounted() {
|
||||
this.handleElement(this.$el);
|
||||
},
|
||||
methods: {
|
||||
translateLabel(labelElement) {
|
||||
if (labelElement) {
|
||||
const labelKey = labelElement.textContent.trim();
|
||||
labelElement.textContent = this.$t(labelKey);
|
||||
}
|
||||
},
|
||||
handleElement(el) {
|
||||
if (!el) return;
|
||||
if (
|
||||
this.$options?.__name &&
|
||||
VALID_VN_ELEMENTS.includes(this.$options.__name)
|
||||
) {
|
||||
this.translateLabel(this.$el.querySelector('.label'));
|
||||
// const labelElement = this.$el.querySelector('.label');
|
||||
// if (labelElement) {
|
||||
// const labelKey = labelElement.textContent.trim();
|
||||
// labelElement.textContent = this.$t(labelKey);
|
||||
// }
|
||||
}
|
||||
// Recorrer los elementos hijos
|
||||
if (VALID_QUASAR_ELEMENTS.includes(this.$options?.name)) {
|
||||
const _children = el.children || [];
|
||||
const childrens = Array.from(_children).filter(
|
||||
(child) =>
|
||||
child.tagName === 'DIV' &&
|
||||
child.classList.contains('q-field__inner')
|
||||
);
|
||||
for (const child of childrens) {
|
||||
const input = child.querySelector('input');
|
||||
|
||||
if (
|
||||
VALID_QUASAR_ELEMENTS.includes(
|
||||
input?.__vueParentComponent?.type?.name
|
||||
)
|
||||
) {
|
||||
this.translateLabel(child.querySelector('.q-field__label'));
|
||||
// const labelElement = child.querySelector('.q-field__label');
|
||||
// if (labelElement) {
|
||||
// const labelKey = labelElement.textContent.trim();
|
||||
// labelElement.textContent = this.$t(labelKey);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue