feat: 卡片可以跳转到任务管理页面

This commit is contained in:
dhb52 2024-06-02 17:42:35 +08:00
parent 8d8d06cd35
commit 8d6140ff28
2 changed files with 17 additions and 14 deletions

View File

@ -305,7 +305,7 @@ const local: App.I18n.Schema = {
notify_recipient: '通知人', notify_recipient: '通知人',
notify_scene: '通知场景', notify_scene: '通知场景',
retry: '重试任务', retry: '重试任务',
retry_task: '重试任务', retry_task: '任务管理',
'retry_dead-letter': '死信任务', 'retry_dead-letter': '死信任务',
user: '用户管理', user: '用户管理',
user_manager: '用户信息', user_manager: '用户信息',

View File

@ -1,13 +1,14 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, nextTick, onUnmounted, reactive } from 'vue'; import { computed, nextTick, onUnmounted, reactive } from 'vue';
import { createReusableTemplate } from '@vueuse/core'; import { createReusableTemplate } from '@vueuse/core';
import { useRouter } from 'vue-router';
import { getPaletteColorByNumber } from '@sa/color'; import { getPaletteColorByNumber } from '@sa/color';
import { $t } from '@/locales'; import { $t } from '@/locales';
import { useThemeStore } from '@/store/modules/theme'; import { useThemeStore } from '@/store/modules/theme';
import { useRouterPush } from '@/hooks/common/router';
import DardRetryChart from './card-retry-chart.vue'; import DardRetryChart from './card-retry-chart.vue';
const router = useRouter(); const { routerPushByKey } = useRouterPush();
const themeStore = useThemeStore(); const themeStore = useThemeStore();
defineOptions({ defineOptions({
@ -76,8 +77,11 @@ const props = withDefaults(defineProps<Props>(), {
}) })
}); });
/** 卡片 key 类型, 与卡片的路由的 name 一致, 便于直接使用 routerPushByKey */
type KeyType = 'job_task' | 'retry_task' | 'workflow_task' | 'pods';
interface CardData { interface CardData {
key: string; key: KeyType;
title: string; title: string;
tip: string; tip: string;
value: number; value: number;
@ -92,7 +96,7 @@ interface CardData {
// eslint-disable-next-line complexity // eslint-disable-next-line complexity
const cardData = computed<CardData[]>(() => [ const cardData = computed<CardData[]>(() => [
{ {
key: 'jobTask', key: 'job_task',
title: $t('page.home.jobTask'), title: $t('page.home.jobTask'),
tip: $t('page.home.jobTaskTip'), tip: $t('page.home.jobTaskTip'),
value: props.modelValue?.jobTask.totalNum ?? 0, value: props.modelValue?.jobTask.totalNum ?? 0,
@ -121,7 +125,7 @@ const cardData = computed<CardData[]>(() => [
] ]
}, },
{ {
key: 'retryTask', key: 'retry_task',
title: $t('page.home.retryTask'), title: $t('page.home.retryTask'),
tip: $t('page.home.retryTaskTip'), tip: $t('page.home.retryTaskTip'),
value: props.modelValue?.retryTask.totalNum ?? 0, value: props.modelValue?.retryTask.totalNum ?? 0,
@ -151,7 +155,7 @@ const cardData = computed<CardData[]>(() => [
] ]
}, },
{ {
key: 'workflow', key: 'workflow_task',
title: $t('page.home.workflow'), title: $t('page.home.workflow'),
tip: $t('page.home.workflowTip'), tip: $t('page.home.workflowTip'),
value: props.modelValue?.workFlowTask.totalNum, value: props.modelValue?.workFlowTask.totalNum,
@ -181,7 +185,7 @@ const cardData = computed<CardData[]>(() => [
] ]
}, },
{ {
key: 'onlineServiceCount', key: 'pods',
title: $t('page.home.onlineServiceCount'), title: $t('page.home.onlineServiceCount'),
tip: $t('page.home.onlineServiceTip'), tip: $t('page.home.onlineServiceTip'),
value: props.modelValue?.onLineService.total ?? 0, value: props.modelValue?.onLineService.total ?? 0,
@ -232,9 +236,8 @@ function getGradientColor(color: CardData['color']) {
<NSpin :show="false"> <NSpin :show="false">
<GradientBg <GradientBg
:gradient-color="getGradientColor(item.color)" :gradient-color="getGradientColor(item.color)"
class="h-165px flex-1" class="h-165px flex-1 cursor-pointer"
:class="item.key === 'onlineServiceCount' ? 'cursor-pointer' : ''" @click="routerPushByKey(item.key)"
@click="() => (item.key === 'onlineServiceCount' ? router.push('pods') : null)"
> >
<div class="flex justify-between"> <div class="flex justify-between">
<div class="align-center flex"> <div class="align-center flex">
@ -254,7 +257,7 @@ function getGradientColor(color: CardData['color']) {
<CountTo :start-value="0" :end-value="item.value" class="text-30px text-white" /> <CountTo :start-value="0" :end-value="item.value" class="text-30px text-white" />
</div> </div>
<NProgress <NProgress
v-if="item.key === 'jobTask'" v-if="item.key === 'job_task'"
class="mb-24px h-20px pt-18px" class="mb-24px h-20px pt-18px"
type="line" type="line"
color="#728bf9" color="#728bf9"
@ -263,7 +266,7 @@ function getGradientColor(color: CardData['color']) {
indicator-text-color="#fff" indicator-text-color="#fff"
/> />
<NProgress <NProgress
v-else-if="item.key === 'workflow'" v-else-if="item.key === 'workflow_task'"
class="mb-24px h-20px pt-18px" class="mb-24px h-20px pt-18px"
type="line" type="line"
color="#728bf9" color="#728bf9"
@ -271,7 +274,7 @@ function getGradientColor(color: CardData['color']) {
:percentage="props.modelValue?.workFlowTask.successRate ?? 0" :percentage="props.modelValue?.workFlowTask.successRate ?? 0"
indicator-text-color="#fff" indicator-text-color="#fff"
/> />
<DardRetryChart v-else-if="item.key === 'retryTask'" :model-value="props.modelValue?.retryTaskBarList" /> <DardRetryChart v-else-if="item.key === 'retry_task'" :model-value="props.modelValue?.retryTaskBarList" />
<div v-else class="mb-12px h-32px"></div> <div v-else class="mb-12px h-32px"></div>
<NDivider /> <NDivider />
<template v-for="(bottomItem, bottomIndex) in item.bottom" :key="bottomIndex"> <template v-for="(bottomItem, bottomIndex) in item.bottom" :key="bottomIndex">