Skip to content

Commit

Permalink
fix(status): wait for payload available
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 13, 2023
1 parent dce4b30 commit 16c1f51
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions packages/status/client/bots/index.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template>
<k-status>
<k-status v-if="store.status">
<template #tooltip>
<span v-if="!store.profile.bots.length" class="el-popper__empty"></span>
<bot-preview v-for="(bot, key) in store.profile.bots" :key="key" :data="bot"></bot-preview>
<span v-if="!store.status.bots.length" class="el-popper__empty"></span>
<bot-preview v-for="(bot, key) in store.status.bots" :key="key" :data="bot"></bot-preview>
</template>
<status-light v-for="(bot, key) in store.profile.bots" :key="key" :class="bot.status"></status-light>
<status-light v-for="(bot, key) in store.status.bots" :key="key" :class="bot.status"></status-light>
<k-icon name="arrow-up"/>
<span>{{ sent }}/min</span>
<k-icon name="arrow-down"/>
Expand All @@ -20,11 +20,11 @@ import BotPreview from './preview.vue'
import StatusLight from './light.vue'
const sent = computed(() => {
return Object.values(store.profile.bots).reduce((acc, bot) => acc + bot.messageSent, 0)
return Object.values(store.status.bots).reduce((acc, bot) => acc + bot.messageSent, 0)
})
const received = computed(() => {
return Object.values(store.profile.bots).reduce((acc, bot) => acc + bot.messageReceived, 0)
return Object.values(store.status.bots).reduce((acc, bot) => acc + bot.messageReceived, 0)
})
</script>
Expand Down
10 changes: 5 additions & 5 deletions packages/status/client/load/index.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<template>
<k-status>
<k-status v-if="store.status">
<template #tooltip>
<div class="load">
<load-bar title="CPU" :rate="store.profile.cpu"/>
<load-bar title="内存" :rate="store.profile.memory"/>
<load-bar title="CPU" :rate="store.status.cpu"/>
<load-bar title="内存" :rate="store.status.memory"/>
</div>
</template>
CPU: {{ percentage(store.profile.cpu[1], 0) }}
内存: {{ percentage(store.profile.memory[1], 0) }}
CPU: {{ percentage(store.status.cpu[1], 0) }}
内存: {{ percentage(store.status.memory[1], 0) }}
</k-status>
</template>

Expand Down
6 changes: 3 additions & 3 deletions packages/status/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@koishijs/plugin-status",
"description": "Status view for Koishi",
"version": "7.0.0",
"version": "7.0.1",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
Expand Down Expand Up @@ -43,12 +43,12 @@
}
},
"peerDependencies": {
"@koishijs/plugin-console": "^5.1.0",
"@koishijs/plugin-console": "^5.1.1",
"koishi": "^4.11.1"
},
"devDependencies": {
"@koishijs/assets": "^1.0.1",
"@koishijs/client": "^5.1.0",
"@koishijs/client": "^5.1.1",
"echarts": "^5.4.1",
"koishi": "^4.11.1",
"vue-echarts": "^6.3.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/status/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ declare module 'koishi' {
declare module '@koishijs/plugin-console' {
namespace Console {
interface Services {
profile: ProfileProvider
status: ProfileProvider
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/status/src/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ProfileProvider extends DataService<ProfileProvider.Payload> {
cached: ProfileProvider.Payload

constructor(ctx: Context, private config: ProfileProvider.Config) {
super(ctx, 'profile')
super(ctx, 'status')

ctx.i18n.define('zh', zhCN)

Expand Down

0 comments on commit 16c1f51

Please sign in to comment.