Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/newpage/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import '@/app/ui/global.css';


export const metadata = {
title: 'cratespro',
description: 'Generated by Next.js',
}

export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}
89 changes: 89 additions & 0 deletions app/newpage/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import React from 'react';
import '@/app/ui/global.css';


const HomePage = () => {
return (
//紫色渐变
// <div className="min-h-screen bg-gray-900 text-white">
// {/* 头部和搜索部分 */}
// <div className="bg-gradient-to-b from-[#4D004D] to-white">
// <header className="p-4 flex justify-between items-center">
// <div className="text-2xl font-bold">open/source/insights</div>
// <nav>
// <ul className="flex space-x-5">
// <li><a href="#" className="hover:underline">About</a></li>
// <li><a href="#" className="hover:underline">Documentation</a></li>
// <li><a href="#" className="hover:underline">Blog</a></li>
// </ul>
// </nav>
// </header>
// <div className="flex flex-col items-center justify-center h-80">
// <h1 className="text-4xl font-bold mb-4">Understand your dependencies</h1>
// <p className="text-center mb-4">Your software and your users rely not only on the code you write, but also on the code your code depends on, the code that code depends on, and so on.</p>
// <div className="flex items-center mb-4">
// <input
// type="text"
// placeholder="Search for open source packages, advisories and projects"
// className="p-2 border-none rounded-md text-gray-800 w-2/3 max-w-xl"
// />
// <button className="bg-teal-600 text-white rounded-md p-2 ml-2 hover:bg-teal-700">Search</button>
// </div>
// </div>
// </div>


//绿色渐变
< div className="min-h-screen bg-gray-900 text-white" >
<header className="bg-teal-500 p-4 flex justify-between items-center">
<div className="text-2xl font-bold">open/source/insights</div>
<nav>
<ul className="flex space-x-5">
<li><a href="#" className="hover:underline">About</a></li>
<li><a href="#" className="hover:underline">Documentation</a></li>
<li><a href="#" className="hover:underline">Blog</a></li>
</ul>
</nav>
</header>
{/* 搜索部分 */}
<div className="flex flex-col items-center justify-center h-80 bg-gradient-to-b from-teal-500 to-gray-800">
<h1 className="text-4xl font-bold mb-4 ">Understand your dependencies</h1>
<p className="text-center mb-4">Your software and your users rely not only on the code you write, but also on the code your code depends on, the code that code depends on, and so on.</p>
<div className="flex items-center mb-4">
<input
type="text"
placeholder="Search for open source crates"
className="p-2 border-none rounded-md text-gray-800 w-80 max-w-2xl"
/>
<button className="bg-teal-600 text-white rounded-md p-2 ml-2 hover:bg-teal-700">Search</button>
</div>
</div>


{/* 分割线部分 */}
<div className="border-t-4 border-green-500 h-1/4"></div>

{/* 一些介绍 */}
<div className="container mx-auto p-10">
<div className="bg-gray-800 p-5 mb-6 rounded shadow-md">
<h2 className="text-2xl font-semibold">New features in the deps.dev API</h2>
<p className="mt-2">The deps.dev API, which provides free access to the data that powers this website, now has experimental batch and pull support, as well as a new version that comes with a stability guarantee and deprecation policy.</p>
<p className="mt-2">Learn more about the new features on our blog, or get started with the API documentation, and code examples.</p>
</div>

<div className="bg-gray-800 p-5 mb-6 rounded shadow-md">
<h2 className="text-2xl font-semibold">Seeing the big picture can be difficult—but it shouldn&apos;t be</h2>
<p className="mt-2">The Open Source Insights page for each package shows the full dependency graph and updates it every day. The information provided can help you make informed decisions about using, building, and maintaining your software.</p>
<p className="mt-2">With Open Source Insights, you can actually see the dependency graph for a package, then isolate the paths to a particular dependency. Or see whether a vulnerability in a dependency might affect your code. Or compare two versions of a package to see how the dependencies have changed in a new release.</p>
</div>

<div className="bg-gray-800 p-5 mb-6 rounded shadow-md">
<h2 className="text-2xl font-semibold">How it works</h2>
<p className="mt-2">The service repeatedly examines sites such as github.com, npmjs.com, and pkg.go.dev to find up-to-date information about open source software packages. Using that information, it builds for each package the full dependency graph from scratch—not just from package lock files—connecting it to the packages it depends on and to those that depend on it. This transitive dependency graph allows problems in any package to be made visible to the owners and users of any software they affect.</p>
</div>
</div>
</div >
);
}

export default HomePage;
74 changes: 74 additions & 0 deletions app/newpage/search/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"use client";

import { useState } from 'react';

export default function Home() {
//const [query,] = useState(''); //const [query, setQuery] = useState('');
// 使用假数据进行测试,const [results, setResults] = useState([
const [results,] = useState([
{ crate_name: "tokio", version: "1.41.1", date: "2023-01-01" },
{ crate_name: "tokio", version: "0.1.2", date: "2023-02-01" },
]);

// const search = async () => {
// // 待替换api
// const apiUrl = 'api';

// try {
// const response = await fetch(apiUrl, {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify({ query }),
// });

// const data = await response.json();
// setResults(data.results);
// } catch (error) {
// console.error('Error fetching data:', error);
// }
// };

return (
//页面顶部和搜索框
<div className="min-h-screen bg-gray-100">
<header className="bg-white shadow p-4">
<div className="flex justify-between items-center">
<div className="text-xl font-bold flex items-center space-x-1">
<span>open</span>
<span className="text-green-500">/</span>
<span>source</span>
<span className="text-green-500">/</span>
<span>insights</span>
</div>
<div className="flex items-center space-x-2">
<input
type="text"
className="p-2 border border-gray-300 rounded-l-md focus:outline-none focus:ring-2 focus:ring-blue-500"
placeholder="Search..."
/>
<button className="bg-blue-600 text-white px-4 py-2 rounded-r-md hover:bg-blue-700">
Search
</button>
</div>
</div>
</header>

{/*搜索数据展示 */}
<div className="max-w-2xl ml-10 p-4">
<div id="results" className="space-y-4">
{results.map((item, index) => (
<div
key={index}
className="p-4 rounded-md hover:bg-blue-100 transition"
>
<strong>{item.crate_name}</strong>
<div>Crate {item.version}Published {item.date}</div>
</div>
))}
</div>
</div>
</div>
);
}
Empty file added app/newpage/styles.css
Empty file.