perf: remove unused parameter in content-slog

This commit is contained in:
Lykin 2024-01-17 15:48:23 +08:00
parent 7fecbc2b53
commit ffed68ae4c
4 changed files with 17 additions and 18 deletions

View File

@ -2456,8 +2456,8 @@ func (b *browserService) CleanCmdHistory() (resp types.JSResp) {
}
// GetSlowLogs get slow log list
func (b *browserService) GetSlowLogs(server string, db int, num int64) (resp types.JSResp) {
item, err := b.getRedisClient(server, db)
func (b *browserService) GetSlowLogs(server string, num int64) (resp types.JSResp) {
item, err := b.getRedisClient(server, -1)
if err != nil {
resp.Msg = err.Error()
return

View File

@ -17,6 +17,7 @@ import ContentSlog from '@/components/content_value/ContentSlog.vue'
import { decodeTypes, formatTypes } from '@/consts/value_view_type.js'
import ContentMonitor from '@/components/content_value/ContentMonitor.vue'
import { decodeRedisKey } from '@/utils/key_convert.js'
import ContentPubsub from '@/components/content_value/ContentPubsub.vue'
const themeVars = useThemeVars()
@ -159,7 +160,7 @@ watch(
</n-tab-pane>
<!-- slow log pane -->
<n-tab-pane :name="BrowserTabType.SlowLog.toString()" display-directive="if">
<n-tab-pane :name="BrowserTabType.SlowLog.toString()" display-directive="show:lazy">
<template #tab>
<n-space :size="5" :wrap-item="false" align="center" inline justify="center">
<n-icon size="16">
@ -171,7 +172,7 @@ watch(
<span>{{ $t('interface.sub_tab.slow_log') }}</span>
</n-space>
</template>
<content-slog :db="tabContent.db" :server="props.server" />
<content-slog :server="props.server" />
</n-tab-pane>
<!-- command monitor pane -->
@ -191,7 +192,7 @@ watch(
</n-tab-pane>
<!-- pub/sub message pane -->
<n-tab-pane :disabled="true" :name="BrowserTabType.PubMessage.toString()">
<n-tab-pane :name="BrowserTabType.PubMessage.toString()" display-directive="show:lazy">
<template #tab>
<n-space :size="5" :wrap-item="false" align="center" inline justify="center">
<n-icon size="16">
@ -203,6 +204,7 @@ watch(
<span>{{ $t('interface.sub_tab.pub_message') }}</span>
</n-space>
</template>
<content-pubsub :server="props.server" />
</n-tab-pane>
</n-tabs>
</div>

View File

@ -3,7 +3,7 @@ import { computed, h, nextTick, onMounted, onUnmounted, reactive, ref } from 'vu
import Refresh from '@/components/icons/Refresh.vue'
import { debounce, isEmpty, map, size, split } from 'lodash'
import { useI18n } from 'vue-i18n'
import { useThemeVars } from 'naive-ui'
import { NIcon, useThemeVars } from 'naive-ui'
import dayjs from 'dayjs'
import useBrowserStore from 'stores/browser.js'
import { timeout } from '@/utils/promise.js'
@ -17,10 +17,6 @@ const props = defineProps({
server: {
type: String,
},
db: {
type: Number,
default: 0,
},
})
const autoRefresh = reactive({
@ -127,7 +123,7 @@ const columns = computed(() => [
const _loadSlowLog = () => {
data.loading = true
browserStore
.getSlowLog(props.server, props.db, data.listLimit)
.getSlowLog(props.server, data.listLimit)
.then((list) => {
data.list = list || []
})
@ -194,10 +190,12 @@ const onListLimitChanged = (limit) => {
<template #trigger>
<n-button :loading="data.loading" circle size="small" tertiary @click="_loadSlowLog">
<template #icon>
<n-icon :size="props.size">
<refresh
:class="{ 'auto-rotate': autoRefresh.on }"
:color="autoRefresh.on ? themeVars.primaryColor : undefined"
:stroke-width="autoRefresh.on ? 6 : 3" />
</n-icon>
</template>
</n-button>
</template>

View File

@ -1884,13 +1884,12 @@ const useBrowserStore = defineStore('browser', {
/**
* get slow log list
* @param {string} server
* @param {number} db
* @param {number} num
* @return {Promise<[]>}
*/
async getSlowLog(server, db, num) {
async getSlowLog(server, num) {
try {
const { success, data = { list: [] } } = await GetSlowLogs(server, db, num)
const { success, data = { list: [] } } = await GetSlowLogs(server, num)
const { list } = data
return list
} catch {