From 3e6a1b36aa08932a6a8973e37bd722084ace1709 Mon Sep 17 00:00:00 2001 From: Elsio Sanchez <45974454+elsiosanchez@users.noreply.github.com> Date: Tue, 4 Jun 2024 15:01:28 -0400 Subject: [PATCH] Fix: Favicon and Name Systems (#2317) * Fix: Favicon and Name Systems * Suppor Favicon in Browser Chrome * login classs * Update index.vue * Update get-page-favicon.js --------- Co-authored-by: Edwin Betancourt --- public/index.html | 3 +-- src/App.vue | 7 +++++++ src/permission.js | 4 +++- src/utils/get-page-favicon.js | 12 ++++++++++++ src/utils/get-page-title.js | 5 +++-- src/views/login/index.vue | 4 ++++ 6 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 src/utils/get-page-favicon.js diff --git a/public/index.html b/public/index.html index d2916fbd2c8..8635f1ad3f7 100644 --- a/public/index.html +++ b/public/index.html @@ -6,8 +6,7 @@ - - + <%= webpackConfig.name %> diff --git a/src/App.vue b/src/App.vue index 778a410c9a3..a391beb3b56 100644 --- a/src/App.vue +++ b/src/App.vue @@ -31,6 +31,11 @@ export default { }, defaultImageLogo() { return require('@/image/ADempiere/logo.jpg') + }, + nameSystem() { + const { name } = this.$store.getters['user/getSystem'] + if (name) return name + return 'ADempiere' } }, watch: { @@ -43,6 +48,7 @@ export default { link.rel = 'shortcut icon' link.type = 'image/x-icon' link.href = this.defaultImageLogo + document.title = this.nameSystem document.head.appendChild(link) this.$nextTick(() => { @@ -63,6 +69,7 @@ export default { link.rel = 'shortcut icon' link.type = 'image/x-icon' link.href = this.defaultImageLogo + document.title = this.nameSystem document.head.appendChild(link) }, getWindowWidth(event) { diff --git a/src/permission.js b/src/permission.js index f2cb556ba98..df21aa19291 100644 --- a/src/permission.js +++ b/src/permission.js @@ -5,6 +5,7 @@ import NProgress from 'nprogress' // progress bar import 'nprogress/nprogress.css' // progress bar style import { getToken } from '@/utils/auth' // get token from cookie import getPageTitle from '@/utils/get-page-title' +import getPageFavicon from '@/utils/get-page-favicon' import { isEmptyValue } from '@/utils/ADempiere' NProgress.configure({ showSpinner: false }) // NProgress Configuration @@ -14,7 +15,8 @@ const whiteList = ['/login', '/userEnrollment', '/createPassword', '/forgotPassw router.beforeEach(async(to, from, next) => { // start progress bar NProgress.start() - + const link = getPageFavicon() + document.head.appendChild(link) // set page title document.title = getPageTitle(to.meta.title) diff --git a/src/utils/get-page-favicon.js b/src/utils/get-page-favicon.js new file mode 100644 index 00000000000..fce8e56bdc8 --- /dev/null +++ b/src/utils/get-page-favicon.js @@ -0,0 +1,12 @@ +import store from '@/store' + +export default function getPageFavicon() { + const { logoUrl } = store.getters['user/getSystem'] + let link = document.querySelector("link[rel~='icon']") + if (!link) { + link = document.createElement('link') + link.rel = 'icon' + } + link.href = logoUrl + return link +} diff --git a/src/utils/get-page-title.js b/src/utils/get-page-title.js index 4b6604cdea8..95be78d3873 100644 --- a/src/utils/get-page-title.js +++ b/src/utils/get-page-title.js @@ -1,9 +1,10 @@ import defaultSettings from '@/settings' import i18n from '@/lang' - -const title = defaultSettings.title || 'Vue Element Admin' +import store from '@/store' export default function getPageTitle(key) { + const { name } = store.getters['user/getSystem'] + const title = name || defaultSettings.title const hasKey = i18n.te(`route.${key}`) if (hasKey) { const pageName = i18n.t(`route.${key}`) diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 5a551058621..94aaaf7cf4f 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -425,6 +425,10 @@ export default {