Files
qb-core-qbcore-fivem/html/app.js
T
Kakarot be4f57410b feat(html): New Notify System
-Replaces old notification system but is also backwards compatible so no changes necessary
- Now allows for the use of sending a table with text and caption
- Can add as many types of notifications as wanted/needed
- Configure position and icons in app,js (google icons or fontawesome)
2021-09-28 23:39:11 -06:00

64 lines
1.4 KiB
JavaScript

const { useQuasar } = Quasar;
const { onMounted, onUnmounted } = Vue;
const app = Vue.createApp({
setup() {
const $q = useQuasar();
const showNotif = (e) => {
const text = e.data.text;
const length = e.data.length;
const type = e.data.type;
const caption = e.data.caption;
switch (type) {
case 'success':
color = 'green';
icon = 'done';
break;
case 'primary':
color = 'blue';
icon = 'info';
break;
case 'error':
color = 'red';
icon = 'dangerous';
break;
case 'police':
color = 'blue';
icon = 'local_police';
break;
case 'ambulance':
color = 'red';
icon = 'fas fa-ambulance';
break;
}
if (text.length > 100) {
multiline = true;
} else {
multiline = false;
}
$q.notify({
message: text,
caption: caption,
multiLine: multiline,
color: color,
group: false,
progress: true,
position: 'right',
timeout: length,
icon: icon,
});
};
onMounted(() => {
window.addEventListener('message', showNotif);
});
onUnmounted(() => {
window.removeEventListener('message', showNotif);
});
return {};
},
});
app.use(Quasar, { config: {} });
app.mount('#q-app');