Skip to content

Commit

Permalink
feat(console): support override title via config.head
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 4, 2024
1 parent ba2315c commit 1b32ecf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/client/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ export const router = createRouter({
routes: [],
})

const initialTitle = document.title

router.afterEach((route) => {
const { name, fullPath } = router.currentRoute.value
routeCache[name] = fullPath
if (route.meta.activity) {
document.title = `${route.meta.activity.name} | ${global.messages?.title || 'Koishi 控制台'}`
document.title = `${route.meta.activity.name}`
if (initialTitle) document.title += ` | ${initialTitle}`
}
})

Expand Down
1 change: 0 additions & 1 deletion packages/online/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ root.page({
})

global.messages = {}
global.messages.title = 'Koishi Online'
global.messages.connecting = '正在初始化 Koishi Online 运行环境……'

if (!('chrome' in window)) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/console/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class NodeConsole extends Console {
const attrString = Object.entries(attrs).map(([key, value]) => ` ${key}="${h.escape(value ?? '', true)}"`).join('')
headInjection += `<${tag}${attrString}>${content ?? ''}</${tag}>`
}
return template.replace('</title>', '</title>' + headInjection)
return template.replace('<title>', headInjection + '<title>')
}

private async createVite() {
Expand Down

0 comments on commit 1b32ecf

Please sign in to comment.