diff --git a/packages/plugin-status/client/index.ts b/packages/plugin-status/client/index.ts index 4feb9761e6..12f09ac28a 100644 --- a/packages/plugin-status/client/index.ts +++ b/packages/plugin-status/client/index.ts @@ -2,7 +2,7 @@ import { ref, watch } from 'vue' import type { User } from 'koishi-core' -import type { Payload } from '~/server' +import type { Registry, Profile, Statistics } from '~/server' const prefix = 'koishi:' @@ -41,7 +41,9 @@ interface Config { export const user = storage.create('user') export const config = storage.create('config', { authType: 0 }) -export const status = ref(null) +export const profile = ref(null) +export const registry = ref(null) +export const stats = ref(null) export const socket = ref(null) const listeners: Record void> = {} @@ -55,11 +57,10 @@ export function start() { listeners[data.type](data.body) } } - receive('update', data => status.value = data) - receive('user', data => { - user.value = data - storage.set('user', data) - }) + receive('profile', data => profile.value = data) + receive('registry', data => registry.value = data) + receive('stats', data => stats.value = data) + receive('user', data => user.value = data) } export function send(type: string, body: any) { diff --git a/packages/plugin-status/client/main.ts b/packages/plugin-status/client/main.ts index 4e616b9aea..b95ed8a4a1 100644 --- a/packages/plugin-status/client/main.ts +++ b/packages/plugin-status/client/main.ts @@ -26,6 +26,7 @@ declare module 'vue-router' { hidden?: boolean authorize?: boolean frameless?: boolean + require?: ('stats' | 'profile' | 'registry')[] } } @@ -36,17 +37,17 @@ const router = createRouter({ routes: [{ path: '/', name: '仪表盘', - meta: { icon: 'tachometer-alt' }, + meta: { icon: 'tachometer-alt', require: ['stats', 'profile', 'registry'] }, component: () => import('./views/home/index.vue'), }, { path: '/bots', name: '机器人', - meta: { icon: 'robot' }, + meta: { icon: 'robot', require: ['stats', 'profile'] }, component: () => import('./views/bots.vue'), }, { path: '/plugins', name: '插件', - meta: { icon: 'plug' }, + meta: { icon: 'plug', require: ['registry'] }, component: () => import('./views/plugins/index.vue'), }, { path: '/sandbox', diff --git a/packages/plugin-status/client/views/bots.vue b/packages/plugin-status/client/views/bots.vue index 97e101a098..4b1b3da842 100644 --- a/packages/plugin-status/client/views/bots.vue +++ b/packages/plugin-status/client/views/bots.vue @@ -1,6 +1,6 @@