From 31a5dd653c303eed36cb854dad46ef91ce6b1a8d Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 23 Jan 2025 13:49:21 +0100 Subject: [PATCH 1/4] fix: refs #7826 init --- proxy-serve.js | 6 ++++++ quasar.config.js | 8 ++++++-- src/App.vue | 2 ++ src/boot/quasar.js | 6 +++++- src/router/index.js | 17 +++++++++++++++-- 5 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 proxy-serve.js diff --git a/proxy-serve.js b/proxy-serve.js new file mode 100644 index 000000000..415968c85 --- /dev/null +++ b/proxy-serve.js @@ -0,0 +1,6 @@ +export default [ + { + path: '/api', + rule: { target: 'http://0.0.0.0:3000' }, + }, +]; diff --git a/quasar.config.js b/quasar.config.js index 2ea356afb..49812d847 100644 --- a/quasar.config.js +++ b/quasar.config.js @@ -55,7 +55,6 @@ export default configure(function (/* ctx */) { browser: ['es2022', 'edge88', 'firefox78', 'chrome87', 'safari13.1'], node: 'node18', }, - vueRouterMode: 'hash', // available values: 'hash', 'history' // vueRouterBase, // vueDevtools, @@ -68,6 +67,12 @@ export default configure(function (/* ctx */) { // env: {}, rawDefine: { 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), + 'process.env.BUILD_VERSION': JSON.stringify( + new Date() + .toISOString() + .replace(/[-:T.]/g, '') + .slice(0, 14), + ), // Versión con marca de tiempo }, // ignorePublicFolder: true, // minify: false, @@ -179,7 +184,6 @@ export default configure(function (/* ctx */) { 'render', // keep this as last one ], }, - // https://v2.quasar.dev/quasar-cli/developing-pwa/configuring-pwa pwa: { workboxMode: 'generateSW', // or 'injectManifest' diff --git a/src/App.vue b/src/App.vue index 27cc34c38..1ac253110 100644 --- a/src/App.vue +++ b/src/App.vue @@ -34,9 +34,11 @@ quasar.iconMapFn = (iconName) => { content: iconName, }; }; +const env = process.env.BUILD_VERSION; diff --git a/src/boot/quasar.js b/src/boot/quasar.js index 547517682..5a3e8bb29 100644 --- a/src/boot/quasar.js +++ b/src/boot/quasar.js @@ -10,7 +10,11 @@ import { useCau } from 'src/composables/useCau'; export default boot(({ app }) => { QForm.mixins = [qFormMixin]; QLayout.mixins = [mainShortcutMixin]; - + const metaVersion = process.env.BUILD_VERSION; + const storedVersion = localStorage.getItem('appVersion'); + if (metaVersion !== storedVersion) { + localStorage.setItem('appVersion', metaVersion); + } app.directive('shortcut', keyShortcut); app.config.errorHandler = async (error) => { let message; diff --git a/src/router/index.js b/src/router/index.js index 226e92c61..e3e8b6488 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -14,6 +14,7 @@ import { useTokenConfig } from 'src/composables/useTokenConfig'; import { useAcl } from 'src/composables/useAcl'; import { isLoggedIn } from 'src/utils/session'; import { useSession } from 'src/composables/useSession'; +import { Notify } from 'quasar'; let session = null; const { t, te } = i18n.global; @@ -21,8 +22,8 @@ const { t, te } = i18n.global; const createHistory = process.env.SERVER ? createMemoryHistory : process.env.VUE_ROUTER_MODE === 'history' - ? createWebHistory - : createWebHashHistory; + ? createWebHistory + : createWebHashHistory; const Router = createRouter({ scrollBehavior: () => ({ left: 0, top: 0 }), @@ -103,5 +104,17 @@ export default defineRouter(function (/* { store, ssrContext } */) { document.title = title; }); + Router.onError((error, to) => { + if ( + error.message.includes('Failed to fetch dynamically imported module') || + error.message.includes('Importing a module script failed') + ) + Notify.create({ + message: t('globals.noSelectedRows'), + type: 'negative', + timeout: 5000, + progress: true, + }); + }); return Router; }); From 0c714d2c041d838a42c692a03a6e3346cc55399b Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sat, 25 Jan 2025 09:20:07 +0100 Subject: [PATCH 2/4] feat: refs #7826 add error handling and refresh icon to NavBar --- src/components/NavBar.vue | 8 ++++++++ src/router/index.js | 13 +++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/components/NavBar.vue b/src/components/NavBar.vue index ef5bdc6ac..70793ffd6 100644 --- a/src/components/NavBar.vue +++ b/src/components/NavBar.vue @@ -63,7 +63,15 @@ onMounted(() => stateStore.setMounted());
+ {{ state }}
+ { + state.set('error', true); + }, 1000); document.title = title; }); @@ -108,13 +111,19 @@ export default defineRouter(function (/* { store, ssrContext } */) { if ( error.message.includes('Failed to fetch dynamically imported module') || error.message.includes('Importing a module script failed') - ) + ) { + state.set('error', { + message: t('globals.errorLoadingPage'), + timeout: 5000, + type: 'negative', + }); Notify.create({ message: t('globals.noSelectedRows'), type: 'negative', timeout: 5000, progress: true, }); + } }); return Router; }); From 24c62b453362385231f89e20ad820d8af857c335 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sun, 26 Jan 2025 03:16:25 +0100 Subject: [PATCH 3/4] perf: refs #7826 improve condition --- src/boot/quasar.js | 6 +----- src/components/NavBar.vue | 3 ++- src/router/index.js | 31 +++++++++---------------------- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/boot/quasar.js b/src/boot/quasar.js index 5a3e8bb29..547517682 100644 --- a/src/boot/quasar.js +++ b/src/boot/quasar.js @@ -10,11 +10,7 @@ import { useCau } from 'src/composables/useCau'; export default boot(({ app }) => { QForm.mixins = [qFormMixin]; QLayout.mixins = [mainShortcutMixin]; - const metaVersion = process.env.BUILD_VERSION; - const storedVersion = localStorage.getItem('appVersion'); - if (metaVersion !== storedVersion) { - localStorage.setItem('appVersion', metaVersion); - } + app.directive('shortcut', keyShortcut); app.config.errorHandler = async (error) => { let message; diff --git a/src/components/NavBar.vue b/src/components/NavBar.vue index 153f2f4da..c6f2375cf 100644 --- a/src/components/NavBar.vue +++ b/src/components/NavBar.vue @@ -20,6 +20,7 @@ const appName = 'Lilium'; const pinnedModulesRef = ref(); onMounted(() => stateStore.setMounted()); +const refresh = () => window.location.reload();