Skip to content

Commit

Permalink
feat: 全局配置title/footer/logo/favicon/产品名称 TencentBlueKing#10678
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 14600
  • Loading branch information
vhwweng committed Aug 8, 2024
1 parent fe46b03 commit 8ed62de
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/frontend/devops-nav/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const createRouter = (store: any, dynamicLoadModule: any, i18n: any) => {
router.beforeEach((to, from, next) => {
const serviceAlias = getServiceAliasByPath(to.path)
const currentPage = window.serviceObject.serviceMap[serviceAlias]
if (to.name !== from.name) {
if (to.name !== from.name && platformInfo) {
console.log(platformInfo, '----from store platformInfo')
document.title = currentPage
? `${currentPage.name} | ${platformInfo.i18n.name || platformInfo.name} | ${platformInfo.i18n.brandName || platformInfo.brandName}`
Expand Down
19 changes: 10 additions & 9 deletions src/frontend/devops-nav/src/utils/iframeUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ interface UrlParam {
refresh: boolean
}

interface titleParams {
title: string,
serverName: string
}

function iframeUtil (router: any) {
const utilMap: ObjectMap = {}
function init () {
Expand All @@ -32,12 +27,18 @@ function iframeUtil (router: any) {
params
}, '*')
}
utilMap.updateTabTitle = function ({ title, serverName }: titleParams): void {
utilMap.updateTabTitle = function (title: string): void {
if (title) {
document.title = title
}
if (!title && serverName) {
document.title = `${serverName} | ${platformInfo.i18n.name || platformInfo.name} | ${platformInfo.i18n.brandName || platformInfo.brandName}`
}
if (!platformInfo) return
const currentPage = window.currentPage
const platformName = platformInfo.i18n.name || platformInfo.name
const brandName = platformInfo.i18n.brandName || platformInfo.brandName
if (currentPage) {
document.title = `${currentPage.name} | ${platformName} | ${brandName}`
} else {
document.title = `${platformName} | ${brandName}`
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/devops-nav/src/views/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
}
async created () {
await this.getPlatformPreData()
const announce = await this.getAnnouncement()
if (announce && announce.id) {
this.setAnnouncement(announce)
}
this.getPlatformPreData()
}
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
'pipelineInfo.pipelineName': {
handler (val) {
const title = val ? `${val} | ${this.$t('pipeline')}` : ''
this.$updateTabTitle?.({ title })
this.$updateTabTitle?.(title)
},
immediate: true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,7 @@
},
created () {
this.$updateTabTitle?.({
serverName: this.$t('pipeline')
})
this.$updateTabTitle?.()
this.goList()
this.checkHasCreatePermission()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,7 @@
this.isLoading = val === null
if (val) {
this.$updateTabTitle?.({
title: `#${val.buildNum} ${val.buildMsg} | ${val.pipelineName}`
})
this.$updateTabTitle?.(`#${val.buildNum} ${val.buildMsg} | ${val.pipelineName}`)
}
},
'routerParams.buildNo': {
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/devops-pipeline/src/views/template/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@
},
created () {
this.$updateTabTitle?.({
serverName: this.$t('pipeline')
})
this.$updateTabTitle?.()
const { projectId, templateId } = this.$route.params
this.$store.dispatch('requestProjectDetail', { projectId })
this.$store.dispatch('pipelines/enableTemplatePermissionManage', projectId).then((res) => {
Expand Down

0 comments on commit 8ed62de

Please sign in to comment.