fix: refs #7826 init

This commit is contained in:
Javier Segarra 2025-01-23 13:49:21 +01:00
parent a6adec0407
commit 31a5dd653c
5 changed files with 34 additions and 5 deletions

6
proxy-serve.js Normal file
View File

@ -0,0 +1,6 @@
export default [
{
path: '/api',
rule: { target: 'http://0.0.0.0:3000' },
},
];

View File

@ -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'

View File

@ -34,9 +34,11 @@ quasar.iconMapFn = (iconName) => {
content: iconName,
};
};
const env = process.env.BUILD_VERSION;
</script>
<template>
<meta name="app-version" :content="env" />
<RouterView />
</template>

View File

@ -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;

View File

@ -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;
});