From 7d26ee82c55e411060882674a560af9d9a64c0ca Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Fri, 12 Mar 2021 16:57:16 +0800 Subject: [PATCH 1/9] =?UTF-8?q?feat(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):?= =?UTF-8?q?=20=E7=94=A8=E4=BE=8B=E6=95=B0=E9=87=8F=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/mapper/ext/ExtTestCaseMapper.java | 12 ++ .../base/mapper/ext/ExtTestCaseMapper.xml | 14 ++ .../track/controller/TrackController.java | 53 +++++ .../track/request/testcase/CasePriority.java | 8 + .../track/response/TrackCountResult.java | 19 ++ .../track/response/TrackStatisticsDTO.java | 143 +++++++++++++ .../track/service/TrackService.java | 40 ++++ .../components/track/home/TrackHome.vue | 114 ++++++++--- .../track/home/components/CaseCountCard.vue | 191 ++++++++++++++++++ .../home/components/RelevanceCaseCard.vue | 191 ++++++++++++++++++ 10 files changed, 756 insertions(+), 29 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/track/controller/TrackController.java create mode 100644 backend/src/main/java/io/metersphere/track/request/testcase/CasePriority.java create mode 100644 backend/src/main/java/io/metersphere/track/response/TrackCountResult.java create mode 100644 backend/src/main/java/io/metersphere/track/response/TrackStatisticsDTO.java create mode 100644 backend/src/main/java/io/metersphere/track/service/TrackService.java create mode 100644 frontend/src/business/components/track/home/components/CaseCountCard.vue create mode 100644 frontend/src/business/components/track/home/components/RelevanceCaseCard.vue diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java index bfe5e65b55..7181b1fb24 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java @@ -5,6 +5,7 @@ import io.metersphere.controller.request.BaseQueryRequest; import io.metersphere.track.dto.TestCaseDTO; import io.metersphere.track.request.testcase.QueryTestCaseRequest; import io.metersphere.track.request.testcase.TestCaseBatchRequest; +import io.metersphere.track.response.TrackCountResult; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -48,4 +49,15 @@ public interface ExtTestCaseMapper { int checkIsHave(@Param("caseId") String caseId, @Param("workspaceIds") Set workspaceIds); List selectIds(@Param("request") BaseQueryRequest condition); + + /** + * 按照用例等级统计 + * @param projectId 项目ID + * @return 统计结果 + */ + List countPriority(@Param("projectId") String projectId); + + long countCreatedThisWeek(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp); + + List countStatus(@Param("projectId") String projectId); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml index 6e746b0b81..ed890ad122 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml @@ -319,4 +319,18 @@ + + + + + + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/track/controller/TrackController.java b/backend/src/main/java/io/metersphere/track/controller/TrackController.java new file mode 100644 index 0000000000..c3d2981b78 --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/controller/TrackController.java @@ -0,0 +1,53 @@ +package io.metersphere.track.controller; + + +import io.metersphere.commons.constants.RoleConstants; +import io.metersphere.track.response.TrackCountResult; +import io.metersphere.track.response.TrackStatisticsDTO; +import io.metersphere.track.service.TrackService; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresRoles; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.text.DecimalFormat; +import java.util.List; + +@RestController +@RequestMapping("/track") +@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER, RoleConstants.ORG_ADMIN}, logical = Logical.OR) +public class TrackController { + + @Resource + private TrackService trackService; + + @GetMapping("/count/{projectId}") + public TrackStatisticsDTO getTrackCount(@PathVariable String projectId) { + TrackStatisticsDTO statistics = new TrackStatisticsDTO(); + + List priorityResults = trackService.countPriority(projectId); + statistics.countPriority(priorityResults); + + long size = trackService.countCreatedThisWeek(projectId); + statistics.setThisWeekAddedCount(size); + + List statusResults = trackService.countStatus(projectId); + statistics.countStatus(statusResults); + + long total = statistics.getPrepareCount() + statistics.getPassCount() + statistics.getUnPassCount(); + if (total != 0) { + float reviewed = (float) (statistics.getPassCount() + statistics.getUnPassCount()) * 100 / total; + DecimalFormat df = new DecimalFormat("0.0"); + statistics.setReviewRage(df.format(reviewed) + "%"); + } + + statistics.setP0CountStr("P0  

" + statistics.getP0CaseCountNumber()); + statistics.setP1CountStr("P1  

" + statistics.getP1CaseCountNumber()); + statistics.setP2CountStr("P2  

" + statistics.getP2CaseCountNumber()); + statistics.setP3CountStr("P3  

" + statistics.getP3CaseCountNumber()); + return statistics; + } +} diff --git a/backend/src/main/java/io/metersphere/track/request/testcase/CasePriority.java b/backend/src/main/java/io/metersphere/track/request/testcase/CasePriority.java new file mode 100644 index 0000000000..e450b44945 --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/request/testcase/CasePriority.java @@ -0,0 +1,8 @@ +package io.metersphere.track.request.testcase; + +public class CasePriority { + public static final String P0 = "P0"; + public static final String P1 = "P1"; + public static final String P2 = "P2"; + public static final String P3 = "P3"; +} diff --git a/backend/src/main/java/io/metersphere/track/response/TrackCountResult.java b/backend/src/main/java/io/metersphere/track/response/TrackCountResult.java new file mode 100644 index 0000000000..14e2add524 --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/response/TrackCountResult.java @@ -0,0 +1,19 @@ +package io.metersphere.track.response; + + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class TrackCountResult { + + /** + * 分组统计字段 + */ + private String groupField; + /** + * 数据统计 + */ + private long countNumber; +} diff --git a/backend/src/main/java/io/metersphere/track/response/TrackStatisticsDTO.java b/backend/src/main/java/io/metersphere/track/response/TrackStatisticsDTO.java new file mode 100644 index 0000000000..6b58ecd8b7 --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/response/TrackStatisticsDTO.java @@ -0,0 +1,143 @@ +package io.metersphere.track.response; + +import io.metersphere.commons.constants.TestReviewCaseStatus; +import io.metersphere.track.request.testcase.CasePriority; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * 用例数量统计数据 + */ +@Getter +@Setter +public class TrackStatisticsDTO { + + /** + * 用例总计 + */ + private long allCaseCountNumber = 0; + + /** + * P0登记用例总计 + */ + private long p0CaseCountNumber = 0; + + /** + * P1登记用例总计 + */ + private long p1CaseCountNumber = 0; + + /** + * P2登记用例总计 + */ + private long p2CaseCountNumber = 0; + + /** + * P3登记用例总计 + */ + private long p3CaseCountNumber = 0; + + private String p0CountStr = ""; + private String p1CountStr = ""; + private String p2CountStr = ""; + private String p3CountStr = ""; + + /** + * 关联用例数量统计 + */ + private long relevanceCaseCount = 0; + + /** + * 接口用例数量统计 + */ + private long apiCaseCount = 0; + + /** + * 场景用例数量统计 + */ + private long scenarioCaseCount = 0; + + /** + * 性能用例数量统计 + */ + private long performanceCaseCount = 0; + + + private String apiCaseCountStr = ""; + private String scenarioCaseStr = ""; + private String performanceCaseCountStr = ""; + + /** + * 本周新增数量 + */ + private long thisWeekAddedCount = 0; + /** + * 未覆盖 + */ + private long uncoverageCount = 0; + /** + * 已覆盖 + */ + private long coverageCount = 0; + /** + * 覆盖率 + */ + private String coverageRage = " 0%"; + /** + * 评审率 + */ + private String reviewRage = " 0%"; + /** + * 未评审 + */ + private long prepareCount = 0; + /** + * 已通过 + */ + private long passCount = 0; + /** + * 未通过 + */ + private long unPassCount = 0; + + + /** + * 按照 Priority 统计 + * @param trackCountResults 统计结果 + */ + public void countPriority(List trackCountResults) { + for (TrackCountResult countResult : trackCountResults) { + switch (countResult.getGroupField().toUpperCase()){ + case CasePriority.P0: + this.p0CaseCountNumber += countResult.getCountNumber(); + break; + case CasePriority.P1: + this.p1CaseCountNumber += countResult.getCountNumber(); + break; + case CasePriority.P2: + this.p2CaseCountNumber += countResult.getCountNumber(); + break; + case CasePriority.P3: + this.p3CaseCountNumber += countResult.getCountNumber(); + break; + default: + break; + } + this.allCaseCountNumber += countResult.getCountNumber(); + } + } + + public void countStatus(List statusResults) { + for (TrackCountResult countResult : statusResults) { + if(TestReviewCaseStatus.Prepare.name().equals(countResult.getGroupField())){ + this.prepareCount += countResult.getCountNumber(); + }else if(TestReviewCaseStatus.Pass.name().equals(countResult.getGroupField())){ + this.passCount += countResult.getCountNumber(); + }else if(TestReviewCaseStatus.UnPass.name().equals(countResult.getGroupField())){ + this.unPassCount += countResult.getCountNumber(); + } + } + } +} diff --git a/backend/src/main/java/io/metersphere/track/service/TrackService.java b/backend/src/main/java/io/metersphere/track/service/TrackService.java new file mode 100644 index 0000000000..6cf219ec8b --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/service/TrackService.java @@ -0,0 +1,40 @@ +package io.metersphere.track.service; + +import io.metersphere.base.mapper.ext.ExtTestCaseMapper; +import io.metersphere.commons.utils.DateUtils; +import io.metersphere.track.response.TrackCountResult; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Service +@Transactional(rollbackFor = Exception.class) +public class TrackService { + + @Resource + private ExtTestCaseMapper extTestCaseMapper; + + public List countPriority(String projectId) { + return extTestCaseMapper.countPriority(projectId); + } + + public long countCreatedThisWeek(String projectId) { + Map startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date()); + + Date firstTime = startAndEndDateInWeek.get("firstTime"); + Date lastTime = startAndEndDateInWeek.get("lastTime"); + + if (firstTime == null || lastTime == null) { + return 0; + } else { + return extTestCaseMapper.countCreatedThisWeek(projectId, firstTime.getTime(), lastTime.getTime()); + } + } + + public List countStatus(String projectId) { + return extTestCaseMapper.countStatus(projectId); + } +} diff --git a/frontend/src/business/components/track/home/TrackHome.vue b/frontend/src/business/components/track/home/TrackHome.vue index 3061221b30..dfb5f4aaee 100644 --- a/frontend/src/business/components/track/home/TrackHome.vue +++ b/frontend/src/business/components/track/home/TrackHome.vue @@ -1,17 +1,44 @@ diff --git a/frontend/src/business/components/track/home/components/CaseCountCard.vue b/frontend/src/business/components/track/home/components/CaseCountCard.vue new file mode 100644 index 0000000000..b70cf1c8f2 --- /dev/null +++ b/frontend/src/business/components/track/home/components/CaseCountCard.vue @@ -0,0 +1,191 @@ + + + + + diff --git a/frontend/src/business/components/track/home/components/RelevanceCaseCard.vue b/frontend/src/business/components/track/home/components/RelevanceCaseCard.vue new file mode 100644 index 0000000000..ec437a0472 --- /dev/null +++ b/frontend/src/business/components/track/home/components/RelevanceCaseCard.vue @@ -0,0 +1,191 @@ + + + + + From e306a17056e283368e71c438d13f9f169845ecf2 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Fri, 12 Mar 2021 18:15:39 +0800 Subject: [PATCH 2/9] =?UTF-8?q?fix(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E5=9B=BE=E8=A1=A8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/components/PerformancePressureConfig.vue | 4 ++-- .../test/components/PerformancePressureConfig.vue | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/business/components/performance/report/components/PerformancePressureConfig.vue b/frontend/src/business/components/performance/report/components/PerformancePressureConfig.vue index 5068f14929..2157353b8d 100644 --- a/frontend/src/business/components/performance/report/components/PerformancePressureConfig.vue +++ b/frontend/src/business/components/performance/report/components/PerformancePressureConfig.vue @@ -364,7 +364,7 @@ export default { if (j === 0) { seriesData.data.push([0, 0]); } - if (j > tg.rampUpTime) { + if (j >= tg.rampUpTime) { xAxis.push(tg.duration); seriesData.data.push([j, tg.threadNumber]); @@ -475,7 +475,7 @@ export default { if (i === 0) { handler.options.series[0].data.push([0, 0]); } - if (i > handler.rampUpTime) { + if (i >= handler.rampUpTime) { handler.options.xAxis.data.push(handler.duration); handler.options.series[0].data.push([i, handler.threadNumber]); diff --git a/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue b/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue index f7c3e121ee..c800972a24 100644 --- a/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue +++ b/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue @@ -92,6 +92,7 @@ :disabled="isReadOnly" :min="1" v-model="threadGroup.rampUpTime" + @change="calculateChart(threadGroup)" size="mini"/> @@ -402,7 +403,7 @@ export default { if (j === 0) { seriesData.data.push([0, 0]); } - if (j > tg.rampUpTime) { + if (j >= tg.rampUpTime) { xAxis.push(tg.duration); seriesData.data.push([j, tg.threadNumber]); @@ -519,7 +520,7 @@ export default { if (i === 0) { handler.options.series[0].data.push([0, 0]); } - if (i > handler.rampUpTime) { + if (i >= handler.rampUpTime) { handler.options.xAxis.data.push(handler.duration); handler.options.series[0].data.push([i, handler.threadNumber]); From 551f34fee723833b311e69bf17401b02522e0664 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Sat, 13 Mar 2021 13:01:28 +0800 Subject: [PATCH 3/9] =?UTF-8?q?feat(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):?= =?UTF-8?q?=20=E9=A6=96=E9=A1=B5=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/mapper/ext/ExtTestCaseMapper.java | 12 ++ .../base/mapper/ext/ExtTestCaseMapper.xml | 28 +++- .../track/controller/TrackController.java | 40 ++++++ .../{CasePriority.java => TrackCount.java} | 6 +- .../track/response/BugStatustics.java | 16 +++ .../track/response/TestPlanBugCount.java | 16 +++ .../track/response/TrackStatisticsDTO.java | 42 +++++- .../track/service/TrackService.java | 128 ++++++++++++++++++ .../components/track/home/TrackHome.vue | 113 +++++++++++++++- .../track/home/components/BugCountCard.vue | 122 +++++++++++++++++ .../track/home/components/CaseCountCard.vue | 2 +- .../track/home/components/CaseMaintenance.vue | 41 ++++++ .../home/components/RelevanceCaseCard.vue | 64 +++------ .../track/home/components/ReviewList.vue | 26 ++-- 14 files changed, 583 insertions(+), 73 deletions(-) rename backend/src/main/java/io/metersphere/track/request/testcase/{CasePriority.java => TrackCount.java} (53%) create mode 100644 backend/src/main/java/io/metersphere/track/response/BugStatustics.java create mode 100644 backend/src/main/java/io/metersphere/track/response/TestPlanBugCount.java create mode 100644 frontend/src/business/components/track/home/components/BugCountCard.vue create mode 100644 frontend/src/business/components/track/home/components/CaseMaintenance.vue diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java index 7181b1fb24..5ed9e3a7fa 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java @@ -60,4 +60,16 @@ public interface ExtTestCaseMapper { long countCreatedThisWeek(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp); List countStatus(@Param("projectId") String projectId); + + List countRelevance(@Param("projectId") String projectId); + + long countRelevanceCreatedThisWeek(@Param("projectId") String projectId,@Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp); + + List countCoverage(@Param("projectId") String projectId); + + List countFuncMaintainer(@Param("projectId") String projectId); + + List countRelevanceMaintainer(@Param("projectId") String projectId); + + } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml index ed890ad122..17d5c37a6e 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml @@ -328,9 +328,33 @@ SELECT count(id) AS countNumber FROM test_case WHERE test_case.project_id = #{projectId} AND create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp} - + + + + + + + + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/track/controller/TrackController.java b/backend/src/main/java/io/metersphere/track/controller/TrackController.java index c3d2981b78..2b0d66bfb0 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TrackController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TrackController.java @@ -2,6 +2,8 @@ package io.metersphere.track.controller; import io.metersphere.commons.constants.RoleConstants; +import io.metersphere.performance.base.ChartsData; +import io.metersphere.track.response.BugStatustics; import io.metersphere.track.response.TrackCountResult; import io.metersphere.track.response.TrackStatisticsDTO; import io.metersphere.track.service.TrackService; @@ -50,4 +52,42 @@ public class TrackController { statistics.setP3CountStr("P3  

" + statistics.getP3CaseCountNumber()); return statistics; } + + @GetMapping("/relevance/count/{projectId}") + public TrackStatisticsDTO getRelevanceCount(@PathVariable String projectId) { + TrackStatisticsDTO statistics = new TrackStatisticsDTO(); + + List relevanceResults = trackService.countRelevance(projectId); + statistics.countRelevance(relevanceResults); + + long size = trackService.countRelevanceCreatedThisWeek(projectId); + statistics.setThisWeekAddedCount(size); + + List coverageResults = trackService.countCoverage(projectId); + statistics.countCoverage(coverageResults); + + long total = statistics.getUncoverageCount() + statistics.getCoverageCount(); + + if (total != 0) { + float coverageRageNumber = (float) statistics.getCoverageCount() * 100 / total; + DecimalFormat df = new DecimalFormat("0.0"); + statistics.setCoverageRage(df.format(coverageRageNumber) + "%"); + } + + statistics.setApiCaseCountStr("接口用例  

" + statistics.getApiCaseCount()); + statistics.setPerformanceCaseCountStr("性能用例  

" + statistics.getPerformanceCaseCount()); + statistics.setScenarioCaseStr("场景用例  

" + statistics.getScenarioCaseCount()); + + return statistics; + } + + @GetMapping("/case/bar/{projectId}") + public List getCaseMaintenanceBar(@PathVariable String projectId) { + return trackService.getCaseMaintenanceBar(projectId); + } + + @GetMapping("/bug/count/{projectId}") + public BugStatustics getBugStatustics(@PathVariable String projectId) { + return trackService.getBugStatustics(projectId); + } } diff --git a/backend/src/main/java/io/metersphere/track/request/testcase/CasePriority.java b/backend/src/main/java/io/metersphere/track/request/testcase/TrackCount.java similarity index 53% rename from backend/src/main/java/io/metersphere/track/request/testcase/CasePriority.java rename to backend/src/main/java/io/metersphere/track/request/testcase/TrackCount.java index e450b44945..b795deb9da 100644 --- a/backend/src/main/java/io/metersphere/track/request/testcase/CasePriority.java +++ b/backend/src/main/java/io/metersphere/track/request/testcase/TrackCount.java @@ -1,8 +1,12 @@ package io.metersphere.track.request.testcase; -public class CasePriority { +public class TrackCount { public static final String P0 = "P0"; public static final String P1 = "P1"; public static final String P2 = "P2"; public static final String P3 = "P3"; + + public static final String API = "api"; + public static final String PERFORMANCE = "performance"; + public static final String AUTOMATION = "automation"; } diff --git a/backend/src/main/java/io/metersphere/track/response/BugStatustics.java b/backend/src/main/java/io/metersphere/track/response/BugStatustics.java new file mode 100644 index 0000000000..863fa5f0fe --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/response/BugStatustics.java @@ -0,0 +1,16 @@ +package io.metersphere.track.response; + +import lombok.Getter; +import lombok.Setter; + +import java.util.ArrayList; +import java.util.List; + +@Getter +@Setter +public class BugStatustics { + + private long bugTotalSize; + private String rage; + private List list = new ArrayList<>(); +} diff --git a/backend/src/main/java/io/metersphere/track/response/TestPlanBugCount.java b/backend/src/main/java/io/metersphere/track/response/TestPlanBugCount.java new file mode 100644 index 0000000000..4c8a75b272 --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/response/TestPlanBugCount.java @@ -0,0 +1,16 @@ +package io.metersphere.track.response; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class TestPlanBugCount { + private int index; + private String planName; + private long creatTime; + private String status; + private int caseSize; + private int bugSize; + private String passRage; +} diff --git a/backend/src/main/java/io/metersphere/track/response/TrackStatisticsDTO.java b/backend/src/main/java/io/metersphere/track/response/TrackStatisticsDTO.java index 6b58ecd8b7..cb3aeffc88 100644 --- a/backend/src/main/java/io/metersphere/track/response/TrackStatisticsDTO.java +++ b/backend/src/main/java/io/metersphere/track/response/TrackStatisticsDTO.java @@ -1,7 +1,8 @@ package io.metersphere.track.response; +import io.metersphere.api.dto.datacount.ApiDataCountResult; import io.metersphere.commons.constants.TestReviewCaseStatus; -import io.metersphere.track.request.testcase.CasePriority; +import io.metersphere.track.request.testcase.TrackCount; import lombok.Getter; import lombok.Setter; @@ -47,7 +48,7 @@ public class TrackStatisticsDTO { /** * 关联用例数量统计 */ - private long relevanceCaseCount = 0; + private long allRelevanceCaseCount = 0; /** * 接口用例数量统计 @@ -110,16 +111,16 @@ public class TrackStatisticsDTO { public void countPriority(List trackCountResults) { for (TrackCountResult countResult : trackCountResults) { switch (countResult.getGroupField().toUpperCase()){ - case CasePriority.P0: + case TrackCount.P0: this.p0CaseCountNumber += countResult.getCountNumber(); break; - case CasePriority.P1: + case TrackCount.P1: this.p1CaseCountNumber += countResult.getCountNumber(); break; - case CasePriority.P2: + case TrackCount.P2: this.p2CaseCountNumber += countResult.getCountNumber(); break; - case CasePriority.P3: + case TrackCount.P3: this.p3CaseCountNumber += countResult.getCountNumber(); break; default: @@ -140,4 +141,33 @@ public class TrackStatisticsDTO { } } } + + public void countRelevance(List relevanceResults) { + for (TrackCountResult countResult : relevanceResults) { + switch (countResult.getGroupField().toUpperCase()){ + case TrackCount.API: + this.apiCaseCount += countResult.getCountNumber(); + break; + case TrackCount.PERFORMANCE: + this.performanceCaseCount += countResult.getCountNumber(); + break; + case TrackCount.AUTOMATION: + this.scenarioCaseCount += countResult.getCountNumber(); + break; + default: + break; + } + this.allRelevanceCaseCount += countResult.getCountNumber(); + } + } + + public void countCoverage(List coverageResults) { + for (TrackCountResult countResult : coverageResults) { + if("coverage".equals(countResult.getGroupField())){ + this.coverageCount+= countResult.getCountNumber(); + }else if("uncoverage".equals(countResult.getGroupField())){ + this.uncoverageCount+= countResult.getCountNumber(); + } + } + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TrackService.java b/backend/src/main/java/io/metersphere/track/service/TrackService.java index 6cf219ec8b..b2a01371bd 100644 --- a/backend/src/main/java/io/metersphere/track/service/TrackService.java +++ b/backend/src/main/java/io/metersphere/track/service/TrackService.java @@ -1,14 +1,22 @@ package io.metersphere.track.service; +import io.metersphere.base.domain.*; +import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.ExtTestCaseMapper; import io.metersphere.commons.utils.DateUtils; +import io.metersphere.performance.base.ChartsData; +import io.metersphere.track.response.BugStatustics; +import io.metersphere.track.response.TestPlanBugCount; import io.metersphere.track.response.TrackCountResult; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; @Service @Transactional(rollbackFor = Exception.class) @@ -16,6 +24,16 @@ public class TrackService { @Resource private ExtTestCaseMapper extTestCaseMapper; + @Resource + private TestPlanMapper testPlanMapper; + @Resource + private TestPlanTestCaseMapper testPlanTestCaseMapper; + @Resource + private TestPlanLoadCaseMapper testPlanLoadCaseMapper; + @Resource + private TestPlanApiCaseMapper testPlanApiCaseMapper; + @Resource + private TestPlanApiScenarioMapper testPlanApiScenarioMapper; public List countPriority(String projectId) { return extTestCaseMapper.countPriority(projectId); @@ -37,4 +55,114 @@ public class TrackService { public List countStatus(String projectId) { return extTestCaseMapper.countStatus(projectId); } + + public List countRelevance(String projectId) { + return extTestCaseMapper.countRelevance(projectId); + } + + public long countRelevanceCreatedThisWeek(String projectId) { + Map startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date()); + + Date firstTime = startAndEndDateInWeek.get("firstTime"); + Date lastTime = startAndEndDateInWeek.get("lastTime"); + + if (firstTime == null || lastTime == null) { + return 0; + } else { + return extTestCaseMapper.countRelevanceCreatedThisWeek(projectId, firstTime.getTime(), lastTime.getTime()); + } + } + + public List countCoverage(String projectId) { + return extTestCaseMapper.countCoverage(projectId); + } + + public List getCaseMaintenanceBar(String projectId) { + List funcMaintainer = extTestCaseMapper.countFuncMaintainer(projectId); + List relevanceMaintainer = extTestCaseMapper.countRelevanceMaintainer(projectId); + List list = relevanceMaintainer.stream().map(TrackCountResult::getGroupField).collect(Collectors.toList()); + + List charts = new ArrayList<>(); + for (TrackCountResult result : funcMaintainer) { + String groupField = result.getGroupField(); + if (!list.contains(groupField)) { + // 创建了功能用例,但是未关联测试 + TrackCountResult trackCount = new TrackCountResult(); + trackCount.setCountNumber(0); + trackCount.setGroupField(groupField); + relevanceMaintainer.add(trackCount); + } + ChartsData chartsData = new ChartsData(); + chartsData.setxAxis(groupField); + chartsData.setyAxis(BigDecimal.valueOf(result.getCountNumber())); + chartsData.setGroupName("FUNCTIONCASE"); + charts.add(chartsData); + } + + for (TrackCountResult result : relevanceMaintainer) { + ChartsData chartsData = new ChartsData(); + chartsData.setxAxis(result.getGroupField()); + chartsData.setyAxis(BigDecimal.valueOf(result.getCountNumber())); + chartsData.setGroupName("RELEVANCECASE"); + charts.add(chartsData); + } + + return charts; + } + + public BugStatustics getBugStatustics(String projectId) { + TestPlanExample example = new TestPlanExample(); + example.createCriteria().andProjectIdEqualTo(projectId); + List plans = testPlanMapper.selectByExample(example); + List list = new ArrayList<>(); + BugStatustics bugStatustics = new BugStatustics(); + int index = 1; + for (TestPlan plan : plans) { + TestPlanBugCount testPlanBug = new TestPlanBugCount(); + testPlanBug.setIndex(index++); + testPlanBug.setPlanName(plan.getName()); + testPlanBug.setCreatTime(plan.getCreateTime()); + testPlanBug.setStatus(plan.getStatus()); + testPlanBug.setCaseSize(getPlanCaseSize(plan.getId())); + testPlanBug.setBugSize(getPlanBugSize(plan.getId())); + testPlanBug.setPassRage(getPlanPassRage(plan.getId())); + list.add(testPlanBug); + } + + // todo + bugStatustics.setList(list); + bugStatustics.setRage("1"); + bugStatustics.setBugTotalSize(2); + return bugStatustics; + } + + private int getPlanCaseSize(String planId) { + TestPlanTestCaseExample testPlanTestCaseExample = new TestPlanTestCaseExample(); + testPlanTestCaseExample.createCriteria().andPlanIdEqualTo(planId); + List testPlanTestCases = testPlanTestCaseMapper.selectByExample(testPlanTestCaseExample); + + TestPlanApiCaseExample testPlanApiCaseExample = new TestPlanApiCaseExample(); + testPlanApiCaseExample.createCriteria().andTestPlanIdEqualTo(planId); + List testPlanApiCases = testPlanApiCaseMapper.selectByExample(testPlanApiCaseExample); + + TestPlanLoadCaseExample example = new TestPlanLoadCaseExample(); + example.createCriteria().andTestPlanIdEqualTo(planId); + List testPlanLoadCases = testPlanLoadCaseMapper.selectByExample(example); + + TestPlanApiScenarioExample testPlanApiScenarioExample = new TestPlanApiScenarioExample(); + testPlanApiCaseExample.createCriteria().andTestPlanIdEqualTo(planId); + List testPlanApiScenarios = testPlanApiScenarioMapper.selectByExample(testPlanApiScenarioExample); + + + return testPlanTestCases.size() + testPlanApiCases.size() + testPlanLoadCases.size() + testPlanApiScenarios.size(); + + } + + private int getPlanBugSize(String planId) { + return 1; + } + + private String getPlanPassRage(String planId) { + return "10%"; + } } diff --git a/frontend/src/business/components/track/home/TrackHome.vue b/frontend/src/business/components/track/home/TrackHome.vue index dfb5f4aaee..1f0b14b7e8 100644 --- a/frontend/src/business/components/track/home/TrackHome.vue +++ b/frontend/src/business/components/track/home/TrackHome.vue @@ -34,13 +34,35 @@
- +
-
3
+
+ +
+ + + + + + + + + + + + + + + + + + + + @@ -52,20 +74,34 @@ import MsContainer from "@/business/components/common/components/MsContainer"; import CaseCountCard from "@/business/components/track/home/components/CaseCountCard"; import RelevanceCaseCard from "@/business/components/track/home/components/RelevanceCaseCard"; import {getCurrentProjectID} from "@/common/js/utils"; +import CaseMaintenance from "@/business/components/track/home/components/CaseMaintenance"; +import {COUNT_NUMBER, COUNT_NUMBER_SHALLOW} from "@/common/js/constants"; +import BugCountCard from "@/business/components/track/home/components/BugCountCard"; +import ReviewList from "@/business/components/track/home/components/ReviewList"; +import MsRunningTaskList from "@/business/components/api/homepage/components/RunningTaskList"; +import MsFailureTestCaseList from "@/business/components/api/homepage/components/FailureTestCaseList"; +require('echarts/lib/component/legend'); export default { name: "TrackHome", components: { + ReviewList, + BugCountCard, RelevanceCaseCard, CaseCountCard, MsMainContainer, - MsContainer + MsContainer, + CaseMaintenance, + MsRunningTaskList, + MsFailureTestCaseList }, data() { return { tipsType: "1", result: {}, - trackCountData: {} + trackCountData: {}, + relevanceCountData: {}, + caseOption: {} } }, activated() { @@ -79,9 +115,76 @@ export default { }, init() { let selectProjectId = getCurrentProjectID(); + this.$get("/track/count/" + selectProjectId, response => { this.trackCountData = response.data; }); + + this.$get("/track/relevance/count/" + selectProjectId, response => { + this.relevanceCountData = response.data; + }); + + this.$get("/track/case/bar/" + selectProjectId, response => { + let data = response.data; + this.setBarOption(data); + }) + }, + setBarOption(data) { + let xAxis = []; + data.map(d => { + if (!xAxis.includes(d.xAxis)) { + xAxis.push(d.xAxis); + } + }); + let yAxis1 = data.filter(d => d.groupName === 'FUNCTIONCASE').map(d => d.yAxis); + let yAxis2 = data.filter(d => d.groupName === 'RELEVANCECASE').map(d => d.yAxis); + let option = { + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow' + } + }, + xAxis: { + type: 'category', + data: xAxis + }, + yAxis: { + type: 'value', + axisLine: { + show: false + }, + axisTick: { + show: false + } + }, + legend: { + data: ["功能用例数", "关联用例数"], + orient: 'vertical', + right: '80', + }, + series: [{ + name: "功能用例数", + data: yAxis1, + type: 'bar', + itemStyle: { + normal: { + color: COUNT_NUMBER + } + } + }, + { + name: "关联用例数", + data: yAxis2, + type: 'bar', + itemStyle: { + normal: { + color: COUNT_NUMBER_SHALLOW + } + } + }] + }; + this.caseOption = option; } } @@ -90,13 +193,11 @@ export default { diff --git a/frontend/src/business/components/track/home/components/CaseCountCard.vue b/frontend/src/business/components/track/home/components/CaseCountCard.vue index b70cf1c8f2..b1caeed243 100644 --- a/frontend/src/business/components/track/home/components/CaseCountCard.vue +++ b/frontend/src/business/components/track/home/components/CaseCountCard.vue @@ -68,7 +68,7 @@ - {{$t('api_test.home_page.detail_card.rate.completion')+":"}} + 评审率: diff --git a/frontend/src/business/components/track/home/components/CaseMaintenance.vue b/frontend/src/business/components/track/home/components/CaseMaintenance.vue new file mode 100644 index 0000000000..8cbb6f1121 --- /dev/null +++ b/frontend/src/business/components/track/home/components/CaseMaintenance.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/frontend/src/business/components/track/home/components/RelevanceCaseCard.vue b/frontend/src/business/components/track/home/components/RelevanceCaseCard.vue index ec437a0472..d82ef603af 100644 --- a/frontend/src/business/components/track/home/components/RelevanceCaseCard.vue +++ b/frontend/src/business/components/track/home/components/RelevanceCaseCard.vue @@ -2,7 +2,7 @@
- 用例数量统计 + 关联用例数量统计
@@ -10,7 +10,7 @@
- {{caseCountData}} + {{relevanceCountData.allRelevanceCaseCount}} {{$t('api_test.home_page.unit_of_measurement')}} @@ -18,34 +18,17 @@
-
+
- - -
+ + +
- -
+ +
- -
-
- -
-
-
- - -
-
- -
-
- -
-
- -
+ +
@@ -57,7 +40,7 @@ {{$t('api_test.home_page.api_details_card.this_week_add')}} - {{caseCountData}} + {{relevanceCountData.thisWeekAddedCount}} {{$t('api_test.home_page.unit_of_measurement')}} @@ -68,11 +51,11 @@ - {{$t('api_test.home_page.detail_card.rate.completion')+":"}} + 覆盖率: - {{caseCountData}} + {{relevanceCountData.coverageRage}} @@ -83,28 +66,19 @@ - {{$t('api_test.home_page.detail_card.running')}} + 未覆盖 {{"\xa0\xa0"}} - {{caseCountData}} - - - - - - {{$t('api_test.home_page.detail_card.not_started')}} - {{"\xa0\xa0"}} - - {{caseCountData}} + {{relevanceCountData.uncoverageCount}} - {{$t('api_test.home_page.detail_card.finished')}} + 已覆盖 {{"\xa0\xa0"}} - - {{caseCountData}} + + {{relevanceCountData.coverageCount}} @@ -122,7 +96,7 @@ export default { name: "RelevanceCaseCard", props:{ - caseCountData:{}, + relevanceCountData:{}, }, data() { return { diff --git a/frontend/src/business/components/track/home/components/ReviewList.vue b/frontend/src/business/components/track/home/components/ReviewList.vue index 5ec3b49d47..b46bb93d01 100644 --- a/frontend/src/business/components/track/home/components/ReviewList.vue +++ b/frontend/src/business/components/track/home/components/ReviewList.vue @@ -1,14 +1,14 @@ From 4243cfdf7bed3797baa44c9a3a2fbbae58b652c6 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 15 Mar 2021 11:34:51 +0800 Subject: [PATCH 4/9] =?UTF-8?q?fix:=20=E4=B8=BB=E9=A2=98=E8=89=B2=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/business/App.vue | 1 + .../components/common/head/HeaderLabelOperate.vue | 7 +++++-- .../src/business/components/track/home/TrackHome.vue | 4 ++-- frontend/src/business/store.js | 12 ++++++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/frontend/src/business/App.vue b/frontend/src/business/App.vue index a03bda8a6d..b2efe68a1b 100644 --- a/frontend/src/business/App.vue +++ b/frontend/src/business/App.vue @@ -62,6 +62,7 @@ export default { this.$get('/system/theme', res => { this.color = res.data ? res.data : ORIGIN_COLOR; setColor(this.color, this.color, this.color, this.color); + this.$store.commit('setTheme', res.data); }) } if (localStorage.getItem("store")) { diff --git a/frontend/src/business/components/common/head/HeaderLabelOperate.vue b/frontend/src/business/components/common/head/HeaderLabelOperate.vue index 66c9f275fd..b5764b6ea6 100644 --- a/frontend/src/business/components/common/head/HeaderLabelOperate.vue +++ b/frontend/src/business/components/common/head/HeaderLabelOperate.vue @@ -2,7 +2,7 @@
@@ -21,5 +21,8 @@ export default { diff --git a/frontend/src/business/components/track/home/TrackHome.vue b/frontend/src/business/components/track/home/TrackHome.vue index 1f0b14b7e8..084aff62dd 100644 --- a/frontend/src/business/components/track/home/TrackHome.vue +++ b/frontend/src/business/components/track/home/TrackHome.vue @@ -169,7 +169,7 @@ export default { type: 'bar', itemStyle: { normal: { - color: COUNT_NUMBER + color: this.$store.state.theme.theme ? this.$store.state.theme.theme : COUNT_NUMBER } } }, @@ -179,7 +179,7 @@ export default { type: 'bar', itemStyle: { normal: { - color: COUNT_NUMBER_SHALLOW + color: this.$store.state.theme.theme ? this.$store.state.theme.theme : COUNT_NUMBER_SHALLOW } } }] diff --git a/frontend/src/business/store.js b/frontend/src/business/store.js index c536ea0d38..4fbb5d7f17 100644 --- a/frontend/src/business/store.js +++ b/frontend/src/business/store.js @@ -50,11 +50,23 @@ const IsReadOnly = { } } +const Theme = { + state: { + theme: undefined + }, + mutations: { + setTheme(state, value) { + state.theme = value; + } + } +} + export default new Vuex.Store({ modules: { api: API, common: Common, switch: Switch, isReadOnly: IsReadOnly, + theme: Theme } }) From 82d7be618c1d3377988615dc7b6b644b9aeb46ac Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 15 Mar 2021 15:26:56 +0800 Subject: [PATCH 5/9] =?UTF-8?q?fix:=20=E4=B8=BB=E9=A2=98=E8=89=B2=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/pom.xml | 5 +++ .../metersphere/commons/utils/ShiroUtils.java | 2 + frontend/src/business/App.vue | 6 +-- frontend/src/business/components/xpack | 2 +- frontend/src/common/css/main.css | 1 + frontend/src/common/js/constants.js | 1 + frontend/src/common/js/utils.js | 40 +++++++++---------- frontend/src/login/Login.vue | 30 ++++++++------ 8 files changed, 50 insertions(+), 37 deletions(-) diff --git a/backend/pom.xml b/backend/pom.xml index edd70316fa..e3a2c2754e 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -541,6 +541,11 @@ + + + + + diff --git a/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java b/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java index 90c4e26e92..61f73dd9ad 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java @@ -42,6 +42,8 @@ public class ShiroUtils { //api-对外文档页面提供的查询接口 filterChainDefinitionMap.put("/api/document/**", "anon"); // filterChainDefinitionMap.put("/document/**", "anon"); + filterChainDefinitionMap.put("/system/theme", "anon"); + } public static void ignoreCsrfFilter(Map filterChainDefinitionMap) { diff --git a/frontend/src/business/App.vue b/frontend/src/business/App.vue index b2efe68a1b..f279581ae6 100644 --- a/frontend/src/business/App.vue +++ b/frontend/src/business/App.vue @@ -31,7 +31,7 @@ import MsView from "./components/common/router/View"; import MsUser from "./components/common/head/HeaderUser"; import MsHeaderOrgWs from "./components/common/head/HeaderOrgWs"; import MsLanguageSwitch from "./components/common/head/LanguageSwitch"; -import {hasLicense, saveLocalStorage, setColor, setOriginColor} from "@/common/js/utils"; +import {hasLicense, saveLocalStorage, setColor, setDefaultTheme} from "@/common/js/utils"; import {registerRequestHeaders} from "@/common/js/ajax"; import {ORIGIN_COLOR} from "@/common/js/constants"; @@ -55,13 +55,13 @@ export default { created() { registerRequestHeaders(); if (!hasLicense()) { - setOriginColor() + setDefaultTheme(); this.color = ORIGIN_COLOR; } else { // this.$get('/system/theme', res => { this.color = res.data ? res.data : ORIGIN_COLOR; - setColor(this.color, this.color, this.color, this.color); + setColor(this.color, this.color, this.color, this.color, this.color); this.$store.commit('setTheme', res.data); }) } diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index 4c33b9c3b1..b2571e06e8 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit 4c33b9c3b12a83da6d9bd2740262c6c8baaab819 +Subproject commit b2571e06e8b211821409115cc2c4a7c52cbac1db diff --git a/frontend/src/common/css/main.css b/frontend/src/common/css/main.css index 34a336f689..2595486214 100644 --- a/frontend/src/common/css/main.css +++ b/frontend/src/common/css/main.css @@ -17,6 +17,7 @@ body { /*--color: #2c2a48;*/ /*--color_shallow: #595591;*/ --color: ''; + --primary_color: ''; --color_shallow: ''; --count_number: ''; --count_number_shallow: ''; diff --git a/frontend/src/common/js/constants.js b/frontend/src/common/js/constants.js index cbaf36f974..e8c6de79f3 100644 --- a/frontend/src/common/js/constants.js +++ b/frontend/src/common/js/constants.js @@ -173,3 +173,4 @@ export const ORIGIN_COLOR = '#2c2a48'; export const ORIGIN_COLOR_SHALLOW = '#595591'; export const COUNT_NUMBER = '#6C317C'; export const COUNT_NUMBER_SHALLOW = '#CDB9D2'; +export const PRIMARY_COLOR = '#783887'; diff --git a/frontend/src/common/js/utils.js b/frontend/src/common/js/utils.js index 02822ea8e6..2463cec636 100644 --- a/frontend/src/common/js/utils.js +++ b/frontend/src/common/js/utils.js @@ -1,17 +1,17 @@ import { - COUNT_NUMBER, - COUNT_NUMBER_SHALLOW, - LicenseKey, - ORIGIN_COLOR, - ORIGIN_COLOR_SHALLOW, - PROJECT_ID, - REFRESH_SESSION_USER_URL, - ROLE_ADMIN, - ROLE_ORG_ADMIN, - ROLE_TEST_MANAGER, - ROLE_TEST_USER, - ROLE_TEST_VIEWER, - TokenKey + COUNT_NUMBER, + COUNT_NUMBER_SHALLOW, + LicenseKey, + ORIGIN_COLOR, + ORIGIN_COLOR_SHALLOW, PRIMARY_COLOR, + PROJECT_ID, + REFRESH_SESSION_USER_URL, + ROLE_ADMIN, + ROLE_ORG_ADMIN, + ROLE_TEST_MANAGER, + ROLE_TEST_USER, + ROLE_TEST_VIEWER, + TokenKey } from "./constants"; import axios from "axios"; import {jsPDF} from "jspdf"; @@ -354,19 +354,19 @@ export function objToStrMap(obj) { return strMap; } -export function getColor() { - return localStorage.getItem('color'); -} - -export function setColor(a, b, c, d) { +export function setColor(a, b, c, d, e) { + // 顶部菜单背景色 document.body.style.setProperty('--color', a); document.body.style.setProperty('--color_shallow', b); + // 首页颜色 document.body.style.setProperty('--count_number', c); document.body.style.setProperty('--count_number_shallow', d); + // 主颜色 + document.body.style.setProperty('--primary_color', e); } -export function setOriginColor() { - setColor(ORIGIN_COLOR, ORIGIN_COLOR_SHALLOW, COUNT_NUMBER, COUNT_NUMBER_SHALLOW); +export function setDefaultTheme() { + setColor(ORIGIN_COLOR, ORIGIN_COLOR_SHALLOW, COUNT_NUMBER, COUNT_NUMBER_SHALLOW, PRIMARY_COLOR); } export function publicKeyEncrypt(input, publicKey) { diff --git a/frontend/src/login/Login.vue b/frontend/src/login/Login.vue index 8ca8bc7da5..4ef3406a7b 100644 --- a/frontend/src/login/Login.vue +++ b/frontend/src/login/Login.vue @@ -56,7 +56,7 @@