0
0
Fork 0

Page title

This commit is contained in:
Joan Sanchez 2022-03-14 10:36:52 +01:00
parent 847cb64ab7
commit 0590a7642f
5 changed files with 54 additions and 11 deletions

View File

@ -85,6 +85,7 @@ module.exports = {
'@typescript-eslint/no-unsafe-assignment': 'off', '@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-floating-promises': 'off', '@typescript-eslint/no-floating-promises': 'off',
// allow debugger during development only // allow debugger during development only

View File

@ -3,12 +3,14 @@ import { createI18n } from 'vue-i18n';
import messages from 'src/i18n'; import messages from 'src/i18n';
export default boot(({ app }) => { const i18n = createI18n({
const i18n = createI18n({ locale: 'en',
locale: 'en', messages,
messages, });
});
export default boot(({ app }) => {
// Set i18n instance on app // Set i18n instance on app
app.use(i18n); app.use(i18n);
}); });
export { i18n };

View File

@ -1,15 +1,15 @@
export default { export default {
'globals': { globals: {
'lang': { lang: {
'es': 'Spanish', 'es': 'Spanish',
'en': 'English' 'en': 'English'
} }
}, },
'errors': { errors: {
'statusUnauthorized': 'Access denied', 'statusUnauthorized': 'Access denied',
'statusInternalServerError': 'An internal server error has ocurred' 'statusInternalServerError': 'An internal server error has ocurred'
}, },
'login': { login: {
'title': 'Login', 'title': 'Login',
'username': 'Username', 'username': 'Username',
'password': 'Password', 'password': 'Password',
@ -18,12 +18,18 @@ export default {
'loginSuccess': 'You have successfully logged in', 'loginSuccess': 'You have successfully logged in',
'loginError': 'Invalid username or password' 'loginError': 'Invalid username or password'
}, },
'customer': {}, customer: {},
'components': { components: {
'topbar': {}, 'topbar': {},
'userPanel': { 'userPanel': {
'settings': 'Settings', 'settings': 'Settings',
'logOut': 'Log Out' 'logOut': 'Log Out'
} }
},
pages: {
'logIn': 'Log In',
'dashboard': 'Dashboard',
'customers': 'Customers',
'list': 'List',
} }
}; };

View File

@ -6,6 +6,7 @@ import {
createWebHistory, createWebHistory,
} from 'vue-router'; } from 'vue-router';
import routes from './routes'; import routes from './routes';
import { i18n } from 'src/boot/i18n';
import { useSession } from 'src/composables/useSession'; import { useSession } from 'src/composables/useSession';
const session = useSession(); const session = useSession();
/* /*
@ -47,5 +48,34 @@ export default route(function (/* { store, ssrContext } */) {
} }
}); });
Router.afterEach((to) => {
interface Meta {
title?: string;
}
const { t } = i18n.global;
let title = '';
const parent = to.matched[1];
if (parent) {
const parentMeta: Meta = parent.meta;
if (parentMeta && parentMeta.title) {
title += t(`pages.${parentMeta.title}`);
}
}
//const childTitle: string = childMeta.title;
const childMeta: Meta = to.meta;
if (childMeta && childMeta.title) {
if (title != '') title += ' - ';
title += t(`pages.${childMeta.title}`);
}
document.title = title;
});
return Router; return Router;
}); });

View File

@ -4,6 +4,7 @@ const routes: RouteRecordRaw[] = [
{ {
path: '/login', path: '/login',
name: 'Login', name: 'Login',
meta: { title: 'logIn' },
component: () => import('../pages/Login/Login.vue'), component: () => import('../pages/Login/Login.vue'),
}, },
{ {
@ -15,17 +16,20 @@ const routes: RouteRecordRaw[] = [
{ {
path: '/dashboard', path: '/dashboard',
name: 'Dashboard', name: 'Dashboard',
meta: { title: 'dashboard' },
component: () => import('../pages/Dashboard/Dashboard.vue'), component: () => import('../pages/Dashboard/Dashboard.vue'),
}, },
{ {
path: '/customer', path: '/customer',
name: 'Customer', name: 'Customer',
meta: { title: 'customers' },
component: () => import('../pages/Customer/Customer.vue'), component: () => import('../pages/Customer/Customer.vue'),
redirect: { name: 'List' }, redirect: { name: 'List' },
children: [ children: [
{ {
path: 'list', path: 'list',
name: 'List', name: 'List',
meta: { title: 'list' },
component: () => import('../pages/Customer/List.vue'), component: () => import('../pages/Customer/List.vue'),
}, },
{ {