Skip to content

Commit

Permalink
fix(status): do not destructure props
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Mar 10, 2021
1 parent 2c91f87 commit fbd767a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/plugin-status/client/components/bot-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import type { BotData } from '@/server'
import { defineProps } from 'vue'
const { bots } = defineProps<{ bots: BotData[] }>()
defineProps<{ bots: BotData[] }>()
</script>

Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-status/client/components/load-bar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@

<script lang="ts" setup>
import type { Rate } from '@/server'
import type { LoadRate } from '@/server'
import { defineProps, computed } from 'vue'
const { rate, title } = defineProps<{ rate: Rate, title: string }>()
const props = defineProps<{ rate: LoadRate, title: string }>()
function percentage(value: number, digits = 3) {
return (value * 100).toFixed(digits) + '%'
}
const mainly = computed(() => {
return 1 + rate[0] > 2 * rate[1] ? 'free' : 'busy'
return 1 + props.rate[0] > 2 * props.rate[1] ? 'free' : 'busy'
})
const caption = computed(() => {
return `${percentage(rate[0], 1)} / ${percentage(rate[1], 1)}`
return `${percentage(props.rate[0], 1)} / ${percentage(props.rate[1], 1)}`
})
</script>
Expand Down
15 changes: 9 additions & 6 deletions packages/plugin-status/client/components/plugin-view.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<li class="plugin-view" :class="{ 'has-children': data.children.length }">
<i class="el-icon-caret-right" :class="{ show: data.show }"/>
<span class="plugin-item" @click="data.show = !data.show" :class="state">{{ data.name }}</span>
<i class="el-icon-caret-right" :class="{ show }"/>
<span class="plugin-item" @click="show = !show" :class="state">{{ data.name }}</span>
<el-collapse-transition v-if="data.children.length">
<ul class="plugin-list" v-show="data.show">
<ul class="plugin-list" v-show="show">
<plugin-view :data="data" v-for="(data, index) in data.children" :key="index" />
</ul>
</el-collapse-transition>
Expand All @@ -12,12 +12,15 @@

<script setup lang="ts">
import { computed, defineProps } from 'vue'
import type { PluginData } from '@/server'
import { ref, computed, defineProps } from 'vue'
const { data } = defineProps(['data'])
const show = ref(false)
const props = defineProps<{ data: PluginData }>()
const state = computed(() => {
return data.sideEffect ? 'side-effect' : 'normal'
return props.data.sideEffect ? 'side-effect' : 'normal'
})
</script>
Expand Down

0 comments on commit fbd767a

Please sign in to comment.