This commit is contained in:
quantulr
2023-10-27 17:29:50 +08:00
parent dd9ae31b30
commit 73bc779168
31 changed files with 591 additions and 165 deletions

View File

@ -0,0 +1,26 @@
import { ReactNode } from "react";
import circle from "@/app/assets/circle.png";
import Image from "next/image";
import LeftNav from "@/app/components/LeftNav";
import ArticleLayout from "@/app/components/ArticleLayout";
const navLinks = [
{ title: "人才概况", href: "/" },
{ title: "人才概况", href: "/3" },
{ title: "人才概况", href: "/4" },
{ title: "人才概况", href: "/5" },
];
const Layout = ({
children,
params,
}: {
children: ReactNode;
params: {
articleId: string;
};
}) => {
return <ArticleLayout>{children}</ArticleLayout>;
};
export default Layout;

View File

@ -0,0 +1,17 @@
import { articleDetail } from "@/app/api/articles";
import ArticleContent from "@/app/components/ArticleContent";
export default async function Article({
params,
}: {
params: {
articleId: string;
};
}) {
const data = await articleDetail({ id: params.articleId });
return (
<div className={"ml-2.5"}>
<ArticleContent article={data} />
</div>
);
}

View File

@ -0,0 +1,7 @@
import React from "react";
const ResearchProgress = () => {
return <div></div>;
};
export default ResearchProgress;

View File

@ -0,0 +1,5 @@
const Page = () => {
return <div>overview</div>;
};
export default Page;

24
app/api/articles.ts Normal file
View File

@ -0,0 +1,24 @@
import request from "@/app/lib/request";
import { BaseResponse, PageData } from "@/app/types/base";
import {
Article,
ArticleDetail,
ArticleDetailParams,
ArticleListParams,
} from "@/app/types/article";
export const listArticles = (params: ArticleListParams) =>
request
.get<never, BaseResponse<PageData<Article>>>("/article/list", {
params,
})
.then((res) => {
return res.data;
});
export const articleDetail = (params: ArticleDetailParams) =>
request
.get<never, BaseResponse<ArticleDetail>>("/pc/articleDetail", {
params,
})
.then((res) => res.data);

BIN
app/assets/banner.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
app/assets/circle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
app/assets/footer.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
app/assets/left-banner.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@ -0,0 +1,11 @@
.articleBlockTitleBar {
background: linear-gradient(
589deg,
rgba(152, 194, 233, 1) 35.96491228070175%,
rgba(15, 111, 202, 1) 100%
);
}
.articlesList li:not(:last-child) {
border-bottom: 1px dashed;
}

BIN
app/assets/trumpet-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

View File

@ -0,0 +1,60 @@
import Image from "next/image";
import trumpetIcon from "@/app/assets/trumpet-icon.png";
import styles from "@/app/assets/page.module.css";
import Link from "next/link";
import request from "@/app/lib/request";
import { listArticles } from "@/app/api/articles";
interface ArticleLink {
title: string;
date?: string;
href: string;
}
const ArticleBlock = async ({
title,
width,
height,
category,
linkPrefix,
}: {
title: string;
height?: number | string;
width?: number | string;
category: string;
linkPrefix: string;
}) => {
const data = await listArticles({ cid: category });
return (
<div
style={{
width,
height,
}}
className={"flex flex-col"}
>
<div
className={`title-bar flex items-center px-2 ${styles.articleBlockTitleBar}`}
>
<Image width={30} height={30} src={trumpetIcon} alt={"trumpet icon"} />
<span className={"ml-2 text-[14px]"}>{title}</span>
</div>
<div className={`${styles.articlesList} bg-[#e1f1fd] flex-1`}>
<ul>
{data.lists.map((article) => (
<li className={"h-7 px-1 flex items-center"} key={article.id}>
<Link
className={"w-full truncate text-xs"}
href={`${linkPrefix}/${article.id}`}
>
{article.title}
</Link>
</li>
))}
</ul>
</div>
</div>
);
};
export default ArticleBlock;

View File

@ -0,0 +1,15 @@
import React from "react";
import { ArticleDetail } from "@/app/types/article";
const ArticleContent = ({ article }: { article: ArticleDetail }) => {
return (
<div className={"bg-white px-5 py-4 h-full"}>
<h1 className={"text-[18px] text-[#054786] text-center font-bold"}>
{article.title}
</h1>
<div dangerouslySetInnerHTML={{ __html: article.content }}></div>
</div>
);
};
export default ArticleContent;

View File

@ -0,0 +1,21 @@
import LeftNav from "@/app/components/LeftNav";
import { ReactNode } from "react";
const ArticleLayout = ({
children,
navs,
}: {
children: ReactNode;
navs: any;
}) => {
return (
<div className={"flex bg-[#6bb7f6] p-2.5"}>
<div className={"left-side w-[325px]"}>
<LeftNav />
</div>
<div className={"flex-1"}>{children}</div>
</div>
);
};
export default ArticleLayout;

View File

@ -0,0 +1,13 @@
.navContent {
background: linear-gradient(
90deg,
rgba(15, 111, 202, 0.7710280373831776) 34.21052631578947%,
rgba(32, 151, 243, 0.6214953271028038) 100%
);
.navItems {
li:not(:last-child) {
border-bottom: 1px solid #ffffff;
}
}
}

View File

@ -0,0 +1,56 @@
import React from "react";
import Image from "next/image";
import circle from "@/app/assets/circle.png";
import styles from "./LeftNav.module.scss";
import Link from "next/link";
const LeftNav = () => {
return (
<div className={"left-nav min-h-[600px] bg-[#d7ecfd] rounded shadow"}>
<div className={"flex items-center pl-2"}>
<Image src={circle} alt={"circle icon"} height={16} width={16} />
<span className={"pl-2"}></span>
</div>
<div
className={`${styles.navContent} mt-3 mx-3 rounded-lg px-2.5 py-[5px]`}
>
<ul className={styles.navItems}>
<li>
<Link
className={"text-sm px-[9px] py-[7px] block text-white"}
href={"/"}
>
</Link>
</li>
<li>
<Link
className={"text-sm px-[9px] py-[7px] block text-white"}
href={"/"}
>
</Link>
</li>
<li>
<Link
className={"text-sm px-[9px] py-[7px] block text-white"}
href={"/"}
>
</Link>
</li>
<li>
<Link
className={"text-sm px-[9px] py-[7px] block text-white"}
href={"/"}
>
</Link>
</li>
</ul>
</div>
</div>
);
};
export default LeftNav;

View File

@ -2,26 +2,26 @@
@tailwind components;
@tailwind utilities;
:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}
/*:root {*/
/* --foreground-rgb: 0, 0, 0;*/
/* --background-start-rgb: 214, 219, 220;*/
/* --background-end-rgb: 255, 255, 255;*/
/*}*/
@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
}
/*@media (prefers-color-scheme: dark) {*/
/* :root {*/
/* --foreground-rgb: 255, 255, 255;*/
/* --background-start-rgb: 0, 0, 0;*/
/* --background-end-rgb: 0, 0, 0;*/
/* }*/
/*}*/
body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}
/*body {*/
/* color: rgb(var(--foreground-rgb));*/
/* background: linear-gradient(*/
/* to bottom,*/
/* transparent,*/
/* rgb(var(--background-end-rgb))*/
/* )*/
/* rgb(var(--background-start-rgb));*/
/*}*/

View File

@ -1,22 +1,57 @@
import type { Metadata } from 'next'
import { Inter } from 'next/font/google'
import './globals.css'
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
import Link from "next/link";
import footer from "@/app/assets/footer.jpg";
import Image from "next/image";
import banner from "@/app/assets/banner.jpg";
import { ReactNode } from "react";
const inter = Inter({ subsets: ['latin'] })
const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
}
title: "中国科学院重庆绿色智能技术研究院合肥分院",
description: "Generated by create next app",
};
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
const navLinks = [
{ title: "首页", href: "/" },
{ title: "机构设置", href: "#" },
{ title: "人才队伍", href: "#" },
{ title: "科研进展", href: "#" },
{ title: "科技成果", href: "#" },
{ title: "学术交流", href: "#" },
{ title: "成果转化服务", href: "#" },
{ title: "中科院科技资源共享平台", href: "#" },
{ title: "联系我们", href: "#" },
];
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
<body className={inter.className}>
<main className={"w-[1000px] m-auto"}>
<Image className={"w-full"} src={banner} alt={"banner"} />
<nav className={"main-nav bg-[#1958a7] h-[38px]"}>
<ul className={"w-full h-full flex"}>
{navLinks.map((link, index) => (
<li key={link.title + index}>
<Link
href={link.href}
className={
"text-white text-sm h-[38px] flex justify-center items-center min-w-[60px] mx-2.5"
}
>
{link.title}
</Link>
</li>
))}
</ul>
</nav>
{children}
<Image src={footer} alt={"footer"} className={"mt-4"} />
</main>
</body>
</html>
)
);
}

11
app/lib/request.ts Normal file
View File

@ -0,0 +1,11 @@
import axios from "axios";
const axiosInstance = axios.create({
baseURL: "http://localhost:8084/api",
});
axiosInstance.interceptors.response.use((response) => {
return response.data;
});
export default axiosInstance;

View File

@ -1,113 +1,61 @@
import Image from 'next/image'
import Image from "next/image";
import leftBanner from "./assets/left-banner.jpg";
import ArticleBlock from "@/app/components/ArticleBlock";
export default function Home() {
export default async function Home() {
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<div className="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
Get started by editing&nbsp;
<code className="font-mono font-bold">app/page.tsx</code>
</p>
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
className="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
By{' '}
<Image
src="/vercel.svg"
alt="Vercel Logo"
className="dark:invert"
width={100}
height={24}
priority
/>
</a>
<main className={"flex justify-between"}>
<div className={"left-side w-[222px]"}>
<Image src={leftBanner} alt={"left banner"} />
</div>
<div className={"main-content w-[513px]"}>
<ArticleBlock
height={218}
title={"综合新闻"}
category={"4"}
linkPrefix={"/general-news"}
></ArticleBlock>
<div className={"flex justify-between mt-1"}>
<ArticleBlock
width={250}
height={218}
title={"科研进展"}
category={"5"}
linkPrefix={"/research-progress"}
></ArticleBlock>
<ArticleBlock
width={250}
height={218}
title={"学术活动"}
category={"6"}
linkPrefix={"/academic-events"}
></ArticleBlock>
</div>
<div className={"flex justify-between mt-1"}>
<ArticleBlock
width={250}
height={218}
title={"科技成果"}
category={"7"}
linkPrefix={"/technological-achievements"}
></ArticleBlock>
<ArticleBlock
width={250}
height={218}
title={"媒体扫描"}
category={"8"}
linkPrefix={"/media-scan"}
></ArticleBlock>
</div>
</div>
<div className="relative flex place-items-center before:absolute before:h-[300px] before:w-[480px] before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-[240px] after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 before:lg:h-[360px] z-[-1]">
<Image
className="relative dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
src="/next.svg"
alt="Next.js Logo"
width={180}
height={37}
priority
/>
</div>
<div className="mb-32 grid text-center lg:max-w-5xl lg:w-full lg:mb-0 lg:grid-cols-4 lg:text-left">
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Docs{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Find in-depth information about Next.js features and API.
</p>
</a>
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Learn{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Learn about Next.js in an interactive course with&nbsp;quizzes!
</p>
</a>
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Templates{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Explore the Next.js 13 playground.
</p>
</a>
<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Deploy{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Instantly deploy your Next.js site to a shareable URL with Vercel.
</p>
</a>
<div className={"right-side w-[225px]"}>
<ArticleBlock
linkPrefix={"/announcements"}
category={"3"}
height={275}
title={"公告通知"}
></ArticleBlock>
</div>
</main>
)
);
}

37
app/types/article.ts Normal file
View File

@ -0,0 +1,37 @@
export interface Article {
id: number;
title: string;
image: string;
intro: string;
visit: number;
collect: boolean;
createTime: string;
}
export interface ArticleListParams {
cid?: string;
}
export interface ArticleDetail {
id: number;
cid: number;
category: string;
title: string;
intro: string;
summary: string;
image: string;
content: string;
author: string;
visit: number;
sort: number;
isCollect: number;
createTime: string;
updateTime: string;
// prev: Prev
// next: Next
// news: News[]
}
export interface ArticleDetailParams {
id: string;
}

13
app/types/base.ts Normal file
View File

@ -0,0 +1,13 @@
export interface BaseResponse<T> {
code: number;
msg: string;
data: T;
}
export interface PageData<T> {
count: number;
pageNo: number;
pageSize: number;
extend: any;
lists: T[];
}