From 28557e07aaa097647da1d44a997e0935f6bbae15 Mon Sep 17 00:00:00 2001 From: Thanit Konmek Date: Tue, 6 Jun 2023 20:33:39 +0700 Subject: [PATCH] loader plugin --- src/main.ts | 6 +++++- src/stores/mixin.ts | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 75fead11e..75f42502e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,7 @@ import { createApp, defineAsyncComponent } from "vue"; import App from "./App.vue"; import router from "./router"; -import { Dialog, Notify, Quasar } from "quasar"; +import { Dialog, Notify, Quasar, Loading } from "quasar"; import quasarUserOptions from "./quasar-user-options"; import "quasar/src/css/index.sass"; @@ -36,11 +36,15 @@ app.use( plugins: { Notify, Dialog, + Loading, }, // import Quasar plugins and add here config: { notify: { /* look at QuasarConfOptions from the API card */ }, + loading: { + /* look at QuasarConfOptions from the API card */ + }, }, lang: th, } diff --git a/src/stores/mixin.ts b/src/stores/mixin.ts index 8acdfbda7..3c44d4624 100644 --- a/src/stores/mixin.ts +++ b/src/stores/mixin.ts @@ -1,6 +1,7 @@ import { defineStore } from "pinia"; import moment from "moment"; import CustomComponent from "@/components/CustomDialog.vue"; +import { Loading, QSpinnerCube } from "quasar"; export const useCounterMixin = defineStore("mixin", () => { /** @@ -408,6 +409,20 @@ export const useCounterMixin = defineStore("mixin", () => { }); }; + const showLoader = () => { + Loading.show({ + spinner: QSpinnerCube, + spinnerSize: 140, + spinnerColor: "primary", + backgroundColor: "white", + }); + }; + + const hideLoader = () => { + // q.loading.hide(); + Loading.hide(); + }; + function modalDelete( q: any, title: string, @@ -615,5 +630,7 @@ export const useCounterMixin = defineStore("mixin", () => { modalError, dialogMessage, messageError, + showLoader, + hideLoader, }; });