feat(工作台): 工作台可视化暗黑主题

This commit is contained in:
xinxin.wu 2024-12-17 19:00:19 +08:00 committed by Craftsman
parent 773acd7937
commit a4bac8a86a
12 changed files with 343 additions and 163 deletions

View File

@ -0,0 +1,61 @@
import useAppStore from '@/store/modules/app';
const appStore = useAppStore();
const colorThemeConfig: Record<string, any> = {
xLabelColor: {
dark: '#C0C2CF',
bright: '#646466',
},
legendColor: {
dark: '#E3E6F3',
bright: '#323233',
},
splitLineColor: {
dark: '#434552',
bright: '#EDEDF1',
},
yLabelColor: {
dark: '#90929F',
bright: '#AEAEB2',
},
subtextStyleColor: {
dark: '#90929F',
bright: '#323233',
},
itemStyleBorderColor: {
dark: '#242633',
bright: '#ffffff',
},
initItemStyleColor: {
dark: '#434552',
bright: '#D4D4D8',
},
pageIconColor: {
dark: '#959598',
bright: '#959598',
},
pageIconInactiveColor: {
dark: '#959598',
bright: '#C7C7CB',
},
pageTextStyleColor: {
dark: '#C7C7CB',
bright: '#959598',
},
graphicBackgroundColor: {
dark: '#ADB0BC',
bright: '#F9F9FE',
},
graphicFillColor: {
dark: '#242633',
bright: '#959598',
},
};
function getVisualThemeColor(key: string): string {
const theme = appStore.isDarkTheme ? 'dark' : 'bright';
return colorThemeConfig[key]?.[theme];
}
export default getVisualThemeColor;

View File

@ -1,5 +1,6 @@
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
import getVisualThemeColor from '@/config/chartTheme';
import { commonConfig, toolTipConfig } from '@/config/testPlan'; import { commonConfig, toolTipConfig } from '@/config/testPlan';
import type { ModuleCardItem } from '@/models/workbench/homePage'; import type { ModuleCardItem } from '@/models/workbench/homePage';
@ -145,12 +146,13 @@ export const defaultLegacy = [
}, },
]; ];
export const defaultValueMap: Record<string, any> = { export const defaultValueMap = (): Record<string, any> => {
return {
// 用例数量 // 用例数量
[WorkCardEnum.CASE_COUNT]: { [WorkCardEnum.CASE_COUNT]: {
review: { review: {
defaultList: cloneDeep(defaultCover), defaultList: cloneDeep(defaultCover),
color: ['#00C261', '#D4D4D8'], color: ['#00C261', getVisualThemeColor('initItemStyleColor')],
defaultName: 'workbench.homePage.reviewRate', defaultName: 'workbench.homePage.reviewRate',
}, },
pass: { pass: {
@ -163,7 +165,7 @@ export const defaultValueMap: Record<string, any> = {
[WorkCardEnum.ASSOCIATE_CASE_COUNT]: { [WorkCardEnum.ASSOCIATE_CASE_COUNT]: {
cover: { cover: {
defaultList: cloneDeep(defaultCover), defaultList: cloneDeep(defaultCover),
color: ['#00C261', '#D4D4D8'], color: ['#00C261', getVisualThemeColor('initItemStyleColor')],
defaultName: 'workbench.homePage.coverRate', defaultName: 'workbench.homePage.coverRate',
}, },
}, },
@ -171,7 +173,7 @@ export const defaultValueMap: Record<string, any> = {
[WorkCardEnum.REVIEW_CASE_COUNT]: { [WorkCardEnum.REVIEW_CASE_COUNT]: {
cover: { cover: {
defaultList: cloneDeep(defaultCover), defaultList: cloneDeep(defaultCover),
color: ['#00C261', '#D4D4D8'], color: ['#00C261', getVisualThemeColor('initItemStyleColor')],
defaultName: 'workbench.homePage.coverRate', defaultName: 'workbench.homePage.coverRate',
}, },
}, },
@ -179,17 +181,17 @@ export const defaultValueMap: Record<string, any> = {
[WorkCardEnum.TEST_PLAN_COUNT]: { [WorkCardEnum.TEST_PLAN_COUNT]: {
execute: { execute: {
defaultList: cloneDeep(defaultExecution), defaultList: cloneDeep(defaultExecution),
color: ['#D4D4D8', '#00C261'], color: [getVisualThemeColor('initItemStyleColor'), '#00C261'],
defaultName: 'workbench.homePage.executeRate', defaultName: 'workbench.homePage.executeRate',
}, },
pass: { pass: {
defaultList: cloneDeep(defaultPass), defaultList: cloneDeep(defaultPass),
color: ['#00C261', '#D4D4D8'], color: ['#00C261', getVisualThemeColor('initItemStyleColor')],
defaultName: 'workbench.homePage.passRate', defaultName: 'workbench.homePage.passRate',
}, },
complete: { complete: {
defaultList: cloneDeep(defaultComplete), defaultList: cloneDeep(defaultComplete),
color: ['#D4D4D8', '#3370FF', '#00C261', '#FF9964'], color: [getVisualThemeColor('initItemStyleColor'), '#3370FF', '#00C261', '#FF9964'],
defaultName: 'workbench.homePage.completeRate', defaultName: 'workbench.homePage.completeRate',
}, },
}, },
@ -197,7 +199,7 @@ export const defaultValueMap: Record<string, any> = {
[WorkCardEnum.PLAN_LEGACY_BUG]: { [WorkCardEnum.PLAN_LEGACY_BUG]: {
legacy: { legacy: {
defaultList: cloneDeep(defaultLegacy), defaultList: cloneDeep(defaultLegacy),
color: ['#00C261', '#D4D4D8'], color: ['#00C261', getVisualThemeColor('initItemStyleColor')],
defaultName: 'workbench.homePage.legacyRate', defaultName: 'workbench.homePage.legacyRate',
}, },
}, },
@ -205,7 +207,7 @@ export const defaultValueMap: Record<string, any> = {
[WorkCardEnum.BUG_COUNT]: { [WorkCardEnum.BUG_COUNT]: {
legacy: { legacy: {
defaultList: cloneDeep(defaultLegacy), defaultList: cloneDeep(defaultLegacy),
color: ['#00C261', '#D4D4D8'], color: ['#00C261', getVisualThemeColor('initItemStyleColor')],
defaultName: 'workbench.homePage.legacyRate', defaultName: 'workbench.homePage.legacyRate',
}, },
}, },
@ -213,7 +215,7 @@ export const defaultValueMap: Record<string, any> = {
[WorkCardEnum.HANDLE_BUG_BY_ME]: { [WorkCardEnum.HANDLE_BUG_BY_ME]: {
legacy: { legacy: {
defaultList: cloneDeep(defaultLegacy), defaultList: cloneDeep(defaultLegacy),
color: ['#00C261', '#D4D4D8'], color: ['#00C261', getVisualThemeColor('initItemStyleColor')],
defaultName: 'workbench.homePage.legacyRate', defaultName: 'workbench.homePage.legacyRate',
}, },
}, },
@ -221,12 +223,12 @@ export const defaultValueMap: Record<string, any> = {
[WorkCardEnum.API_COUNT]: { [WorkCardEnum.API_COUNT]: {
cover: { cover: {
defaultList: cloneDeep(defaultCover), defaultList: cloneDeep(defaultCover),
color: ['#00C261', '#D4D4D8'], color: ['#00C261', getVisualThemeColor('initItemStyleColor')],
defaultName: 'workbench.homePage.coverRate', defaultName: 'workbench.homePage.coverRate',
}, },
complete: { complete: {
defaultList: cloneDeep(defaultComplete), defaultList: cloneDeep(defaultComplete),
color: ['#00C261', '#3370FF', '#D4D4D8'], color: ['#00C261', '#3370FF', getVisualThemeColor('initItemStyleColor')],
defaultName: 'workbench.homePage.completeRate', defaultName: 'workbench.homePage.completeRate',
}, },
}, },
@ -234,10 +236,11 @@ export const defaultValueMap: Record<string, any> = {
[WorkCardEnum.CREATE_BUG_BY_ME]: { [WorkCardEnum.CREATE_BUG_BY_ME]: {
legacy: { legacy: {
defaultList: cloneDeep(defaultLegacy), defaultList: cloneDeep(defaultLegacy),
color: ['#00C261', '#D4D4D8'], color: ['#00C261', getVisualThemeColor('initItemStyleColor')],
defaultName: 'workbench.homePage.legacyRate', defaultName: 'workbench.homePage.legacyRate',
}, },
}, },
};
}; };
// XX率饼图配置 // XX率饼图配置
@ -257,7 +260,7 @@ export const commonRatePieOptions = {
subtext: '0', subtext: '0',
subtextStyle: { subtextStyle: {
fontSize: 12, fontSize: 12,
color: '#323233', color: getVisualThemeColor('subtextStyleColor'),
fontWeight: 'bold', fontWeight: 'bold',
align: 'center', align: 'center',
lineHeight: 3, lineHeight: 3,

View File

@ -90,6 +90,7 @@
import RatioPie from './ratioPie.vue'; import RatioPie from './ratioPie.vue';
import { workApiCaseCountDetail, workApiCountCoverRage, workScenarioCaseCountDetail } from '@/api/modules/workbench'; import { workApiCaseCountDetail, workApiCountCoverRage, workScenarioCaseCountDetail } from '@/api/modules/workbench';
import getVisualThemeColor from '@/config/chartTheme';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useOpenNewPage from '@/hooks/useOpenNewPage'; import useOpenNewPage from '@/hooks/useOpenNewPage';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
@ -196,7 +197,7 @@
const coverTitleConfig = computed(() => { const coverTitleConfig = computed(() => {
return { return {
name: t('workbench.homePage.apiCoverage'), name: t('workbench.homePage.apiCoverage'),
color: ['#D4D4D8', '#00C261'], color: [getVisualThemeColor('initItemStyleColor'), '#00C261'],
tooltipText: tooltipText:
props.item.key === WorkCardEnum.API_CASE_COUNT props.item.key === WorkCardEnum.API_CASE_COUNT
? t('workbench.homePage.apiCaseCountCoverRateTooltip') ? t('workbench.homePage.apiCaseCountCoverRateTooltip')
@ -208,12 +209,12 @@
return props.item.key === WorkCardEnum.API_CASE_COUNT return props.item.key === WorkCardEnum.API_CASE_COUNT
? { ? {
name: t('workbench.homePage.caseExecutionRate'), name: t('workbench.homePage.caseExecutionRate'),
color: ['#D4D4D8', '#00C261'], color: [getVisualThemeColor('initItemStyleColor'), '#00C261'],
tooltipText: t('workbench.homePage.apiCaseCountExecuteRateTooltip'), tooltipText: t('workbench.homePage.apiCaseCountExecuteRateTooltip'),
} }
: { : {
name: t('workbench.homePage.sceneExecutionRate'), name: t('workbench.homePage.sceneExecutionRate'),
color: ['#D4D4D8', '#00C261'], color: [getVisualThemeColor('initItemStyleColor'), '#00C261'],
tooltipText: t('workbench.homePage.scenarioCaseCountExecuteRateTooltip'), tooltipText: t('workbench.homePage.scenarioCaseCountExecuteRateTooltip'),
}; };
}); });

View File

@ -63,6 +63,7 @@
import PassRatePie from './passRatePie.vue'; import PassRatePie from './passRatePie.vue';
import { workApiCountCoverRage, workApiCountDetail } from '@/api/modules/workbench'; import { workApiCountCoverRage, workApiCountDetail } from '@/api/modules/workbench';
import getVisualThemeColor from '@/config/chartTheme';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
@ -195,7 +196,11 @@
return { return {
...item, ...item,
selected: true, selected: true,
color: `${colorMapConfig[props.item.key][index]}`, color: `${
colorMapConfig[props.item.key][index] !== 'initItemStyleColor'
? colorMapConfig[props.item.key][index]
: getVisualThemeColor('initItemStyleColor')
}`,
}; };
}); });

View File

@ -59,6 +59,7 @@
import PassRatePie from './passRatePie.vue'; import PassRatePie from './passRatePie.vue';
import { workCaseCountDetail } from '@/api/modules/workbench'; import { workCaseCountDetail } from '@/api/modules/workbench';
import getVisualThemeColor from '@/config/chartTheme';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
@ -146,7 +147,11 @@
return { return {
...item, ...item,
selected: true, selected: true,
color: `${colorMapConfig[props.item.key][index]}`, color: `${
colorMapConfig[props.item.key][index] !== 'initItemStyleColor'
? colorMapConfig[props.item.key][index]
: getVisualThemeColor('initItemStyleColor')
}`,
}; };
}); });
hasPermission.value = detail.errorCode !== 109001; hasPermission.value = detail.errorCode !== 109001;

View File

@ -58,6 +58,7 @@
import PassRatePie from './passRatePie.vue'; import PassRatePie from './passRatePie.vue';
import { workCaseReviewDetail } from '@/api/modules/workbench'; import { workCaseReviewDetail } from '@/api/modules/workbench';
import getVisualThemeColor from '@/config/chartTheme';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
@ -137,7 +138,11 @@
return { return {
...item, ...item,
selected: true, selected: true,
color: `${colorMapConfig[props.item.key][index]}`, color: `${
colorMapConfig[props.item.key][index] !== 'initItemStyleColor'
? colorMapConfig[props.item.key][index]
: getVisualThemeColor('initItemStyleColor')
}`,
}; };
}); });

View File

@ -63,6 +63,7 @@
workBugHandleByMe, workBugHandleByMe,
workPlanLegacyBug, workPlanLegacyBug,
} from '@/api/modules/workbench'; } from '@/api/modules/workbench';
import getVisualThemeColor from '@/config/chartTheme';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
@ -150,7 +151,11 @@
return { return {
...item, ...item,
selected: true, selected: true,
color: `${colorMapConfig[props.item.key][index]}`, color: `${
colorMapConfig[props.item.key][index] !== 'initItemStyleColor'
? colorMapConfig[props.item.key][index]
: getVisualThemeColor('initItemStyleColor')
}`,
}; };
}); });

View File

@ -54,6 +54,7 @@
import MsChart from '@/components/pure/chart/index.vue'; import MsChart from '@/components/pure/chart/index.vue';
import getVisualThemeColor from '@/config/chartTheme';
import { toolTipConfig } from '@/config/testPlan'; import { toolTipConfig } from '@/config/testPlan';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useOpenNewPage from '@/hooks/useOpenNewPage'; import useOpenNewPage from '@/hooks/useOpenNewPage';
@ -92,7 +93,7 @@
subtext: '', subtext: '',
subtextStyle: { subtextStyle: {
fontSize: 14, fontSize: 14,
color: '#323233', color: getVisualThemeColor('subtextStyleColor'),
fontWeight: 'bold', fontWeight: 'bold',
lineHeight: 3, lineHeight: 3,
}, },
@ -118,29 +119,11 @@
}, },
y: 'bottom', y: 'bottom',
bottom: 'center', bottom: 'center',
formatter: (name: any) => {
return `{a|${name}} {b|${addCommasToNumber(1022220)}}`;
},
tooltip: { tooltip: {
show: false, show: false,
}, },
}, },
textStyle: {
rich: {
a: {
width: 60,
color: '#959598', //
fontSize: 12,
},
b: {
width: 60,
color: '#783887',
fontSize: 16,
fontWeight: 'bold',
padding: [0, 0, 0, 16],
},
},
},
series: { series: {
name: '', name: '',
type: 'pie', type: 'pie',
@ -188,13 +171,27 @@
itemStyle: { itemStyle: {
color: color[i], color: color[i],
borderWidth: pieBorderWidth, borderWidth: pieBorderWidth,
borderColor: '#ffffff', borderColor: getVisualThemeColor('itemStyleBorderColor'),
}, },
}; };
}) })
.filter((e) => e.value !== 0); .filter((e) => e.value !== 0);
options.value.series.data = hasDataLength > 0 ? seriesData : []; options.value.series.data =
hasDataLength > 0
? seriesData
: [
{
name: '',
value: 1,
tooltip: {
show: false,
},
itemStyle: {
color: getVisualThemeColor('initItemStyleColor'),
},
},
];
legend.value = [...props.data.slice(1)].map((e, i) => { legend.value = [...props.data.slice(1)].map((e, i) => {
return { return {
...e, ...e,
@ -211,7 +208,18 @@
if (props.hasPermission) { if (props.hasPermission) {
options.value.title.subtext = `${props.data[0].value ?? 0}%`; options.value.title.subtext = `${props.data[0].value ?? 0}%`;
} else { } else {
options.value.series.data = []; options.value.series.data = [
{
name: '',
value: 1,
tooltip: {
show: false,
},
itemStyle: {
color: getVisualThemeColor('initItemStyleColor'),
},
},
];
options.value.title.subtext = `-%`; options.value.title.subtext = `-%`;
} }

View File

@ -57,6 +57,7 @@
import PassRatePie from './passRatePie.vue'; import PassRatePie from './passRatePie.vue';
import { workTestPlanRage } from '@/api/modules/workbench'; import { workTestPlanRage } from '@/api/modules/workbench';
import getVisualThemeColor from '@/config/chartTheme';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
@ -179,7 +180,11 @@
return { return {
...item, ...item,
selected: true, selected: true,
color: `${colorMapConfig[props.item.key][index]}`, color: `${
colorMapConfig[props.item.key][index] !== 'initItemStyleColor'
? colorMapConfig[props.item.key][index]
: getVisualThemeColor('initItemStyleColor')
}`,
percentValue: total > 0 ? `${((item.count / total) * 100).toFixed(2)}%` : '0.00%', percentValue: total > 0 ? `${((item.count / total) * 100).toFixed(2)}%` : '0.00%',
}; };
}); });

View File

@ -97,6 +97,7 @@
import ThresholdProgress from './thresholdProgress.vue'; import ThresholdProgress from './thresholdProgress.vue';
import { getWorkTestPlanListUrl, workTestPlanOverviewDetail } from '@/api/modules/workbench'; import { getWorkTestPlanListUrl, workTestPlanOverviewDetail } from '@/api/modules/workbench';
import getVisualThemeColor from '@/config/chartTheme';
import { commonRatePieOptions } from '@/config/workbench'; import { commonRatePieOptions } from '@/config/workbench';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
@ -250,24 +251,40 @@
{ {
name: t('common.unExecute'), name: t('common.unExecute'),
value: totalCount - executeCount, value: totalCount - executeCount,
color: '#EDEDF1', color: getVisualThemeColor('initItemStyleColor'),
}, },
]; ];
const pieBorderWidth = executeData.filter((e) => Number(e.value) > 0).length === 1 ? 0 : 1; const pieBorderWidth = executeData.filter((e) => Number(e.value) > 0).length === 1 ? 0 : 1;
execOptions.value.series.data = executeData const lastExecuteData = executeData
.map((e) => { .map((e) => {
return { return {
...e, ...e,
itemStyle: { itemStyle: {
borderWidth: pieBorderWidth, borderWidth: pieBorderWidth,
borderColor: '#ffffff', borderColor: getVisualThemeColor('itemStyleBorderColor'),
color: e.color, color: e.color,
}, },
}; };
}) })
.filter((e) => e.value !== 0); .filter((e) => e.value !== 0);
execOptions.value.series.data =
lastExecuteData.length > 0
? lastExecuteData
: [
{
name: '',
value: 1,
tooltip: {
show: false,
},
itemStyle: {
color: getVisualThemeColor('initItemStyleColor'),
},
},
];
} }
const showSkeleton = ref(false); const showSkeleton = ref(false);

View File

@ -345,6 +345,13 @@
initDefaultList(); initDefaultList();
}); });
watch(
() => appStore.isDarkTheme,
() => {
handleRefresh();
}
);
const time = ref({ ...timeForm.value }); const time = ref({ ...timeForm.value });
watch( watch(

View File

@ -1,5 +1,6 @@
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
import getVisualThemeColor from '@/config/chartTheme';
import { toolTipConfig } from '@/config/testPlan'; import { toolTipConfig } from '@/config/testPlan';
import { commonRatePieOptions, defaultValueMap } from '@/config/workbench'; import { commonRatePieOptions, defaultValueMap } from '@/config/workbench';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
@ -68,16 +69,22 @@ export function getColorScheme(dataLength: number): string[] {
// 饼图颜色配置 // 饼图颜色配置
export const colorMapConfig: Record<string, string[]> = { export const colorMapConfig: Record<string, string[]> = {
[WorkCardEnum.CASE_COUNT]: ['#ED0303', '#FFA200', '#3370FF', '#D4D4D8'], [WorkCardEnum.CASE_COUNT]: ['#ED0303', '#FFA200', '#3370FF', 'initItemStyleColor'],
[WorkCardEnum.ASSOCIATE_CASE_COUNT]: ['#00C261', '#3370FF'], [WorkCardEnum.ASSOCIATE_CASE_COUNT]: ['#00C261', '#3370FF'],
[WorkCardEnum.REVIEW_CASE_COUNT]: ['#D4D4D8', '#3370FF', '#00C261', '#ED0303', '#FFA200'], [WorkCardEnum.REVIEW_CASE_COUNT]: [
[WorkCardEnum.TEST_PLAN_COUNT]: ['#D4D4D8', '#3370FF', '#00C261', '#FF9964'], getVisualThemeColor('initItemStyleColor'),
[WorkCardEnum.PLAN_LEGACY_BUG]: ['#FFA200', '#3370FF', '#D4D4D8', '#00C261', ...getColorScheme(13)], '#3370FF',
[WorkCardEnum.BUG_COUNT]: ['#FFA200', '#3370FF', '#D4D4D8', '#00C261', ...getColorScheme(13)], '#00C261',
[WorkCardEnum.HANDLE_BUG_BY_ME]: ['#FFA200', '#3370FF', '#D4D4D8', '#00C261', ...getColorScheme(13)], '#ED0303',
[WorkCardEnum.CREATE_BY_ME]: ['#9441B1', '#3370FF', '#00C261', '#D4D4D8'], '#FFA200',
],
[WorkCardEnum.TEST_PLAN_COUNT]: ['initItemStyleColor', '#3370FF', '#00C261', '#FF9964'],
[WorkCardEnum.PLAN_LEGACY_BUG]: ['#FFA200', '#3370FF', 'initItemStyleColor', '#00C261', ...getColorScheme(13)],
[WorkCardEnum.BUG_COUNT]: ['#FFA200', '#3370FF', 'initItemStyleColor', '#00C261', ...getColorScheme(13)],
[WorkCardEnum.HANDLE_BUG_BY_ME]: ['#FFA200', '#3370FF', 'initItemStyleColor', '#00C261', ...getColorScheme(13)],
[WorkCardEnum.CREATE_BY_ME]: ['#9441B1', '#3370FF', '#00C261', 'initItemStyleColor'],
[WorkCardEnum.API_COUNT]: ['#811FA3', '#00C261', '#3370FF', '#FFA1FF', '#EE50A3', '#FF9964', '#F9F871', '#C3DD40'], [WorkCardEnum.API_COUNT]: ['#811FA3', '#00C261', '#3370FF', '#FFA1FF', '#EE50A3', '#FF9964', '#F9F871', '#C3DD40'],
[WorkCardEnum.CREATE_BUG_BY_ME]: ['#FFA200', '#3370FF', '#D4D4D8', '#00C261', ...getColorScheme(13)], [WorkCardEnum.CREATE_BUG_BY_ME]: ['#FFA200', '#3370FF', 'initItemStyleColor', '#00C261', ...getColorScheme(13)],
}; };
// 柱状图 // 柱状图
@ -129,8 +136,10 @@ export function getCommonBarOptions(
paramsList = params; paramsList = params;
} }
const html = ` const html = `
<div class="w-[186px] ms-scroll-bar max-h-[236px] overflow-y-auto p-[16px] gap-[8px] flex flex-col"> <div class="w-[186px] rounded ms-scroll-bar max-h-[236px] overflow-y-auto p-[16px] gap-[8px] flex flex-col bg-[var(--color-text-fff)]">
<div class="font-medium max-w-[150px] one-line-text" style="color:#323233">${params[0].axisValueLabel}</div> <div class="font-medium max-w-[150px] text-[var(--color-text-1)] one-line-text">
${params[0].axisValueLabel}
</div>
${testPlanHtml} ${testPlanHtml}
${paramsList ${paramsList
.map( .map(
@ -168,7 +177,7 @@ export function getCommonBarOptions(
triggerEvent: true, triggerEvent: true,
axisLabel: { axisLabel: {
show: true, show: true,
color: '#646466', color: getVisualThemeColor('xLabelColor'),
width: 100, width: 100,
overflow: 'truncate', overflow: 'truncate',
ellipsis: '...', ellipsis: '...',
@ -188,7 +197,7 @@ export function getCommonBarOptions(
}, },
axisLine: { axisLine: {
lineStyle: { lineStyle: {
color: '#EDEDF1', color: getVisualThemeColor('splitLineColor'),
}, },
}, },
}, },
@ -201,6 +210,9 @@ export function getCommonBarOptions(
show: false, show: false,
onZero: false, // 禁止 Y 轴强制显示在 0 位置 onZero: false, // 禁止 Y 轴强制显示在 0 位置
}, },
axisLabel: {
color: getVisualThemeColor('yLabelColor'),
},
offset: 0, // 第一个 Y 轴默认位置 offset: 0, // 第一个 Y 轴默认位置
nameTextStyle: { nameTextStyle: {
fontSize: 12, fontSize: 12,
@ -211,7 +223,7 @@ export function getCommonBarOptions(
splitLine: { splitLine: {
show: true, // 控制是否显示水平线 show: true, // 控制是否显示水平线
lineStyle: { lineStyle: {
color: '#EDEDF1', // 水平线颜色 color: getVisualThemeColor('splitLineColor'), // 水平线颜色
width: 1, // 水平线宽度 width: 1, // 水平线宽度
type: 'dashed', // 水平线线型,可选 'solid'、'dashed'、'dotted' type: 'dashed', // 水平线线型,可选 'solid'、'dashed'、'dotted'
}, },
@ -227,8 +239,8 @@ export function getCommonBarOptions(
style: { style: {
text: '', text: '',
fontSize: 14, fontSize: 14,
fill: '#959598', fill: getVisualThemeColor('graphicFillColor'),
backgroundColor: '#F9F9FE', backgroundColor: getVisualThemeColor('graphicBackgroundColor'),
padding: [6, 16, 6, 16], padding: [6, 16, 6, 16],
borderRadius: 4, borderRadius: 4,
}, },
@ -246,15 +258,16 @@ export function getCommonBarOptions(
left: 'center', left: 'center',
pageButtonItemGap: 5, pageButtonItemGap: 5,
pageButtonGap: 5, pageButtonGap: 5,
pageIconColor: '#00000099', pageIconColor: getVisualThemeColor('pageIconColor'),
pageIconInactiveColor: '#00000042', pageIconInactiveColor: getVisualThemeColor('pageIconInactiveColor'),
pageIconSize: [10, 8], pageIconSize: [10, 8],
pageTextStyle: { pageTextStyle: {
color: '#00000099', color: getVisualThemeColor('pageTextStyleColor'),
fontSize: 12, fontSize: 12,
}, },
textStyle: { textStyle: {
width: 150, width: 150,
color: getVisualThemeColor('legendColor'),
overflow: 'truncate', overflow: 'truncate',
ellipsis: '...', ellipsis: '...',
}, },
@ -338,7 +351,7 @@ export function getPieCharOptions() {
subtext: '100111', subtext: '100111',
subtextStyle: { subtextStyle: {
fontSize: 20, fontSize: 20,
color: '#323233', color: getVisualThemeColor('subtextStyleColor'),
fontWeight: 'bold', fontWeight: 'bold',
align: 'center', align: 'center',
}, },
@ -415,7 +428,8 @@ export function handlePieData(
const pieBorderWidth = hasDataLength === 1 ? 0 : 2; const pieBorderWidth = hasDataLength === 1 ? 0 : 2;
const lastData = lastStatusPercentList const lastData = lastStatusPercentList
.map((item, color) => ({ .map((item, color) => {
return {
name: item.status, name: item.status,
value: item.count, value: item.count,
tooltip: { tooltip: {
@ -424,14 +438,32 @@ export function handlePieData(
show: !!hasPermission, show: !!hasPermission,
}, },
itemStyle: { itemStyle: {
color: colorMapConfig[key][color], color:
colorMapConfig[key][color] === 'initItemStyleColor'
? getVisualThemeColor('initItemStyleColor')
: colorMapConfig[key][color],
borderWidth: pieBorderWidth, borderWidth: pieBorderWidth,
borderColor: '#ffffff', borderColor: getVisualThemeColor('itemStyleBorderColor'),
}, },
})) };
})
.filter((e) => e.value !== 0); .filter((e) => e.value !== 0);
options.series.data = hasDataLength > 0 ? lastData : []; options.series.data =
hasDataLength > 0
? lastData
: [
{
name: '',
value: 1,
tooltip: {
show: false,
},
itemStyle: {
color: getVisualThemeColor('initItemStyleColor'),
},
},
];
// 计算总数和图例格式 // 计算总数和图例格式
const tempObject: Record<string, any> = {}; const tempObject: Record<string, any> = {};
@ -445,7 +477,18 @@ export function handlePieData(
options.title.subtext = addCommasToNumber(totalCount); options.title.subtext = addCommasToNumber(totalCount);
if (!hasPermission) { if (!hasPermission) {
options.title.subtext = '-'; options.title.subtext = '-';
options.series.data = []; options.series.data = [
{
name: '',
value: 1,
tooltip: {
show: false,
},
itemStyle: {
color: getVisualThemeColor('initItemStyleColor'),
},
},
];
} }
return options; return options;
@ -600,6 +643,18 @@ export function handleUpdateTabPie(
const valueKey = key.split('-')[1]; const valueKey = key.split('-')[1];
const countList = list || []; const countList = list || [];
let lastCountList: { value: number | string; label: string; name: string }[] = []; let lastCountList: { value: number | string; label: string; name: string }[] = [];
const defaultValueMapConfig = defaultValueMap();
const emptyData = {
name: '',
value: 1,
tooltip: {
show: false,
},
itemStyle: {
color: getVisualThemeColor('initItemStyleColor'),
},
};
if (hasPermission) { if (hasPermission) {
const pieBorderWidth = countList.slice(1).filter((e) => Number(e.count) > 0).length === 1 ? 0 : 1; const pieBorderWidth = countList.slice(1).filter((e) => Number(e.count) > 0).length === 1 ? 0 : 1;
@ -609,26 +664,29 @@ export function handleUpdateTabPie(
label: item.name, label: item.name,
name: item.name, name: item.name,
itemStyle: { itemStyle: {
color: defaultValueMap[typeKey][valueKey].color[i], color: defaultValueMapConfig[typeKey][valueKey].color[i],
borderWidth: pieBorderWidth, borderWidth: pieBorderWidth,
borderColor: '#ffffff', borderColor: getVisualThemeColor('itemStyleBorderColor'),
}, },
}; };
}); });
options.series.data = lastCountList.every((e) => e.value === 0) ? [] : lastCountList.filter((e) => e.value !== 0); options.series.data = lastCountList.every((e) => e.value === 0)
? [emptyData]
: lastCountList.filter((e) => e.value !== 0);
options.title.text = countList[0].name ?? ''; options.title.text = countList[0].name ?? '';
options.title.subtext = `${countList[0].count ?? 0}%`; options.title.subtext = `${countList[0].count ?? 0}%`;
} else { } else {
options.series.data = []; options.series.data = [emptyData];
lastCountList = defaultValueMap[typeKey][valueKey].defaultList.map((e: any) => {
lastCountList = defaultValueMapConfig[typeKey][valueKey].defaultList.map((e: any) => {
return { return {
...e, ...e,
label: t(e.label), label: t(e.label),
}; };
}); });
options.title.text = t(defaultValueMap[typeKey][valueKey].defaultName); options.title.text = t(defaultValueMapConfig[typeKey][valueKey].defaultName);
options.title.subtext = '-%'; options.title.subtext = '-%';
} }
@ -700,12 +758,12 @@ export function getSeriesData(
enterable: true, enterable: true,
formatter(params: any) { formatter(params: any) {
const html = ` const html = `
<div class="w-[186px] h-[50px] p-[16px] flex items-center justify-between"> <div class="w-[186px] h-[50px] p-[16px] flex items-center justify-between bg-[var(--color-text-fff)]">
<div class=" flex items-center"> <div class=" flex items-center">
<div class="mb-[2px] mr-[8px] h-[8px] w-[8px] rounded-sm bg-[${params.color}]" style="background:${ <div class="mb-[2px] mr-[8px] h-[8px] w-[8px] rounded-sm bg-[${params.color}]" style="background:${
params.color params.color
}"></div> }"></div>
<div class="one-line-text max-w-[100px]"" style="color:#959598">${params.name}</div> <div class="one-line-text max-w-[100px] text-[var(--color-text-2)]">${params.name}</div>
</div> </div>
<div class="text-[var(--color-text-1)] font-semibold">${addCommasToNumber(params.value)}</div> <div class="text-[var(--color-text-1)] font-semibold">${addCommasToNumber(params.value)}</div>
</div> </div>
@ -778,7 +836,7 @@ export function createCustomTooltip(chartDom: InstanceType<typeof VCharts>) {
customTooltip.style.maxWidth = '300px'; customTooltip.style.maxWidth = '300px';
customTooltip.style.padding = '5px'; customTooltip.style.padding = '5px';
customTooltip.style.background = 'rgba(0, 0, 0, 0.75)'; customTooltip.style.background = 'var(--color-text-2)';
customTooltip.style.color = 'var(--color-text-fff)'; customTooltip.style.color = 'var(--color-text-fff)';
customTooltip.style.borderRadius = '4px'; customTooltip.style.borderRadius = '4px';