mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-09-04 16:23:21 +00:00
Styling update
This commit is contained in:
+17
-14
@@ -1,16 +1,29 @@
|
||||
import { registerWindowMethods } from "./testing.js";
|
||||
import { isEnvBrowser } from "./utils.js";
|
||||
import { determineStyleFromVariant, DEV_MODE, fetchNotifyConfig, NOTIFY_CONFIG } from "./config.js";
|
||||
import { determineStyleFromVariant, fetchNotifyConfig, NOTIFY_CONFIG } from "./config.js";
|
||||
|
||||
const { useQuasar } = Quasar;
|
||||
const { onMounted, onUnmounted } = Vue;
|
||||
|
||||
const fetchNui = async (evName, data) => {
|
||||
const resourceName = window.GetParentResourceName();
|
||||
|
||||
const rawResp = await fetch(`https://${resourceName}/${evName}`, {
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
"Content-Type": "application/json; charset=UTF8",
|
||||
},
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
return await rawResp.json();
|
||||
};
|
||||
|
||||
window.fetchNui = fetchNui;
|
||||
|
||||
const app = Vue.createApp({
|
||||
setup() {
|
||||
const $q = useQuasar();
|
||||
|
||||
const showNotif = async ({ data }) => {
|
||||
// Otherwise we process any old MessageEvent with a data property
|
||||
if (data?.action !== "notify") return;
|
||||
|
||||
const { text, length, type, caption, icon: dataIcon } = data;
|
||||
@@ -20,21 +33,15 @@ const app = Vue.createApp({
|
||||
icon = dataIcon;
|
||||
}
|
||||
|
||||
// Make sure we have sucessfully fetched out config properly
|
||||
if (!NOTIFY_CONFIG) {
|
||||
console.error("The notification config did not load properly, trying again for next time");
|
||||
// Lets check again to see if it exists
|
||||
await fetchNotifyConfig();
|
||||
// If we have a config lets re-run notification with same data, this
|
||||
// isn't recursive though.
|
||||
if (NOTIFY_CONFIG) return showNotif({ data });
|
||||
}
|
||||
|
||||
$q.notify({
|
||||
message: text,
|
||||
multiLine: text.length > 100,
|
||||
// If our text is larger than a 100 characters,
|
||||
// we should use multiline notifications
|
||||
group: NOTIFY_CONFIG.NotificationStyling.group ?? false,
|
||||
progress: NOTIFY_CONFIG.NotificationStyling.progress ?? true,
|
||||
position: NOTIFY_CONFIG.NotificationStyling.position ?? "right",
|
||||
@@ -56,7 +63,3 @@ const app = Vue.createApp({
|
||||
|
||||
app.use(Quasar, { config: {} });
|
||||
app.mount("#q-app");
|
||||
|
||||
if (DEV_MODE || isEnvBrowser()) {
|
||||
registerWindowMethods();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user