Compare commits
7
Commits
aa227ab369
...
84c60ab758
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84c60ab758 | ||
|
|
7d0854127a | ||
|
|
9ce0c5704a | ||
|
|
4f687ba457 | ||
|
|
4725e373c2 | ||
|
|
812f0b291f | ||
|
|
46ab81ae3b |
No files matched your search
@@ -1,73 +1,204 @@
|
||||
# React + TypeScript + Vite
|
||||
# 筱周の网站 (XiaoZhou's Website)
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
个人主页 —— 终端 / 黑客风格,黑底 + emerald 主题,等宽字体 Geist。
|
||||
|
||||
Currently, two official plugins are available:
|
||||
- 首页 `/`:视差 Hero、打字机标题、导航卡片,以及「关于我 / 项目展示 / 联系我」三个区块。
|
||||
- 更多 `/more`:应用聚合页,把自建的小工具集中到一个入口。
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
||||
## 技术栈
|
||||
|
||||
## React Compiler
|
||||
| 类别 | 选型 |
|
||||
| --- | --- |
|
||||
| 框架 | React 19 + TypeScript |
|
||||
| 构建 | Vite 8 |
|
||||
| 样式 | Tailwind CSS 4 |
|
||||
| 图标 | lucide-react |
|
||||
| 字体 | Geist Variable (`@fontsource-variable/geist`) |
|
||||
| 路由 | 自研轻量路由(零依赖,见 `src/router/`) |
|
||||
|
||||
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
||||
## 快速开始
|
||||
|
||||
## Expanding the ESLint configuration
|
||||
|
||||
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||
|
||||
```js
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
|
||||
// Remove tseslint.configs.recommended and replace with this
|
||||
tseslint.configs.recommendedTypeChecked,
|
||||
// Alternatively, use this for stricter rules
|
||||
tseslint.configs.strictTypeChecked,
|
||||
// Optionally, add this for stylistic rules
|
||||
tseslint.configs.stylisticTypeChecked,
|
||||
|
||||
// Other configs...
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```bash
|
||||
npm install # 安装依赖
|
||||
npm run dev # 启动开发服务器(HMR)
|
||||
npm run build # 生产构建 + 后处理
|
||||
npm run preview # 本地预览构建产物
|
||||
npm run lint # ESLint 检查
|
||||
```
|
||||
|
||||
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||
> 构建脚本为 `tsc -b && vite build && node scripts/postbuild.mjs`,最后一步会把
|
||||
> `dist/index.html` 复制成 `dist/more/index.html`,用于静态托管。
|
||||
|
||||
## 目录结构
|
||||
|
||||
```
|
||||
src/
|
||||
├── App.tsx 根组件:解析当前路由并渲染对应页面
|
||||
├── main.tsx React 挂载入口
|
||||
├── index.css Tailwind 入口 + 全局基础样式
|
||||
├── router/ 轻量路由
|
||||
│ ├── routes.ts 路由表(页面的唯一数据源)
|
||||
│ ├── history.ts normalizePath / navigate / subscribe
|
||||
│ ├── useRoute.ts 基于 useSyncExternalStore 的路由 hook
|
||||
│ ├── Link.tsx 站内跳转链接组件
|
||||
│ └── index.ts 统一导出
|
||||
├── components/
|
||||
│ ├── Banner.tsx 首页 Hero(背景 + 打字机 + 导航卡片)
|
||||
│ ├── NavCard.tsx 导航卡片
|
||||
│ ├── layout/ Header / Footer
|
||||
│ └── sections/ About / Projects / Contact 区块
|
||||
├── pages/
|
||||
│ ├── HomePage.tsx 首页
|
||||
│ └── MorePage.tsx /more 应用聚合页
|
||||
├── data/navigation.ts 首页导航卡片数据
|
||||
├── hooks/ useTypewriter / useParallax
|
||||
├── types/index.ts NavItem 类型
|
||||
└── assets/banner.png 全站背景图
|
||||
scripts/postbuild.mjs 构建后处理(生成 dist/more/index.html)
|
||||
```
|
||||
|
||||
## 添加 Item
|
||||
|
||||
有 3 种情况,按你想加的东西选择。
|
||||
|
||||
### 方式一:首页 Banner 上的导航卡片
|
||||
|
||||
编辑 `src/data/navigation.ts`,往 `NAV_ITEMS` 数组追加一项:
|
||||
|
||||
```ts
|
||||
import { LayoutDashboard, ListCollapse, BookOpen } from "lucide-react"; // 1. 引入图标
|
||||
import type { NavItem } from "@/types";
|
||||
|
||||
export const NAV_ITEMS: NavItem[] = [
|
||||
// ...已有项
|
||||
{
|
||||
name: "Blog", // 卡片标题
|
||||
desc: "我的博客", // 卡片副标题
|
||||
path: "https://blog.xiaozhou233.cn", // 链接(见下方说明)
|
||||
Icon: BookOpen, // lucide 图标组件
|
||||
color: "text-sky-400", // 图标颜色
|
||||
borderHover: // hover 时的边框 + 光晕
|
||||
"hover:border-sky-500/50 hover:shadow-[0_0_20px_rgba(56,189,248,0.2)]",
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
字段说明:
|
||||
|
||||
| 字段 | 说明 |
|
||||
| --- | --- |
|
||||
| `name` | 卡片标题,同时作为 React `key`,**不要重复** |
|
||||
| `desc` | 卡片副标题 |
|
||||
| `path` | 以 `/` 开头 → 站内路由、当前页 SPA 跳转;其他(`http...`、`#`)→ 新标签页打开。由 `NavCard.tsx` 自动判断 |
|
||||
| `Icon` | 任意 `lucide-react` 图标组件 |
|
||||
| `color` | 图标 Tailwind 颜色类 |
|
||||
| `borderHover` | hover 的边框色 + 阴影类 |
|
||||
|
||||
> 卡片网格会自动排版,无需改动布局。
|
||||
|
||||
### 方式二:`/more` 页的应用卡片
|
||||
|
||||
编辑 `src/pages/MorePage.tsx`,需要动两个地方:图标定义和列表。
|
||||
|
||||
```ts
|
||||
// 1. 在 appIcons 里加图标(SVG 内容,通常从 lucide 复制 path)
|
||||
const appIcons = {
|
||||
water: <path d="M12 2.69l5.66 5.66a8 8 0 1 1-11.31 0z" />,
|
||||
atom: (<>...</>),
|
||||
book: <path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20" />, // 新增
|
||||
};
|
||||
|
||||
// 2. 在 apps 数组里追加一项
|
||||
const apps = [
|
||||
// ...已有项
|
||||
{
|
||||
name: "新应用",
|
||||
desc: "一句话描述",
|
||||
color: "#10b981", // 图标底色,渐变自动生成
|
||||
link: "https://example.com", // 跳转地址
|
||||
icon: appIcons.book, // 指向上面定义的图标
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
| 字段 | 说明 |
|
||||
| --- | --- |
|
||||
| `name` | 应用名,同时作为 React `key`,**不要重复** |
|
||||
| `desc` | 一句话描述 |
|
||||
| `color` | 图标十六进制底色,卡片会自动生成同色渐变与光晕 |
|
||||
| `link` | 目标地址(站内相对路径或完整 URL) |
|
||||
| `icon` | 引用 `appIcons` 里的 SVG 片段 |
|
||||
|
||||
### 方式三:新增一个独立页面(路由)
|
||||
|
||||
如果卡片要指向站内新页面(例如 `/blog`):
|
||||
|
||||
**1. 新建页面组件**,如 `src/pages/BlogPage.tsx`。
|
||||
|
||||
**2. 注册路由**,在 `src/router/routes.ts` 的 `ROUTES` 追加:
|
||||
|
||||
```ts
|
||||
import BlogPage from "@/pages/BlogPage";
|
||||
|
||||
export const ROUTES: RouteDefinition[] = [
|
||||
// ...已有路由
|
||||
{
|
||||
name: "blog",
|
||||
path: "/blog",
|
||||
pattern: /^\/blog$/, // 路径匹配正则
|
||||
title: "博客 - 筱周の网站", // 会自动设置 document.title
|
||||
Component: BlogPage,
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
**3.(可选)让该路径能被直接访问。** 目前 `scripts/postbuild.mjs` 只为 `/more`
|
||||
生成了静态入口。若希望直接打开 `https://你的域名/blog` 也能命中(而不是只从首页点进去),
|
||||
照抄一份:
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import reactX from 'eslint-plugin-react-x'
|
||||
import reactDom from 'eslint-plugin-react-dom'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
// Enable lint rules for React
|
||||
reactX.configs['recommended-typescript'],
|
||||
// Enable lint rules for React DOM
|
||||
reactDom.configs.recommended,
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
const blogDir = resolve(root, "dist", "blog");
|
||||
mkdirSync(blogDir, { recursive: true });
|
||||
writeFileSync(resolve(blogDir, "index.html"), indexHtml);
|
||||
```
|
||||
|
||||
> 如果托管平台已配置 SPA history fallback(如 Cloudflare Pages / Netlify 的 rewrite),
|
||||
> 这一步可以省略。
|
||||
|
||||
## 路由
|
||||
|
||||
路由是自研的零依赖实现,核心思路:
|
||||
|
||||
- **路由表唯一数据源**:`src/router/routes.ts` 里的 `ROUTES`,每条包含 `path`、
|
||||
`pattern`、`title`、`Component`。加页面只改这里。
|
||||
- **路径归一化**:`normalizePath()` 把 `/more`、`/more/`、`/more/index.html`
|
||||
统一成 `/more`。
|
||||
- **响应式**:`useRoute()` 基于 `useSyncExternalStore`,监听 `popstate`,
|
||||
浏览器前进/后退正常工作。
|
||||
- **站内跳转**:用 `src/router/Link.tsx` 的 `<Link to="/more">` 做客户端跳转;
|
||||
中键 / Ctrl 点击等仍会走浏览器默认行为(新标签页)。
|
||||
- **兜底**:未知路径回落到首页(`FALLBACK_ROUTE`)。
|
||||
|
||||
## 样式约定
|
||||
|
||||
- 主色 `emerald`,背景 `black`,卡片统一使用玻璃拟态:
|
||||
`bg-white/5 border border-white/5 backdrop-blur-sm rounded-2xl`。
|
||||
- 强调/交互用 emerald 光晕:`hover:border-emerald-500/30 hover:shadow-[0_0_25px_rgba(52,211,153,0.1)]`。
|
||||
- 标题、终端提示符用 `font-mono`;正文描述用 `font-sans`(Geist)。
|
||||
- Tailwind 4 语法:渐变用 `bg-linear-to-r`,字体族通过 `@theme` 覆盖。
|
||||
|
||||
## 部署
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
产物在 `dist/`,可直接托管到任意静态平台。注意构建会自动把
|
||||
`dist/index.html` 复制成 `dist/more/index.html`,保证 `/more` 可直达。
|
||||
|
||||
## 备注
|
||||
|
||||
- 全站背景图为 `src/assets/banner.png`,由 Vite 打包(带 hash)。
|
||||
- `index.html` 中接入了 umami 访问统计(`umami.xiaozhou233.cn`),如不需要可移除该 `<script>`。
|
||||
- 首页导航目前包含一个「Maintenance」占位项,原来的 Blog / Git / Jenkins / Workstation
|
||||
入口已临时下线。
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"$schema": "https://ui.shadcn.com/schema.json",
|
||||
"style": "radix-nova",
|
||||
"rsc": false,
|
||||
"tsx": true,
|
||||
"tailwind": {
|
||||
"config": "",
|
||||
"css": "src/index.css",
|
||||
"baseColor": "neutral",
|
||||
"cssVariables": true,
|
||||
"prefix": ""
|
||||
},
|
||||
"iconLibrary": "lucide",
|
||||
"rtl": false,
|
||||
"aliases": {
|
||||
"components": "@/components",
|
||||
"utils": "@/lib/utils",
|
||||
"ui": "@/components/ui",
|
||||
"lib": "@/lib",
|
||||
"hooks": "@/hooks"
|
||||
},
|
||||
"menuColor": "default",
|
||||
"menuAccent": "subtle",
|
||||
"registries": {}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>筱周の网站 - XiaoZhou's Website</title>
|
||||
<script defer src="https://umami.xiaozhou233.cn/script.js" data-website-id="5a5128e4-1e6c-4c0f-8f45-536d929aa2a1"></script>
|
||||
|
||||
Generated
+412
-3662
File diff suppressed because it is too large.
Load diff
+1
-6
@@ -12,17 +12,12 @@
|
||||
"dependencies": {
|
||||
"@fontsource-variable/geist": "^5.2.9",
|
||||
"@tailwindcss/vite": "^4.3.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"lucide-react": "^1.17.0",
|
||||
"react": "^19.2.6",
|
||||
"react-dom": "^19.2.6",
|
||||
"tailwind-merge": "^3.6.0",
|
||||
"tailwindcss": "^4.3.0",
|
||||
"tw-animate-css": "^1.4.0"
|
||||
"tailwindcss": "^4.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"shadcn": "^4.8.2",
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@types/node": "^24.12.4",
|
||||
"@types/react": "^19.2.14",
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 133 KiB |
+14
-22
@@ -1,22 +1,14 @@
|
||||
import Banner from "./components/Banner";
|
||||
import AboutSection from "./components/sections/AboutSection";
|
||||
import ProjectsSection from "./components/sections/ProjectsSection";
|
||||
import ContactSection from "./components/sections/ContactSection";
|
||||
import MorePage from "./pages/MorePage";
|
||||
|
||||
export default function App() {
|
||||
const { pathname } = window.location;
|
||||
|
||||
if (/^\/more(\/index\.html)?\/?$/.test(pathname)) {
|
||||
return <MorePage />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="bg-black">
|
||||
<Banner />
|
||||
<AboutSection />
|
||||
<ProjectsSection />
|
||||
<ContactSection />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
import { useEffect } from "react";
|
||||
import { useRoute } from "@/router";
|
||||
|
||||
// Resolves the current path to a page via the route registry.
|
||||
export default function App() {
|
||||
const { route } = useRoute();
|
||||
|
||||
useEffect(() => {
|
||||
document.title = route.title;
|
||||
}, [route.title]);
|
||||
|
||||
const { Component } = route;
|
||||
return <Component />;
|
||||
}
|
||||
@@ -1,20 +1,19 @@
|
||||
import { Link } from "@/router";
|
||||
import type { NavItem } from "@/types";
|
||||
|
||||
interface NavCardProps {
|
||||
item: NavItem;
|
||||
}
|
||||
|
||||
// A clickable navigation card with icon, title, and description
|
||||
// A clickable navigation card with icon, title, and description.
|
||||
// Internal paths ("/...") route client-side; external URLs open in a new tab.
|
||||
export default function NavCard({ item }: NavCardProps) {
|
||||
const { name, desc, path, Icon, color, borderHover } = item;
|
||||
|
||||
return (
|
||||
<a
|
||||
href={path}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className={`flex items-center md:flex-col md:text-center gap-5 md:gap-4 p-6 md:py-8 rounded-2xl bg-black/35 backdrop-blur-md border border-white/5 transition-all duration-300 cursor-pointer hover:-translate-y-1 hover:bg-black/45 ${borderHover} group block`}
|
||||
>
|
||||
const className = `flex items-center md:flex-col md:text-center gap-5 md:gap-4 p-6 md:py-8 rounded-2xl bg-black/35 backdrop-blur-md border border-white/5 transition-all duration-300 cursor-pointer hover:-translate-y-1 hover:bg-black/45 ${borderHover} group`;
|
||||
|
||||
const content = (
|
||||
<>
|
||||
<div className="shrink-0 transition-transform duration-300 group-hover:scale-105">
|
||||
<Icon className={color} size={36} />
|
||||
</div>
|
||||
@@ -26,6 +25,20 @@ export default function NavCard({ item }: NavCardProps) {
|
||||
{desc}
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
if (path.startsWith("/")) {
|
||||
return (
|
||||
<Link to={path} className={className}>
|
||||
{content}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<a href={path} target="_blank" rel="noopener noreferrer" className={className}>
|
||||
{content}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
@@ -1,16 +1,8 @@
|
||||
import { LayoutDashboard, GitFork, MonitorCog, ListCollapse, Workflow } from "lucide-react";
|
||||
import { GitFork, MonitorCog, ListCollapse, Workflow } from "lucide-react";
|
||||
import type { NavItem } from "@/types";
|
||||
|
||||
// External links displayed as navigation cards on the banner
|
||||
export const NAV_ITEMS: NavItem[] = [
|
||||
{
|
||||
name: "Blog",
|
||||
desc: "技术随笔与生活记录",
|
||||
path: "https://blog.xiaozhou233.cn",
|
||||
Icon: LayoutDashboard,
|
||||
color: "text-emerald-400",
|
||||
borderHover: "hover:border-emerald-500/50 hover:shadow-[0_0_20px_rgba(52,211,153,0.2)]",
|
||||
},
|
||||
{
|
||||
name: "Git",
|
||||
desc: "开源项目与代码托管",
|
||||
|
||||
@@ -6,14 +6,18 @@ export function useTypewriter(text: string, speed = 100) {
|
||||
|
||||
useEffect(() => {
|
||||
let i = 0;
|
||||
setDisplayed("");
|
||||
|
||||
const timer = setInterval(() => {
|
||||
i++;
|
||||
setDisplayed(text.slice(0, i));
|
||||
if (i === text.length) clearInterval(timer);
|
||||
|
||||
if (i === text.length) {
|
||||
clearInterval(timer);
|
||||
}
|
||||
}, speed);
|
||||
|
||||
return () => clearInterval(timer);
|
||||
}, [text, speed]);
|
||||
|
||||
return displayed;
|
||||
}
|
||||
}
|
||||
+9
-122
@@ -1,129 +1,16 @@
|
||||
@import "tailwindcss";
|
||||
@import "tw-animate-css";
|
||||
@import "@fontsource-variable/geist";
|
||||
|
||||
@custom-variant dark (&:is(.dark *));
|
||||
|
||||
@theme inline {
|
||||
--font-heading: var(--font-sans);
|
||||
--font-sans: 'Geist Variable', sans-serif;
|
||||
--color-sidebar-ring: var(--sidebar-ring);
|
||||
--color-sidebar-border: var(--sidebar-border);
|
||||
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
||||
--color-sidebar-accent: var(--sidebar-accent);
|
||||
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
||||
--color-sidebar-primary: var(--sidebar-primary);
|
||||
--color-sidebar-foreground: var(--sidebar-foreground);
|
||||
--color-sidebar: var(--sidebar);
|
||||
--color-chart-5: var(--chart-5);
|
||||
--color-chart-4: var(--chart-4);
|
||||
--color-chart-3: var(--chart-3);
|
||||
--color-chart-2: var(--chart-2);
|
||||
--color-chart-1: var(--chart-1);
|
||||
--color-ring: var(--ring);
|
||||
--color-input: var(--input);
|
||||
--color-border: var(--border);
|
||||
--color-destructive: var(--destructive);
|
||||
--color-accent-foreground: var(--accent-foreground);
|
||||
--color-accent: var(--accent);
|
||||
--color-muted-foreground: var(--muted-foreground);
|
||||
--color-muted: var(--muted);
|
||||
--color-secondary-foreground: var(--secondary-foreground);
|
||||
--color-secondary: var(--secondary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
--color-primary: var(--primary);
|
||||
--color-popover-foreground: var(--popover-foreground);
|
||||
--color-popover: var(--popover);
|
||||
--color-card-foreground: var(--card-foreground);
|
||||
--color-card: var(--card);
|
||||
--color-foreground: var(--foreground);
|
||||
--color-background: var(--background);
|
||||
--radius-sm: calc(var(--radius) * 0.6);
|
||||
--radius-md: calc(var(--radius) * 0.8);
|
||||
--radius-lg: var(--radius);
|
||||
--radius-xl: calc(var(--radius) * 1.4);
|
||||
--radius-2xl: calc(var(--radius) * 1.8);
|
||||
--radius-3xl: calc(var(--radius) * 2.2);
|
||||
--radius-4xl: calc(var(--radius) * 2.6);
|
||||
}
|
||||
|
||||
:root {
|
||||
--background: oklch(1 0 0);
|
||||
--foreground: oklch(0.145 0 0);
|
||||
--card: oklch(1 0 0);
|
||||
--card-foreground: oklch(0.145 0 0);
|
||||
--popover: oklch(1 0 0);
|
||||
--popover-foreground: oklch(0.145 0 0);
|
||||
--primary: oklch(0.205 0 0);
|
||||
--primary-foreground: oklch(0.985 0 0);
|
||||
--secondary: oklch(0.97 0 0);
|
||||
--secondary-foreground: oklch(0.205 0 0);
|
||||
--muted: oklch(0.97 0 0);
|
||||
--muted-foreground: oklch(0.556 0 0);
|
||||
--accent: oklch(0.97 0 0);
|
||||
--accent-foreground: oklch(0.205 0 0);
|
||||
--destructive: oklch(0.577 0.245 27.325);
|
||||
--border: oklch(0.922 0 0);
|
||||
--input: oklch(0.922 0 0);
|
||||
--ring: oklch(0.708 0 0);
|
||||
--chart-1: oklch(0.87 0 0);
|
||||
--chart-2: oklch(0.556 0 0);
|
||||
--chart-3: oklch(0.439 0 0);
|
||||
--chart-4: oklch(0.371 0 0);
|
||||
--chart-5: oklch(0.269 0 0);
|
||||
--radius: 0.625rem;
|
||||
--sidebar: oklch(0.985 0 0);
|
||||
--sidebar-foreground: oklch(0.145 0 0);
|
||||
--sidebar-primary: oklch(0.205 0 0);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.97 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.205 0 0);
|
||||
--sidebar-border: oklch(0.922 0 0);
|
||||
--sidebar-ring: oklch(0.708 0 0);
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: oklch(0.145 0 0);
|
||||
--foreground: oklch(0.985 0 0);
|
||||
--card: oklch(0.205 0 0);
|
||||
--card-foreground: oklch(0.985 0 0);
|
||||
--popover: oklch(0.205 0 0);
|
||||
--popover-foreground: oklch(0.985 0 0);
|
||||
--primary: oklch(0.922 0 0);
|
||||
--primary-foreground: oklch(0.205 0 0);
|
||||
--secondary: oklch(0.269 0 0);
|
||||
--secondary-foreground: oklch(0.985 0 0);
|
||||
--muted: oklch(0.269 0 0);
|
||||
--muted-foreground: oklch(0.708 0 0);
|
||||
--accent: oklch(0.269 0 0);
|
||||
--accent-foreground: oklch(0.985 0 0);
|
||||
--destructive: oklch(0.704 0.191 22.216);
|
||||
--border: oklch(1 0 0 / 10%);
|
||||
--input: oklch(1 0 0 / 15%);
|
||||
--ring: oklch(0.556 0 0);
|
||||
--chart-1: oklch(0.87 0 0);
|
||||
--chart-2: oklch(0.556 0 0);
|
||||
--chart-3: oklch(0.439 0 0);
|
||||
--chart-4: oklch(0.371 0 0);
|
||||
--chart-5: oklch(0.269 0 0);
|
||||
--sidebar: oklch(0.205 0 0);
|
||||
--sidebar-foreground: oklch(0.985 0 0);
|
||||
--sidebar-primary: oklch(0.488 0.243 264.376);
|
||||
--sidebar-primary-foreground: oklch(0.985 0 0);
|
||||
--sidebar-accent: oklch(0.269 0 0);
|
||||
--sidebar-accent-foreground: oklch(0.985 0 0);
|
||||
--sidebar-border: oklch(1 0 0 / 10%);
|
||||
--sidebar-ring: oklch(0.556 0 0);
|
||||
@theme {
|
||||
--font-sans: "Geist Variable", system-ui, sans-serif;
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* {
|
||||
@apply border-border outline-ring/50;
|
||||
}
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
html {
|
||||
@apply font-sans;
|
||||
}
|
||||
}
|
||||
font-family: var(--font-sans);
|
||||
}
|
||||
|
||||
body {
|
||||
@apply bg-black text-white antialiased;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import { clsx, type ClassValue } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
|
||||
// Merges Tailwind classes, resolving conflicts via tailwind-merge
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import Banner from "@/components/Banner";
|
||||
import AboutSection from "@/components/sections/AboutSection";
|
||||
import ProjectsSection from "@/components/sections/ProjectsSection";
|
||||
import ContactSection from "@/components/sections/ContactSection";
|
||||
|
||||
// Landing page: hero banner followed by the content sections.
|
||||
export default function HomePage() {
|
||||
return (
|
||||
<div className="bg-black">
|
||||
<Banner />
|
||||
<AboutSection />
|
||||
<ProjectsSection />
|
||||
<ContactSection />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+56
-24
@@ -1,5 +1,7 @@
|
||||
import { useEffect } from "react";
|
||||
import "./more.css";
|
||||
import { Link } from "@/router";
|
||||
import Header from "@/components/layout/Header";
|
||||
import Footer from "@/components/layout/Footer";
|
||||
import bannerImg from "@/assets/banner.png";
|
||||
|
||||
const appIcons = {
|
||||
water: <path d="M12 2.69l5.66 5.66a8 8 0 1 1-11.31 0z" />,
|
||||
@@ -17,31 +19,55 @@ const apps = [
|
||||
{ name: "力的课题", desc: "认识三种基本的力", color: "#ef4444", link: "/forces.html", icon: appIcons.atom },
|
||||
];
|
||||
|
||||
// App hub at /more, styled to match the main site's terminal aesthetic.
|
||||
export default function MorePage() {
|
||||
useEffect(() => {
|
||||
document.title = "更多应用";
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="more-page">
|
||||
<div className="more-page-inner">
|
||||
<header className="more-banner">
|
||||
<h1 className="more-banner-title">更多应用</h1>
|
||||
<p className="more-banner-subtitle">一个入口,汇聚所有工具</p>
|
||||
<a className="more-home-link" href="/">
|
||||
返回主站
|
||||
</a>
|
||||
</header>
|
||||
<div
|
||||
className="relative w-full min-h-screen flex flex-col text-white overflow-hidden font-mono"
|
||||
style={{
|
||||
backgroundImage: `url(${bannerImg})`,
|
||||
backgroundSize: "cover",
|
||||
backgroundPosition: "center",
|
||||
}}
|
||||
>
|
||||
<div className="absolute inset-0 bg-black/80 pointer-events-none" />
|
||||
|
||||
<main className="more-app-grid">
|
||||
<Header />
|
||||
|
||||
<main className="relative z-10 flex-1 w-full max-w-5xl mx-auto px-4 py-16 md:py-24">
|
||||
<div className="text-center mb-14">
|
||||
<h1 className="text-4xl md:text-6xl font-extrabold tracking-tighter text-transparent bg-clip-text bg-linear-to-r from-emerald-50 via-white to-emerald-50 drop-shadow-[0_0_15px_rgba(52,211,153,0.4)]">
|
||||
更多应用
|
||||
</h1>
|
||||
<p className="mt-5 text-emerald-400/80 text-sm md:text-base tracking-tight font-light">
|
||||
{"< 一个入口,汇聚所有工具 >"}
|
||||
</p>
|
||||
<div className="w-12 h-0.5 bg-emerald-500 mt-5 mx-auto shadow-[0_0_8px_#10b981]" />
|
||||
<Link
|
||||
to="/"
|
||||
className="inline-flex items-center mt-8 px-4 py-2 rounded-full bg-white/5 border border-white/10 text-sm text-gray-200 transition-colors hover:bg-white/10 hover:border-emerald-500/40 hover:text-white"
|
||||
>
|
||||
返回主站
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{apps.map((app) => (
|
||||
<a key={app.name} className="more-app-card" href={app.link}>
|
||||
<a
|
||||
key={app.name}
|
||||
href={app.link}
|
||||
className="flex items-center gap-5 p-6 rounded-2xl bg-white/5 border border-white/5 backdrop-blur-sm transition-all duration-300 hover:-translate-y-1 hover:bg-white/10 hover:border-emerald-500/30 hover:shadow-[0_0_25px_rgba(52,211,153,0.1)] group"
|
||||
>
|
||||
<span
|
||||
className="more-app-icon"
|
||||
style={{ background: `linear-gradient(135deg, ${app.color}, ${app.color}cc)` }}
|
||||
className="shrink-0 flex items-center justify-center w-12 h-12 rounded-xl text-white transition-transform duration-300 group-hover:scale-105"
|
||||
style={{
|
||||
background: `linear-gradient(135deg, ${app.color}, ${app.color}cc)`,
|
||||
boxShadow: `0 0 18px ${app.color}40`,
|
||||
}}
|
||||
>
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
className="w-6 h-6"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
@@ -52,14 +78,20 @@ export default function MorePage() {
|
||||
{app.icon}
|
||||
</svg>
|
||||
</span>
|
||||
<div className="more-app-info">
|
||||
<h2 className="more-app-name">{app.name}</h2>
|
||||
<p className="more-app-desc">{app.desc}</p>
|
||||
<div className="min-w-0">
|
||||
<h2 className="text-lg font-bold text-gray-100 transition-colors group-hover:text-white">
|
||||
{app.name}
|
||||
</h2>
|
||||
<p className="text-sm text-gray-400/80 mt-1 tracking-wide font-sans transition-colors group-hover:text-gray-300">
|
||||
{app.desc}
|
||||
</p>
|
||||
</div>
|
||||
</a>
|
||||
))}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
.more-page {
|
||||
position: relative;
|
||||
min-height: 100svh;
|
||||
box-sizing: border-box;
|
||||
color: #94a3b8;
|
||||
font-family: system-ui, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
|
||||
}
|
||||
|
||||
.more-page::before {
|
||||
content: "";
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: -1;
|
||||
background: linear-gradient(rgba(15, 23, 42, 0.6), rgba(15, 23, 42, 0.6)),
|
||||
url("/banner.jpg") center / cover no-repeat, #0f172a;
|
||||
}
|
||||
|
||||
.more-page *,
|
||||
.more-page *::before,
|
||||
.more-page *::after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
.more-page-inner {
|
||||
max-width: 1120px;
|
||||
margin: 0 auto;
|
||||
padding: 0 24px 64px;
|
||||
}
|
||||
|
||||
.more-banner {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
padding: 88px 24px;
|
||||
margin: 32px 0 48px;
|
||||
border-radius: 20px;
|
||||
background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
|
||||
.more-home-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 24px;
|
||||
padding: 8px 16px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border: 1px solid rgba(255, 255, 255, 0.14);
|
||||
color: #e2e8f0;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
text-decoration: none;
|
||||
transition:
|
||||
background 0.2s ease,
|
||||
border-color 0.2s ease;
|
||||
}
|
||||
|
||||
.more-home-link:hover {
|
||||
background: rgba(255, 255, 255, 0.16);
|
||||
border-color: rgba(255, 255, 255, 0.25);
|
||||
}
|
||||
|
||||
.more-banner-title {
|
||||
font-size: 48px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -1px;
|
||||
margin: 0 0 12px;
|
||||
color: #f1f5f9;
|
||||
}
|
||||
|
||||
.more-banner-subtitle {
|
||||
font-size: 18px;
|
||||
margin: 0;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.more-app-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.more-app-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 20px;
|
||||
border-radius: 16px;
|
||||
background: #1e293b;
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
text-decoration: none;
|
||||
transition:
|
||||
transform 0.25s ease,
|
||||
box-shadow 0.25s ease,
|
||||
border-color 0.25s ease;
|
||||
}
|
||||
|
||||
.more-app-card:hover {
|
||||
transform: translateY(-4px);
|
||||
border-color: rgba(255, 255, 255, 0.14);
|
||||
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.more-app-icon {
|
||||
flex-shrink: 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 14px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.more-app-icon svg {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
.more-app-info {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.more-app-name {
|
||||
font-size: 17px;
|
||||
font-weight: 600;
|
||||
margin: 0 0 4px;
|
||||
color: #f1f5f9;
|
||||
}
|
||||
|
||||
.more-app-desc {
|
||||
font-size: 13px;
|
||||
margin: 0;
|
||||
color: #94a3b8;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.more-banner {
|
||||
padding: 64px 20px;
|
||||
}
|
||||
|
||||
.more-app-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.more-banner {
|
||||
padding: 48px 16px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.more-banner-title {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.more-app-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.more-app-desc {
|
||||
white-space: normal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import type { AnchorHTMLAttributes, MouseEvent } from "react";
|
||||
import { navigate } from "./history";
|
||||
|
||||
interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
||||
to: string;
|
||||
}
|
||||
|
||||
// In-app link that routes client-side while keeping normal anchor semantics
|
||||
// (middle-click / modifier-click still open a new tab and get a real href).
|
||||
export function Link({ to, onClick, ...props }: LinkProps) {
|
||||
function handleClick(event: MouseEvent<HTMLAnchorElement>) {
|
||||
onClick?.(event);
|
||||
if (
|
||||
event.defaultPrevented ||
|
||||
event.button !== 0 ||
|
||||
event.metaKey ||
|
||||
event.ctrlKey ||
|
||||
event.shiftKey ||
|
||||
event.altKey
|
||||
) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
navigate(to);
|
||||
}
|
||||
|
||||
return <a href={to} onClick={handleClick} {...props} />;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Minimal history-based routing primitives (no external router dependency).
|
||||
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
function notify() {
|
||||
listeners.forEach((listener) => listener());
|
||||
}
|
||||
|
||||
// Normalizes a pathname so "/more", "/more/" and "/more/index.html" all match.
|
||||
export function normalizePath(pathname: string): string {
|
||||
let path = pathname.replace(/\/index\.html$/, "");
|
||||
if (path.length > 1) path = path.replace(/\/+$/, "");
|
||||
return path || "/";
|
||||
}
|
||||
|
||||
// `useSyncExternalStore` subscribes here; `popstate` covers back/forward.
|
||||
export function subscribe(listener: () => void): () => void {
|
||||
listeners.add(listener);
|
||||
window.addEventListener("popstate", listener);
|
||||
return () => {
|
||||
listeners.delete(listener);
|
||||
window.removeEventListener("popstate", listener);
|
||||
};
|
||||
}
|
||||
|
||||
export function getPath(): string {
|
||||
return normalizePath(window.location.pathname);
|
||||
}
|
||||
|
||||
// Client-side navigation. Same-path navigations are ignored.
|
||||
export function navigate(to: string): void {
|
||||
const url = new URL(to, window.location.origin);
|
||||
if (url.pathname === window.location.pathname) return;
|
||||
window.history.pushState(null, "", url);
|
||||
notify();
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export { Link } from "./Link";
|
||||
export { useRoute } from "./useRoute";
|
||||
export { ROUTES, FALLBACK_ROUTE, matchRoute, type RouteDefinition } from "./routes";
|
||||
@@ -0,0 +1,36 @@
|
||||
import type { ComponentType } from "react";
|
||||
import HomePage from "@/pages/HomePage";
|
||||
import MorePage from "@/pages/MorePage";
|
||||
|
||||
export interface RouteDefinition {
|
||||
name: string;
|
||||
path: string;
|
||||
pattern: RegExp;
|
||||
title: string;
|
||||
Component: ComponentType;
|
||||
}
|
||||
|
||||
// Single source of truth for pages. Add a route here and it is wired up.
|
||||
export const ROUTES: RouteDefinition[] = [
|
||||
{
|
||||
name: "home",
|
||||
path: "/",
|
||||
pattern: /^\/$/,
|
||||
title: "筱周の网站 - XiaoZhou's Website",
|
||||
Component: HomePage,
|
||||
},
|
||||
{
|
||||
name: "more",
|
||||
path: "/more",
|
||||
pattern: /^\/more$/,
|
||||
title: "更多应用 - 筱周の网站",
|
||||
Component: MorePage,
|
||||
},
|
||||
];
|
||||
|
||||
// Unknown paths fall back to home (preserves the previous behaviour).
|
||||
export const FALLBACK_ROUTE = ROUTES[0];
|
||||
|
||||
export function matchRoute(pathname: string): RouteDefinition {
|
||||
return ROUTES.find((route) => route.pattern.test(pathname)) ?? FALLBACK_ROUTE;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { useSyncExternalStore } from "react";
|
||||
import { getPath, subscribe } from "./history";
|
||||
import { matchRoute, type RouteDefinition } from "./routes";
|
||||
|
||||
export function useRoute(): { path: string; route: RouteDefinition } {
|
||||
const path = useSyncExternalStore(subscribe, getPath, () => "/");
|
||||
return { path, route: matchRoute(path) };
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ export default defineConfig({
|
||||
plugins: [react(), tailwindcss()],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./src"),
|
||||
"@": path.resolve(import.meta.dirname, "./src"),
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in new issue
Block a user