diff --git a/.env b/.env index cf6ed3e..a427653 100644 --- a/.env +++ b/.env @@ -3,7 +3,8 @@ # add CRATES_PRO_HOST, CRATES_PRO_INTERNAL_HOST to your enviroment for development -CRATES_PRO_HOST=http://210.28.134.203:6888 -CRATES_PRO_INTERNAL_HOST=http://210.28.134.203:6888 +CRATES_PRO_HOST=http://210.28.134.203:31688 +CRATES_PRO_INTERNAL_HOST=http://210.28.134.203:31688 + +SECRET_KEY=$YOUR_SECRET_KEY #(not prefixed with NEXT_PUBLIC_ ) -SECRET_KEY=$YOUR_SECRET_KEY #(not prefixed with NEXT_PUBLIC_ ) \ No newline at end of file diff --git a/app/[nsfront]/[nsbehind]/[name]/[version]/dependencies/graph/page.tsx b/app/[nsfront]/[nsbehind]/[name]/[version]/dependencies/graph/page.tsx index 68114dc..cb83328 100644 --- a/app/[nsfront]/[nsbehind]/[name]/[version]/dependencies/graph/page.tsx +++ b/app/[nsfront]/[nsbehind]/[name]/[version]/dependencies/graph/page.tsx @@ -43,7 +43,7 @@ const CratePage = () => { } }; fetchCrateData(); // 调用函数来获取数据 - }, [params.name, params.version, params.nsfront, params.nsbehind]); // 依赖项数组,确保在 crateName 或 version 改变时重新获取数据 + },); // 依赖项数组,确保在 crateName 或 version 改变时重新获取数据 if (loading) return
Loading...
; if (error) return
Error: {error}
; diff --git a/app/[nsfront]/[nsbehind]/[name]/[version]/page.tsx b/app/[nsfront]/[nsbehind]/[name]/[version]/page.tsx index 3736c1f..c407475 100644 --- a/app/[nsfront]/[nsbehind]/[name]/[version]/page.tsx +++ b/app/[nsfront]/[nsbehind]/[name]/[version]/page.tsx @@ -4,12 +4,161 @@ import React, { useEffect, useState } from 'react'; import Link from 'next/link'; import { cratesInfo } from '@/app/lib/all_interface'; import { useParams } from 'next/navigation'; +import { Pagination } from 'antd'; + +interface CVE { + subtitle?: string; + id?: string; + reported?: string; + issued?: string; + package?: string; + ttype?: string; + aliases?: string | string[]; + keywords?: string; + patched?: string; + unaffected?: string; + url?: string; + reference?: string; + description?: string; +} + +const CveCard = ({ cve }: { cve: CVE }) => ( +
+ {/* 标题和ID */} +
+

+ {cve.subtitle || 'No subtitle available'} +

+

+ {cve.id || 'No ID available'} +

+
+ + {/* 时间信息 */} +
+
+ Reported + {cve.reported || 'Not specified'} +
+ +
+ + {/* 时间信息 */} +
+ Issued + {cve.issued || 'Not specified'} +
+ + + + {/* 包信息 */} +
+ Package + {cve.package || 'No package info'} +
+ + + + + {/* 类型信息 */} + {cve.ttype && ( +
+ Type + {cve.ttype} +
+ )} + + + {/* 别名信息 */} + {cve.aliases && ( +
+ Aliases + {Array.isArray(cve.aliases) ? cve.aliases.join(', ') : cve.aliases} +
+ + )} + + {/* 关键词 */} + {cve.keywords && ( +
+ Keywords + {cve.keywords} +
+ )} + + + {/* 修复状态 */} + {cve.patched && ( +
+ Patched + {cve.patched} +
+ + )} + + {/* 未受影响版本 */} + {cve.unaffected && ( +
+ Unaffected + {cve.unaffected} +
+ + )} + + {/* URL */} + {cve.url && ( +
+ Url + + {cve.url} + +
+ )} + + {/* 引用链接 */} + {cve.reference && ( +
+

Reference

+
+ {cve.reference.split(' ').map((url: string, i: number) => ( + + {url} + + ))} +
+
+ )} + + {/* 描述信息 */} + {cve.description && ( +
+

Description

+

{cve.description}

+
+ )} +
+); const CratePage = () => { const params = useParams(); const [results, setResults] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); + const [packageCurrentPage, setPackageCurrentPage] = useState(1); + const [depCurrentPage, setDepCurrentPage] = useState(1); + const itemsPerPage = 1; useEffect(() => { const fetchCrateData = async () => { @@ -20,6 +169,7 @@ const CratePage = () => { } const data = await response.json(); setResults(data); + console.log('data in overviewwwwwwwww:', data); } catch (error) { console.error('Error fetching data:', error); setError('An error occurred'); @@ -34,84 +184,109 @@ const CratePage = () => { if (loading) return

Loading...

; if (error) return

Error: {error}

; + // 计算当前页的 CVE 数据 + const getCurrentPageItems = (items: CVE[], currentPage: number) => { + const start = (currentPage - 1) * itemsPerPage; + const end = start + itemsPerPage; + return items.slice(start, end); + }; + return (
- {/* Security Advisories */} + {/* Security Advisories 主框 */}
- -
-

Security Advisories

- - {results ? results.cves.length + results.dep_cves.length : 0} - -
-

In this package

-
-
- {results && results.cves && results.cves.length > 0 ? ( - results.cves.map((cve, index) => ( -
-

- {cve.id !== '' ? JSON.stringify(cve.small_desc) : 'No results available'} -

-

- {cve.id !== '' ? JSON.stringify(cve.id) : 'No results available'} -

- -

-

SIMILAR ADVISORIES
- {cve.id !== '' ? JSON.stringify(cve.aliases) : 'No results available'} -

-
- )) - ) : ( -

No results available

- )} + {/* Security Advisories 标题 */} +
+
+

Security Advisories

+ 0 + ? 'rgb(179, 20, 18)' + : 'rgb(34, 197, 94)' + }} + > + {results ? (results.cves?.length || 0) + (results.dep_cves?.length || 0) : 0} +
- {/* */}
+ {/* 两个子框的容器 */} +
+ {/* In this package 框 */} +
+
+

In this package

+ 0) ? 'rgb(179, 20, 18)' : 'rgb(34, 197, 94)' }}> + {results?.cves?.length || 0} + +
+
+ {results?.cves && results.cves.length > 0 ? ( + <> + {getCurrentPageItems(results.cves, packageCurrentPage).map((cve, index) => ( + + ))} + {results.cves.length > itemsPerPage && ( +
+ +
+ )} + + ) : ( +

No vulnerabilities found

+ )} +
+
- -

In the dependencies

-
- {results && results.dep_cves && results.dep_cves.length > 0 ? ( - results.dep_cves.map((dep_cves, index) => ( - <> -

- {dep_cves.id !== '' ? JSON.stringify(dep_cves.small_desc) : 'No results available'} -

-

- {dep_cves.id !== '' ? JSON.stringify(dep_cves.id) : 'No results available'} -

-

-

SIMILAR ADVISORIES
- {dep_cves.id !== '' ? JSON.stringify(dep_cves.aliases) : 'No results available'} -

- - )) - ) : ( -

No results available

- )} + {/* In the dependencies 框 */} +
+
+

In the dependencies

+ 0 ? 'rgb(179, 20, 18)' : 'rgb(34, 197, 94)' }}> + {results?.dep_cves?.length || 0} + +
+
+ {results?.dep_cves && results.dep_cves.length > 0 ? ( + <> + {getCurrentPageItems(results.dep_cves, depCurrentPage).map((cve, index) => ( + + ))} + {results.dep_cves.length > itemsPerPage && ( +
+ +
+ )} + + ) : ( +

No vulnerabilities found

+ )} +
+
-
{/* Licenses */} diff --git a/components/VersionsTable.tsx b/components/VersionsTable.tsx index 0addd27..810fb7d 100644 --- a/components/VersionsTable.tsx +++ b/components/VersionsTable.tsx @@ -63,13 +63,13 @@ const VersionsTable: React.FC = () => { render: (text: string) => {text}, }, { - title: 'Publish Day', + title: 'Published', dataIndex: 'publishDay', // 修改为使用 publishDay key: 'publishDay', // 修改为使用 publishDay render: (text: string) => {text}, }, { - title: 'Dependents Number', + title: 'Dependents', dataIndex: 'dependents', key: 'dependents', render: (text: number) => {text},