Skip to content

Commit

Permalink
feat(status): support config.title
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Mar 21, 2021
1 parent 5afc5f0 commit 57e5eba
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/plugin-status/client/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ declare module '~/client' {
}

declare const KOISHI_ENDPOINT: string
declare const KOISHI_TITLE: string
declare const KOISHI_UI_PATH: string
2 changes: 1 addition & 1 deletion packages/plugin-status/client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ router.beforeEach((route) => {

router.afterEach((route) => {
if (typeof route.name === 'string') {
document.title = route.name + ' | Koishi 控制台'
document.title = `${route.name} | ${KOISHI_TITLE}`
}
})

Expand Down
1 change: 1 addition & 0 deletions packages/plugin-status/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const defaultConfig: Config = {
apiPath: '/status',
uiPath: '/console',
selfUrl: '',
title: 'Koishi 控制台',
expiration: Time.week,
tickInterval: Time.second * 5,
refreshInterval: Time.hour,
Expand Down
10 changes: 6 additions & 4 deletions packages/plugin-status/server/webui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type PluginVue from '@vitejs/plugin-vue'
export { BotData, LoadRate } from './profile'

export interface Config extends WebAdapter.Config, Profile.Config {
title?: string
selfUrl?: string
uiPath?: string
devMode?: boolean
Expand All @@ -30,12 +31,13 @@ export interface Registry {
export const name = 'webui'

export function apply(ctx: Context, config: Config = {}) {
const { apiPath, uiPath, devMode, selfUrl } = config
const { apiPath, uiPath, devMode, selfUrl, title } = config

const globalVariables = Object.entries({
KOISHI_UI_PATH: uiPath,
KOISHI_ENDPOINT: selfUrl + apiPath,
}).map(([key, value]) => `window.${key} = ${JSON.stringify(value)};`).join('\n')
TITLE: title,
UI_PATH: uiPath,
ENDPOINT: selfUrl + apiPath,
}).map(([key, value]) => `window.KOISHI_${key} = ${JSON.stringify(value)};`).join('\n')

const root = resolve(__dirname, '..', devMode ? 'client' : 'dist')

Expand Down

0 comments on commit 57e5eba

Please sign in to comment.