From 2f28e7e6ebc0f4f7985482ca653a505b54a5e36c Mon Sep 17 00:00:00 2001 From: vinland100 Date: Thu, 25 Dec 2025 13:42:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E4=B8=ADGitea=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E4=BB=8D=E7=84=B6=E6=98=BE=E7=A4=BA=E4=B8=BA'=E5=85=B6?= =?UTF-8?q?=E4=BB=96'=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../audit/components/BasicConfig.tsx | 4 +- frontend/src/pages/ProjectDetail.tsx | 49 +++++++++---------- frontend/src/pages/Projects.tsx | 16 +++--- frontend/src/pages/TaskDetail.tsx | 17 +++---- 4 files changed, 41 insertions(+), 45 deletions(-) diff --git a/frontend/src/components/audit/components/BasicConfig.tsx b/frontend/src/components/audit/components/BasicConfig.tsx index c82968e..b613f85 100644 --- a/frontend/src/components/audit/components/BasicConfig.tsx +++ b/frontend/src/components/audit/components/BasicConfig.tsx @@ -9,7 +9,7 @@ import { } from "@/components/ui/select"; import { GitBranch, Zap, Info } from "lucide-react"; import type { Project, CreateAuditTaskForm } from "@/shared/types"; -import { isRepositoryProject, isZipProject } from "@/shared/utils/projectUtils"; +import { isRepositoryProject, isZipProject, getRepositoryPlatformLabel } from "@/shared/utils/projectUtils"; import ZipFileSection from "./ZipFileSection"; import type { ZipFileMeta } from "@/shared/utils/zipStorage"; @@ -138,7 +138,7 @@ function ProjectInfoCard({ project }: { project: Project }) { {isRepo && ( <>

- 仓库平台:{project.repository_type?.toUpperCase() || "OTHER"} + 仓库平台:{getRepositoryPlatformLabel(project.repository_type)}

默认分支:{project.default_branch}

diff --git a/frontend/src/pages/ProjectDetail.tsx b/frontend/src/pages/ProjectDetail.tsx index 9d282c2..0d809ed 100644 --- a/frontend/src/pages/ProjectDetail.tsx +++ b/frontend/src/pages/ProjectDetail.tsx @@ -34,7 +34,7 @@ import { api } from "@/shared/config/database"; import { runRepositoryAudit, scanStoredZipFile } from "@/features/projects/services"; import type { Project, AuditTask, CreateProjectForm } from "@/shared/types"; import { hasZipFile } from "@/shared/utils/zipStorage"; -import { isRepositoryProject, getSourceTypeLabel } from "@/shared/utils/projectUtils"; +import { isRepositoryProject, getSourceTypeLabel, getRepositoryPlatformLabel } from "@/shared/utils/projectUtils"; import { toast } from "sonner"; import CreateTaskDialog from "@/components/audit/CreateTaskDialog"; import FileSelectionDialog from "@/components/audit/FileSelectionDialog"; @@ -475,8 +475,7 @@ export default function ProjectDetail() {
仓库平台 - {project.repository_type === 'github' ? 'GitHub' : - project.repository_type === 'gitlab' ? 'GitLab' : '其他'} + {getRepositoryPlatformLabel(project.repository_type)}
@@ -529,12 +528,11 @@ export default function ProjectDetail() { className="flex items-center justify-between p-3 bg-muted/50 rounded-lg hover:bg-muted transition-all group" >
-
+
{getStatusIcon(task.status)}
@@ -579,12 +577,11 @@ export default function ProjectDetail() {
-
+
{getStatusIcon(task.status)}
@@ -676,12 +673,11 @@ export default function ProjectDetail() {
-
+
@@ -695,13 +691,13 @@ export default function ProjectDetail() { {issue.severity === 'critical' ? '严重' : issue.severity === 'high' ? '高' : - issue.severity === 'medium' ? '中等' : '低'} + issue.severity === 'medium' ? '中等' : '低'}

@@ -785,6 +781,7 @@ export default function ProjectDetail() { GitHub GitLab + Gitea 其他 @@ -831,14 +828,14 @@ export default function ProjectDetail() { className={`flex items-center space-x-2 p-3 border cursor-pointer transition-all rounded ${editForm.programming_languages?.includes(lang) ? 'border-primary bg-primary/10 text-primary' : 'border-border hover:border-border text-muted-foreground' - }`} + }`} onClick={() => handleToggleLanguage(lang)} >

{editForm.programming_languages?.includes(lang) && ( diff --git a/frontend/src/pages/Projects.tsx b/frontend/src/pages/Projects.tsx index f2c0a72..8ad4c30 100644 --- a/frontend/src/pages/Projects.tsx +++ b/frontend/src/pages/Projects.tsx @@ -485,10 +485,10 @@ export default function Projects() { - GITHUB - GITLAB - GITEA - OTHER + GitHub + GitLab + Gitea + 其他
@@ -1016,10 +1016,10 @@ export default function Projects() { - GITHUB - GITLAB - GITEA - OTHER + GitHub + GitLab + Gitea + 其他
diff --git a/frontend/src/pages/TaskDetail.tsx b/frontend/src/pages/TaskDetail.tsx index 0d05359..21d3372 100644 --- a/frontend/src/pages/TaskDetail.tsx +++ b/frontend/src/pages/TaskDetail.tsx @@ -36,7 +36,7 @@ import type { AuditTask, AuditIssue } from "@/shared/types"; import { toast } from "sonner"; import ExportReportDialog from "@/components/reports/ExportReportDialog"; import { calculateTaskProgress } from "@/shared/utils/utils"; -import { isRepositoryProject, getSourceTypeLabel } from "@/shared/utils/projectUtils"; +import { isRepositoryProject, getSourceTypeLabel, getRepositoryPlatformLabel } from "@/shared/utils/projectUtils"; // AI explanation parser function parseAIExplanation(aiExplanation: string) { @@ -86,12 +86,11 @@ function IssuesList({ issues }: { issues: AuditIssue[] }) {
-
+
{getTypeIcon(issue.issue_type)}
@@ -112,7 +111,7 @@ function IssuesList({ issues }: { issues: AuditIssue[] }) { {issue.severity === 'critical' ? '严重' : issue.severity === 'high' ? '高' : - issue.severity === 'medium' ? '中等' : '低'} + issue.severity === 'medium' ? '中等' : '低'}
@@ -702,7 +701,7 @@ export default function TaskDetail() { {isRepositoryProject(task.project) && (

仓库平台

-

{task.project.repository_type?.toUpperCase() || 'OTHER'}

+

{getRepositoryPlatformLabel(task.project.repository_type)}

)} {task.project.programming_languages && ( From 84fa2b52669abbb6e283c83e1c468fda1776b196 Mon Sep 17 00:00:00 2001 From: vinland100 Date: Thu, 25 Dec 2025 14:11:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?refactor(frontend):=20=E9=87=87=E7=94=A8?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E5=8C=96=E5=B8=B8=E9=87=8F=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E4=BB=93=E5=BA=93=E5=B9=B3=E5=8F=B0=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/ProjectDetail.tsx | 29 ++++++++++--------- frontend/src/pages/Projects.tsx | 20 +++++++------ frontend/src/shared/constants/index.ts | 7 ----- frontend/src/shared/constants/projectTypes.ts | 18 ++++++++---- frontend/src/shared/utils/projectUtils.ts | 9 ++---- 5 files changed, 40 insertions(+), 43 deletions(-) diff --git a/frontend/src/pages/ProjectDetail.tsx b/frontend/src/pages/ProjectDetail.tsx index 0d809ed..28ea711 100644 --- a/frontend/src/pages/ProjectDetail.tsx +++ b/frontend/src/pages/ProjectDetail.tsx @@ -40,7 +40,7 @@ import CreateTaskDialog from "@/components/audit/CreateTaskDialog"; import FileSelectionDialog from "@/components/audit/FileSelectionDialog"; import TerminalProgressDialog from "@/components/audit/TerminalProgressDialog"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog"; -import { SUPPORTED_LANGUAGES } from "@/shared/constants"; +import { SUPPORTED_LANGUAGES, REPOSITORY_PLATFORMS } from "@/shared/constants"; export default function ProjectDetail() { const { id } = useParams<{ id: string }>(); @@ -529,9 +529,9 @@ export default function ProjectDetail() { >
{getStatusIcon(task.status)}
@@ -578,9 +578,9 @@ export default function ProjectDetail() {
{getStatusIcon(task.status)}
@@ -674,9 +674,9 @@ export default function ProjectDetail() {
@@ -779,10 +779,11 @@ export default function ProjectDetail() { - GitHub - GitLab - Gitea - 其他 + {REPOSITORY_PLATFORMS.map((platform) => ( + + {platform.label} + + ))}
diff --git a/frontend/src/pages/Projects.tsx b/frontend/src/pages/Projects.tsx index 8ad4c30..4e3cb0c 100644 --- a/frontend/src/pages/Projects.tsx +++ b/frontend/src/pages/Projects.tsx @@ -44,7 +44,7 @@ import { Link } from "react-router-dom"; import { toast } from "sonner"; import CreateTaskDialog from "@/components/audit/CreateTaskDialog"; import TerminalProgressDialog from "@/components/audit/TerminalProgressDialog"; -import { SUPPORTED_LANGUAGES } from "@/shared/constants"; +import { SUPPORTED_LANGUAGES, REPOSITORY_PLATFORMS } from "@/shared/constants"; export default function Projects() { const [projects, setProjects] = useState([]); @@ -485,10 +485,11 @@ export default function Projects() { - GitHub - GitLab - Gitea - 其他 + {REPOSITORY_PLATFORMS.map((platform) => ( + + {platform.label} + + ))}
@@ -1016,10 +1017,11 @@ export default function Projects() { - GitHub - GitLab - Gitea - 其他 + {REPOSITORY_PLATFORMS.map((platform) => ( + + {platform.label} + + ))}
diff --git a/frontend/src/shared/constants/index.ts b/frontend/src/shared/constants/index.ts index 2f48818..401ecb2 100644 --- a/frontend/src/shared/constants/index.ts +++ b/frontend/src/shared/constants/index.ts @@ -62,13 +62,6 @@ export const PROJECT_SOURCE_TYPES = { ZIP: 'zip', } as const; -// 仓库平台类型 -export const REPOSITORY_TYPES = { - GITHUB: 'github', - GITLAB: 'gitlab', - OTHER: 'other', -} as const; - // 分析深度 export const ANALYSIS_DEPTH = { BASIC: 'basic', diff --git a/frontend/src/shared/constants/projectTypes.ts b/frontend/src/shared/constants/projectTypes.ts index 55e6d47..4e78e9b 100644 --- a/frontend/src/shared/constants/projectTypes.ts +++ b/frontend/src/shared/constants/projectTypes.ts @@ -22,17 +22,23 @@ export const PROJECT_SOURCE_TYPES: Array<{ } ]; +// 仓库平台显示名称 +export const REPOSITORY_PLATFORM_LABELS: Record = { + github: 'GitHub', + gitlab: 'GitLab', + gitea: 'Gitea', + other: '其他', +}; + // 仓库平台选项 export const REPOSITORY_PLATFORMS: Array<{ value: RepositoryPlatform; label: string; icon?: string; -}> = [ - { value: 'github', label: 'GitHub' }, - { value: 'gitlab', label: 'GitLab' }, - { value: 'gitea', label: 'Gitea' }, - { value: 'other', label: '其他' } - ]; +}> = Object.entries(REPOSITORY_PLATFORM_LABELS).map(([value, label]) => ({ + value: value as RepositoryPlatform, + label +})); // 项目来源类型的颜色配置 export const SOURCE_TYPE_COLORS: Record = { - github: 'GitHub', - gitlab: 'GitLab', - gitea: 'Gitea', - other: '其他' - }; - return labels[platform || 'other'] || '其他'; + return REPOSITORY_PLATFORM_LABELS[platform as keyof typeof REPOSITORY_PLATFORM_LABELS] || REPOSITORY_PLATFORM_LABELS.other; } /**