diff --git a/.env b/.env deleted file mode 100644 index 41b358c..0000000 --- a/.env +++ /dev/null @@ -1,19 +0,0 @@ -# When adding additional environment variables, the schema in "/src/env.js" -# should be updated accordingly. - -# Next Auth -# You can generate a new secret on the command line with: -# npx auth secret -# https://next-auth.js.org/configuration/options#secret -AUTH_SECRET="3s/7AKiCKcO5sfJLpP304y43i6mfE6T+LUkeglCxzns=" # Generated by create-t3-app. - -# Next Auth Discord Provider -AUTH_DISCORD_ID="hackrobot" -AUTH_DISCORD_SECRET="Xiao4669805" - -# Prisma -# https://www.prisma.io/docs/reference/database-reference/connection-urls#env -DATABASE_URL="file:./db.sqlite" - - -PORT=3001 diff --git a/.env.example b/.env.example deleted file mode 100644 index 6dc5614..0000000 --- a/.env.example +++ /dev/null @@ -1,24 +0,0 @@ -# Since the ".env" file is gitignored, you can use the ".env.example" file to -# build a new ".env" file when you clone the repo. Keep this file up-to-date -# when you add new variables to `.env`. - -# This file will be committed to version control, so make sure not to have any -# secrets in it. If you are cloning this repo, create a copy of this file named -# ".env" and populate it with your secrets. - -# When adding additional environment variables, the schema in "/src/env.js" -# should be updated accordingly. - -# Next Auth -# You can generate a new secret on the command line with: -# npx auth secret -# https://next-auth.js.org/configuration/options#secret -AUTH_SECRET="" - -# Next Auth Discord Provider -AUTH_DISCORD_ID="" -AUTH_DISCORD_SECRET="" - -# Prisma -# https://www.prisma.io/docs/reference/database-reference/connection-urls#env -DATABASE_URL="file:./db.sqlite" diff --git a/.gitignore b/.gitignore index 6dc30a6..5ef6a52 100644 --- a/.gitignore +++ b/.gitignore @@ -3,20 +3,19 @@ # dependencies /node_modules /.pnp -.pnp.js +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/versions # testing /coverage -# database -/prisma/db.sqlite -/prisma/db.sqlite-journal -db.sqlite - # next.js /.next/ /out/ -next-env.d.ts # production /build @@ -31,16 +30,12 @@ yarn-debug.log* yarn-error.log* .pnpm-debug.log* -# local env files -# do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables -# .env -.env*.local +# env files (can opt-in for committing if needed) +.env* # vercel .vercel # typescript *.tsbuildinfo - -# idea files -.idea \ No newline at end of file +next-env.d.ts diff --git a/README.md b/README.md index 05d010d..e215bc4 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,36 @@ -# nomadro +This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). +## Getting Started +First, run the development server: -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin http://gitlab.yidooplanet.com/gitlab-instance-0a899031/nomadro.git -git branch -M main -git push -uf origin main +```bash +npm run dev +# or +yarn dev +# or +pnpm dev +# or +bun dev ``` -## Integrate with your tools +Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. -- [ ] [Set up project integrations](http://gitlab.yidooplanet.com/gitlab-instance-0a899031/nomadro/-/settings/integrations) +You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. -## Collaborate with your team +This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) +## Learn More -## Test and Deploy +To learn more about Next.js, take a look at the following resources: -Use the built-in continuous integration in GitLab. +- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. +- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) +You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! -*** +## Deploy on Vercel -# Editing this README +The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. diff --git a/app/about/page.tsx b/app/about/page.tsx new file mode 100644 index 0000000..fdb565c --- /dev/null +++ b/app/about/page.tsx @@ -0,0 +1,25 @@ +import Link from "next/link"; +import { SiteHeader } from "~/components/layout/site-header"; +import { SiteFooter } from "~/components/layout/site-footer"; + +export default function AboutPage() { + return ( +
+ +
+

关于 Nomadro

+

+ Nomadro 是中文数字游民操作系统,致力于帮助更多人从固定工位走向自由生活与自由收入。 + 我们提供城市探索、学习路径、会员社区三大核心模块,从地点、技能、工具到社群,构建完整的数字游民支持体系。 +

+ + ← 返回首页 + +
+ +
+ ); +} diff --git a/app/contact/page.tsx b/app/contact/page.tsx new file mode 100644 index 0000000..9ded534 --- /dev/null +++ b/app/contact/page.tsx @@ -0,0 +1,32 @@ +import Link from "next/link"; +import { SiteHeader } from "~/components/layout/site-header"; +import { SiteFooter } from "~/components/layout/site-footer"; + +export default function ContactPage() { + return ( +
+ +
+

联系我们

+

+ 加入数字游民社群,获取最新动态与交流机会。 +

+ + 加入社群 + + + ← 返回首页 + +
+ +
+ ); +} diff --git a/app/favicon.ico b/app/favicon.ico new file mode 100644 index 0000000..718d6fe Binary files /dev/null and b/app/favicon.ico differ diff --git a/app/globals.css b/app/globals.css new file mode 100644 index 0000000..6ea7b2f --- /dev/null +++ b/app/globals.css @@ -0,0 +1,20 @@ +@import "tailwindcss"; + +:root { + --background: #ffffff; + --foreground: #171717; +} + +@theme inline { + --color-background: var(--background); + --color-foreground: var(--foreground); + --font-sans: var(--font-geist-sans), ui-sans-serif, system-ui, "PingFang SC", + "Microsoft YaHei", sans-serif; + --font-mono: var(--font-geist-mono), ui-monospace, monospace; +} + +body { + background: var(--background); + color: var(--foreground); + font-family: var(--font-sans); +} diff --git a/app/layout.tsx b/app/layout.tsx new file mode 100644 index 0000000..7140935 --- /dev/null +++ b/app/layout.tsx @@ -0,0 +1,48 @@ +import "./globals.css"; + +import { type Metadata } from "next"; +import { Geist, Geist_Mono } from "next/font/google"; + +export const metadata: Metadata = { + title: "Nomadro | 中文数字游民操作系统", + description: + "从城市、技能、工具到社群,一站开始你的数字游民生活。探索城市、学习路径、会员社区,帮你从固定工位走向自由生活与自由收入。", + keywords: [ + "数字游民", + "远程工作", + "旅居", + "自由职业", + "城市探索", + "学习路径", + "会员社区", + ], + openGraph: { + title: "Nomadro | 中文数字游民操作系统", + description: + "从城市、技能、工具到社群,一站开始你的数字游民生活。", + type: "website", + }, + icons: [{ rel: "icon", url: "/nomadro.ico" }], +}; + +const geist = Geist({ + subsets: ["latin"], + variable: "--font-geist-sans", +}); + +const geistMono = Geist_Mono({ + subsets: ["latin"], + variable: "--font-geist-mono", +}); + +export default function RootLayout({ + children, +}: Readonly<{ children: React.ReactNode }>) { + return ( + + + {children} + + + ); +} diff --git a/app/page.tsx b/app/page.tsx new file mode 100644 index 0000000..1d3fe6a --- /dev/null +++ b/app/page.tsx @@ -0,0 +1,31 @@ +import { SiteHeader } from "~/components/layout/site-header"; +import { SiteFooter } from "~/components/layout/site-footer"; +import { Hero } from "~/components/sections/hero"; +import { ValueGrid } from "~/components/sections/value-grid"; +import { EntryGrid } from "~/components/sections/entry-grid"; +import { Methodology } from "~/components/sections/methodology"; +import { Scenarios } from "~/components/sections/scenarios"; +import { Ecosystem } from "~/components/sections/ecosystem"; +import { ContentPreview } from "~/components/sections/content-preview"; +import { Trust } from "~/components/sections/trust"; +import { FinalCta } from "~/components/sections/final-cta"; + +export default function HomePage() { + return ( +
+ +
+ + + + + + + + + +
+ +
+ ); +} diff --git a/components/layout/site-footer.tsx b/components/layout/site-footer.tsx new file mode 100644 index 0000000..70aeb69 --- /dev/null +++ b/components/layout/site-footer.tsx @@ -0,0 +1,78 @@ +import Link from "next/link"; +import { NAV_LINKS, ENTRY_PATHS } from "~/lib/data"; + +export function SiteFooter() { + return ( + + ); +} diff --git a/components/layout/site-header.tsx b/components/layout/site-header.tsx new file mode 100644 index 0000000..966a120 --- /dev/null +++ b/components/layout/site-header.tsx @@ -0,0 +1,116 @@ +"use client"; + +import Link from "next/link"; +import { useState, useEffect } from "react"; +import { Menu, X } from "lucide-react"; +import { motion, AnimatePresence } from "framer-motion"; +import { NAV_LINKS } from "~/lib/data"; +import { Button } from "~/components/ui/button"; + +export function SiteHeader() { + const [mobileOpen, setMobileOpen] = useState(false); + const [scrolled, setScrolled] = useState(false); + + useEffect(() => { + const onScroll = () => setScrolled(window.scrollY > 20); + window.addEventListener("scroll", onScroll, { passive: true }); + return () => window.removeEventListener("scroll", onScroll); + }, []); + + return ( +
+
+ + + Nomadro + + + Digital Nomad OS / 数字游民操作系统 + + + + + + +
+ + + {mobileOpen && ( + +
+ Nomadro + +
+ +
+ )} +
+
+ ); +} diff --git a/components/sections/content-preview.tsx b/components/sections/content-preview.tsx new file mode 100644 index 0000000..1b45416 --- /dev/null +++ b/components/sections/content-preview.tsx @@ -0,0 +1,75 @@ +"use client"; + +import Link from "next/link"; +import { ArrowRight } from "lucide-react"; +import { motion } from "framer-motion"; +import { CONTENT_PREVIEW_ITEMS } from "~/lib/data"; + +const TAG_COLORS: Record = { + 城市: "bg-blue-50 text-blue-700", + 专题: "bg-emerald-50 text-emerald-700", + 工具: "bg-amber-50 text-amber-700", + 活动: "bg-rose-50 text-rose-700", + 学习路径: "bg-violet-50 text-violet-700", + 会员: "bg-neutral-100 text-neutral-700", +}; + +export function ContentPreview() { + return ( +
+
+ + 本周精选 + + + 城市、专题、工具、活动,持续更新 + + +
+ {CONTENT_PREVIEW_ITEMS.map((item, i) => ( + + + + {item.tag} + +

+ {item.title} +

+

{item.summary}

+ + 查看详情 + + + +
+ ))} +
+
+
+ ); +} diff --git a/components/sections/ecosystem.tsx b/components/sections/ecosystem.tsx new file mode 100644 index 0000000..525c69d --- /dev/null +++ b/components/sections/ecosystem.tsx @@ -0,0 +1,63 @@ +"use client"; + +import { MapPin, BookOpen, Crown } from "lucide-react"; +import { motion } from "framer-motion"; +import { ECOSYSTEM_COLUMNS } from "~/lib/data"; + +const ICON_MAP = [MapPin, BookOpen, Crown] as const; + +export function Ecosystem() { + return ( +
+
+ + 已有完整生态 + + + 不是从零开始,而是已经搭建好的体系 + + +
+ {ECOSYSTEM_COLUMNS.map((col, i) => { + const Icon = ICON_MAP[i]; + return ( + + +

+ {col.title} +

+
+ {col.items.map((item) => ( + + {item} + + ))} +
+
+ ); + })} +
+
+
+ ); +} diff --git a/components/sections/entry-grid.tsx b/components/sections/entry-grid.tsx new file mode 100644 index 0000000..1720208 --- /dev/null +++ b/components/sections/entry-grid.tsx @@ -0,0 +1,78 @@ +"use client"; + +import Link from "next/link"; +import { MapPin, BookOpen, Crown, ArrowRight } from "lucide-react"; +import { motion } from "framer-motion"; +import { ENTRY_PATHS } from "~/lib/data"; + +const ICON_MAP = { + MapPin, + BookOpen, + Crown, +} as const; + +const ACCENT_STYLES = { + blue: "border-l-blue-500/80 hover:border-l-blue-500", + green: "border-l-emerald-500/80 hover:border-l-emerald-500", + amber: "border-l-amber-500/80 hover:border-l-amber-500", +} as const; + +export function EntryGrid() { + return ( +
+
+ + 选择你的入口 + + + 三大路径,对应不同的需求和阶段 + + +
+ {ENTRY_PATHS.map((path, i) => { + const Icon = ICON_MAP[path.icon]; + const accent = ACCENT_STYLES[path.accent]; + return ( + + + +

+ {path.title} +

+

+ {path.description} +

+ + {path.cta} + + + +
+ ); + })} +
+
+
+ ); +} diff --git a/components/sections/final-cta.tsx b/components/sections/final-cta.tsx new file mode 100644 index 0000000..e9b1fec --- /dev/null +++ b/components/sections/final-cta.tsx @@ -0,0 +1,63 @@ +"use client"; + +import Link from "next/link"; +import { MapPin, BookOpen, Crown } from "lucide-react"; +import { motion } from "framer-motion"; +import { FINAL_CTAS } from "~/lib/data"; +import { Button } from "~/components/ui/button"; + +const ICONS = [MapPin, BookOpen, Crown] as const; + +export function FinalCta() { + return ( +
+
+ + 从这里开始你的数字游民路径 + + + 先选择最适合你的入口,然后开始行动。 + + + + {FINAL_CTAS.map((cta, i) => { + const Icon = ICONS[i]; + return ( + + + + ); + })} + +
+
+ ); +} diff --git a/components/sections/hero.tsx b/components/sections/hero.tsx new file mode 100644 index 0000000..8b28586 --- /dev/null +++ b/components/sections/hero.tsx @@ -0,0 +1,141 @@ +"use client"; + +import Link from "next/link"; +import { MapPin, BookOpen, Crown } from "lucide-react"; +import { motion } from "framer-motion"; +import { HERO_TAGS } from "~/lib/data"; +import { Button } from "~/components/ui/button"; + +const HERO_CARDS = [ + { + title: "探索城市", + desc: "找到适合远程生活的地方", + icon: MapPin, + href: "https://meetup.hackrobot.cn", + }, + { + title: "学习专题", + desc: "从零搭建你的技能与收入结构", + icon: BookOpen, + href: "https://digital.hackrobot.cn", + }, + { + title: "会员社区", + desc: "进入更高密度的人脉与资源网络", + icon: Crown, + href: "https://vip.hackrobot.cn", + }, +]; + +export function Hero() { + return ( +
+
+
+
+ +

+ 中文数字游民操作系统 +

+

+ 从城市、技能、工具到社群,一站开始 +

+

+ 帮你从固定工位,走向自由生活与自由收入 +

+
+ + + 数字游民不只是旅行,而是「地点自由 + 收入结构 + 系统工具 + 社群连接」的组合。 + + + + + + + + + + + + + + + + {HERO_TAGS.map((tag, i) => ( + + {tag} + + ))} + +
+ + +
+ {HERO_CARDS.map((card, i) => ( + + +

+ {card.title} +

+

{card.desc}

+ + ))} +
+
+
+
+
+ ); +} diff --git a/components/sections/methodology.tsx b/components/sections/methodology.tsx new file mode 100644 index 0000000..f1fcd33 --- /dev/null +++ b/components/sections/methodology.tsx @@ -0,0 +1,70 @@ +"use client"; + +import { MapPin, Wallet, Wrench, Users } from "lucide-react"; +import { motion } from "framer-motion"; +import { METHODOLOGY_SYSTEMS } from "~/lib/data"; + +const ICON_MAP = { + location: MapPin, + income: Wallet, + tools: Wrench, + community: Users, +} as const; + +export function Methodology() { + return ( +
+
+ + 数字游民,不只是旅行 + + + 真正的数字游民,由四个系统组成 + + +
+ {METHODOLOGY_SYSTEMS.map((sys, i) => { + const Icon = ICON_MAP[sys.id]; + return ( + + +

+ {sys.title} +

+

+ {sys.description} +

+
+ ); + })} +
+ + + 从选择城市,到建立收入,再到搭建系统和进入社群,这才是数字游民真正可持续的底层结构。 + +
+
+ ); +} diff --git a/components/sections/scenarios.tsx b/components/sections/scenarios.tsx new file mode 100644 index 0000000..553fe7a --- /dev/null +++ b/components/sections/scenarios.tsx @@ -0,0 +1,57 @@ +"use client"; + +import Link from "next/link"; +import { ArrowRight } from "lucide-react"; +import { motion } from "framer-motion"; +import { SCENARIOS } from "~/lib/data"; + +export function Scenarios() { + return ( +
+
+ + 找到你的场景 + + + 不同阶段,不同需求,都有对应路径 + + +
+ {SCENARIOS.map((s, i) => ( + + +

{s.pain}

+

{s.path}

+ + {s.cta} + + + +
+ ))} +
+
+
+ ); +} diff --git a/components/sections/trust.tsx b/components/sections/trust.tsx new file mode 100644 index 0000000..129d1da --- /dev/null +++ b/components/sections/trust.tsx @@ -0,0 +1,56 @@ +"use client"; + +import { Target, Layers, Handshake } from "lucide-react"; +import { motion } from "framer-motion"; +import { TRUST_PRINCIPLES } from "~/lib/data"; + +const ICON_MAP = [Target, Layers, Handshake] as const; + +export function Trust() { + return ( +
+
+ + 我们的原则 + + + 不吹嘘,不夸大,只说清楚我们相信什么 + + +
+ {TRUST_PRINCIPLES.map((p, i) => { + const Icon = ICON_MAP[i]; + return ( + + +

+ {p.title} +

+

+ {p.description} +

+
+ ); + })} +
+
+
+ ); +} diff --git a/components/sections/value-grid.tsx b/components/sections/value-grid.tsx new file mode 100644 index 0000000..e67ff56 --- /dev/null +++ b/components/sections/value-grid.tsx @@ -0,0 +1,61 @@ +"use client"; + +import { MapPin, TrendingUp, Zap, Users } from "lucide-react"; +import { motion } from "framer-motion"; +import { VALUE_PROPOSITIONS } from "~/lib/data"; + +const ICON_MAP = { + MapPin, + TrendingUp, + Zap, + Users, +} as const; + +export function ValueGrid() { + return ( +
+
+ + 你能在这里获得什么 + + + 不是功能列表,而是实实在在的结果 + + +
+ {VALUE_PROPOSITIONS.map((item, i) => { + const Icon = ICON_MAP[item.icon]; + return ( + + +

+ {item.title} +

+

+ {item.description} +

+
+ ); + })} +
+
+
+ ); +} diff --git a/components/ui/button.tsx b/components/ui/button.tsx new file mode 100644 index 0000000..5bdf491 --- /dev/null +++ b/components/ui/button.tsx @@ -0,0 +1,38 @@ +import * as React from "react"; + +export interface ButtonProps + extends React.ButtonHTMLAttributes { + variant?: "default" | "outline" | "ghost" | "link"; + size?: "default" | "sm" | "lg"; + asChild?: boolean; +} + +const Button = React.forwardRef( + ({ className = "", variant = "default", size = "default", ...props }, ref) => { + const base = + "inline-flex items-center justify-center whitespace-nowrap rounded-lg font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"; + const variants = { + default: + "bg-neutral-900 text-white hover:bg-neutral-800 focus-visible:ring-neutral-900", + outline: + "border border-neutral-200 bg-transparent hover:bg-neutral-50 focus-visible:ring-neutral-400", + ghost: "hover:bg-neutral-100 focus-visible:ring-neutral-400", + link: "text-neutral-900 underline-offset-4 hover:underline focus-visible:ring-neutral-400", + }; + const sizes = { + default: "h-10 px-4 py-2 text-sm", + sm: "h-8 px-3 text-xs", + lg: "h-12 px-6 text-base", + }; + return ( + - - - ); -} diff --git a/src/app/api/auth/[...nextauth]/route.ts b/src/app/api/auth/[...nextauth]/route.ts deleted file mode 100644 index 8e8302c..0000000 --- a/src/app/api/auth/[...nextauth]/route.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { handlers } from "~/server/auth"; - -export const { GET, POST } = handlers; diff --git a/src/app/api/trpc/[trpc]/route.ts b/src/app/api/trpc/[trpc]/route.ts deleted file mode 100644 index 5fbd827..0000000 --- a/src/app/api/trpc/[trpc]/route.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { fetchRequestHandler } from "@trpc/server/adapters/fetch"; -import { type NextRequest } from "next/server"; - -import { env } from "~/env"; -import { appRouter } from "~/server/api/root"; -import { createTRPCContext } from "~/server/api/trpc"; - -/** - * This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when - * handling a HTTP request (e.g. when you make requests from Client Components). - */ -const createContext = async (req: NextRequest) => { - return createTRPCContext({ - headers: req.headers, - }); -}; - -const handler = (req: NextRequest) => - fetchRequestHandler({ - endpoint: "/api/trpc", - req, - router: appRouter, - createContext: () => createContext(req), - onError: - env.NODE_ENV === "development" - ? ({ path, error }) => { - console.error( - `❌ tRPC failed on ${path ?? ""}: ${error.message}` - ); - } - : undefined, - }); - -export { handler as GET, handler as POST }; diff --git a/src/app/layout.tsx b/src/app/layout.tsx deleted file mode 100644 index ab0d1bc..0000000 --- a/src/app/layout.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import "~/styles/globals.css"; - -import { type Metadata } from "next"; -import { Geist } from "next/font/google"; - -import { TRPCReactProvider } from "~/trpc/react"; - -export const metadata: Metadata = { - title: "nomadro", - description: "nomadro", - // icons: [{ rel: "icon", url: "/favicon.ico" }], - icons: [{ rel: "icon", url: "/nomadro.ico" }], - -}; - -const geist = Geist({ - subsets: ["latin"], - variable: "--font-geist-sans", -}); - -export default function RootLayout({ - children, -}: Readonly<{ children: React.ReactNode }>) { - return ( - - - {children} - - - ); -} diff --git a/src/app/page.tsx b/src/app/page.tsx deleted file mode 100644 index ae41abe..0000000 --- a/src/app/page.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import Link from "next/link"; - -import { LatestPost } from "~/app/_components/post"; -import { auth } from "~/server/auth"; -import { api, HydrateClient } from "~/trpc/server"; - -export default async function Home() { - const hello = await api.post.hello({ text: "from tRPC" }); - const session = await auth(); - - if (session?.user) { - void api.post.getLatest.prefetch(); - } - - return ( - -
-
-

- 数字游民 nomadro -

-
- -

游民导航 →

-
-
    -
  • 出海赚美金
  • -
  • -
-
- - -

低成本工作室 →

-
-
    -
  • 自建云手机
  • - {/*
  • 搭建sass网站
  • -
  • PVE虚拟化自建云桌面
  • -
  • AIGC+RPA自动化
  • */} -
-
- -
- - {/*
-

- {hello ? hello.greeting : "Loading tRPC query..."} -

- -
-

- {session && Logged in as {session.user?.name}} -

- - {session ? "Sign out" : "Sign in"} - -
-
*/} - - {/* {session?.user && } */} -
-
-
- ); -} diff --git a/src/env.js b/src/env.js deleted file mode 100644 index 6b19f72..0000000 --- a/src/env.js +++ /dev/null @@ -1,52 +0,0 @@ -import { createEnv } from "@t3-oss/env-nextjs"; -import { z } from "zod"; - -export const env = createEnv({ - /** - * Specify your server-side environment variables schema here. This way you can ensure the app - * isn't built with invalid env vars. - */ - server: { - AUTH_SECRET: - process.env.NODE_ENV === "production" - ? z.string() - : z.string().optional(), - AUTH_DISCORD_ID: z.string(), - AUTH_DISCORD_SECRET: z.string(), - DATABASE_URL: z.string().url(), - NODE_ENV: z - .enum(["development", "test", "production"]) - .default("development"), - }, - - /** - * Specify your client-side environment variables schema here. This way you can ensure the app - * isn't built with invalid env vars. To expose them to the client, prefix them with - * `NEXT_PUBLIC_`. - */ - client: { - // NEXT_PUBLIC_CLIENTVAR: z.string(), - }, - - /** - * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g. - * middlewares) or client-side so we need to destruct manually. - */ - runtimeEnv: { - AUTH_SECRET: process.env.AUTH_SECRET, - AUTH_DISCORD_ID: process.env.AUTH_DISCORD_ID, - AUTH_DISCORD_SECRET: process.env.AUTH_DISCORD_SECRET, - DATABASE_URL: process.env.DATABASE_URL, - NODE_ENV: process.env.NODE_ENV, - }, - /** - * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially - * useful for Docker builds. - */ - skipValidation: !!process.env.SKIP_ENV_VALIDATION, - /** - * Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and - * `SOME_VAR=''` will throw an error. - */ - emptyStringAsUndefined: true, -}); diff --git a/src/server/api/root.ts b/src/server/api/root.ts deleted file mode 100644 index b341fc4..0000000 --- a/src/server/api/root.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { postRouter } from "~/server/api/routers/post"; -import { createCallerFactory, createTRPCRouter } from "~/server/api/trpc"; - -/** - * This is the primary router for your server. - * - * All routers added in /api/routers should be manually added here. - */ -export const appRouter = createTRPCRouter({ - post: postRouter, -}); - -// export type definition of API -export type AppRouter = typeof appRouter; - -/** - * Create a server-side caller for the tRPC API. - * @example - * const trpc = createCaller(createContext); - * const res = await trpc.post.all(); - * ^? Post[] - */ -export const createCaller = createCallerFactory(appRouter); diff --git a/src/server/api/routers/post.ts b/src/server/api/routers/post.ts deleted file mode 100644 index b602dd5..0000000 --- a/src/server/api/routers/post.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { z } from "zod"; - -import { - createTRPCRouter, - protectedProcedure, - publicProcedure, -} from "~/server/api/trpc"; - -export const postRouter = createTRPCRouter({ - hello: publicProcedure - .input(z.object({ text: z.string() })) - .query(({ input }) => { - return { - greeting: `Hello ${input.text}`, - }; - }), - - create: protectedProcedure - .input(z.object({ name: z.string().min(1) })) - .mutation(async ({ ctx, input }) => { - return ctx.db.post.create({ - data: { - name: input.name, - createdBy: { connect: { id: ctx.session.user.id } }, - }, - }); - }), - - getLatest: protectedProcedure.query(async ({ ctx }) => { - const post = await ctx.db.post.findFirst({ - orderBy: { createdAt: "desc" }, - where: { createdBy: { id: ctx.session.user.id } }, - }); - - return post ?? null; - }), - - getSecretMessage: protectedProcedure.query(() => { - return "you can now see this secret message!"; - }), -}); diff --git a/src/server/api/trpc.ts b/src/server/api/trpc.ts deleted file mode 100644 index 923751a..0000000 --- a/src/server/api/trpc.ts +++ /dev/null @@ -1,133 +0,0 @@ -/** - * YOU PROBABLY DON'T NEED TO EDIT THIS FILE, UNLESS: - * 1. You want to modify request context (see Part 1). - * 2. You want to create a new middleware or type of procedure (see Part 3). - * - * TL;DR - This is where all the tRPC server stuff is created and plugged in. The pieces you will - * need to use are documented accordingly near the end. - */ - -import { initTRPC, TRPCError } from "@trpc/server"; -import superjson from "superjson"; -import { ZodError } from "zod"; - -import { auth } from "~/server/auth"; -import { db } from "~/server/db"; - -/** - * 1. CONTEXT - * - * This section defines the "contexts" that are available in the backend API. - * - * These allow you to access things when processing a request, like the database, the session, etc. - * - * This helper generates the "internals" for a tRPC context. The API handler and RSC clients each - * wrap this and provides the required context. - * - * @see https://trpc.io/docs/server/context - */ -export const createTRPCContext = async (opts: { headers: Headers }) => { - const session = await auth(); - - return { - db, - session, - ...opts, - }; -}; - -/** - * 2. INITIALIZATION - * - * This is where the tRPC API is initialized, connecting the context and transformer. We also parse - * ZodErrors so that you get typesafety on the frontend if your procedure fails due to validation - * errors on the backend. - */ -const t = initTRPC.context().create({ - transformer: superjson, - errorFormatter({ shape, error }) { - return { - ...shape, - data: { - ...shape.data, - zodError: - error.cause instanceof ZodError ? error.cause.flatten() : null, - }, - }; - }, -}); - -/** - * Create a server-side caller. - * - * @see https://trpc.io/docs/server/server-side-calls - */ -export const createCallerFactory = t.createCallerFactory; - -/** - * 3. ROUTER & PROCEDURE (THE IMPORTANT BIT) - * - * These are the pieces you use to build your tRPC API. You should import these a lot in the - * "/src/server/api/routers" directory. - */ - -/** - * This is how you create new routers and sub-routers in your tRPC API. - * - * @see https://trpc.io/docs/router - */ -export const createTRPCRouter = t.router; - -/** - * Middleware for timing procedure execution and adding an artificial delay in development. - * - * You can remove this if you don't like it, but it can help catch unwanted waterfalls by simulating - * network latency that would occur in production but not in local development. - */ -const timingMiddleware = t.middleware(async ({ next, path }) => { - const start = Date.now(); - - if (t._config.isDev) { - // artificial delay in dev - const waitMs = Math.floor(Math.random() * 400) + 100; - await new Promise((resolve) => setTimeout(resolve, waitMs)); - } - - const result = await next(); - - const end = Date.now(); - console.log(`[TRPC] ${path} took ${end - start}ms to execute`); - - return result; -}); - -/** - * Public (unauthenticated) procedure - * - * This is the base piece you use to build new queries and mutations on your tRPC API. It does not - * guarantee that a user querying is authorized, but you can still access user session data if they - * are logged in. - */ -export const publicProcedure = t.procedure.use(timingMiddleware); - -/** - * Protected (authenticated) procedure - * - * If you want a query or mutation to ONLY be accessible to logged in users, use this. It verifies - * the session is valid and guarantees `ctx.session.user` is not null. - * - * @see https://trpc.io/docs/procedures - */ -export const protectedProcedure = t.procedure - .use(timingMiddleware) - .use(({ ctx, next }) => { - if (!ctx.session?.user) { - throw new TRPCError({ code: "UNAUTHORIZED" }); - } - return next({ - ctx: { - // infers the `session` as non-nullable - session: { ...ctx.session, user: ctx.session.user }, - }, - }); - }); diff --git a/src/server/auth/config.ts b/src/server/auth/config.ts deleted file mode 100644 index 9b8ec79..0000000 --- a/src/server/auth/config.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { PrismaAdapter } from "@auth/prisma-adapter"; -import { type DefaultSession, type NextAuthConfig } from "next-auth"; -import DiscordProvider from "next-auth/providers/discord"; - -import { db } from "~/server/db"; - -/** - * Module augmentation for `next-auth` types. Allows us to add custom properties to the `session` - * object and keep type safety. - * - * @see https://next-auth.js.org/getting-started/typescript#module-augmentation - */ -declare module "next-auth" { - interface Session extends DefaultSession { - user: { - id: string; - // ...other properties - // role: UserRole; - } & DefaultSession["user"]; - } - - // interface User { - // // ...other properties - // // role: UserRole; - // } -} - -/** - * Options for NextAuth.js used to configure adapters, providers, callbacks, etc. - * - * @see https://next-auth.js.org/configuration/options - */ -export const authConfig = { - providers: [ - DiscordProvider, - /** - * ...add more providers here. - * - * Most other providers require a bit more work than the Discord provider. For example, the - * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account - * model. Refer to the NextAuth.js docs for the provider you want to use. Example: - * - * @see https://next-auth.js.org/providers/github - */ - ], - adapter: PrismaAdapter(db), - callbacks: { - session: ({ session, user }) => ({ - ...session, - user: { - ...session.user, - id: user.id, - }, - }), - }, -} satisfies NextAuthConfig; diff --git a/src/server/auth/index.ts b/src/server/auth/index.ts deleted file mode 100644 index 76c146d..0000000 --- a/src/server/auth/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import NextAuth from "next-auth"; -import { cache } from "react"; - -import { authConfig } from "./config"; - -const { auth: uncachedAuth, handlers, signIn, signOut } = NextAuth(authConfig); - -const auth = cache(uncachedAuth); - -export { auth, handlers, signIn, signOut }; diff --git a/src/server/db.ts b/src/server/db.ts deleted file mode 100644 index 37b65c6..0000000 --- a/src/server/db.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { env } from "~/env"; -import { PrismaClient } from "../../generated/prisma"; - -const createPrismaClient = () => - new PrismaClient({ - log: - env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"], - }); - -const globalForPrisma = globalThis as unknown as { - prisma: ReturnType | undefined; -}; - -export const db = globalForPrisma.prisma ?? createPrismaClient(); - -if (env.NODE_ENV !== "production") globalForPrisma.prisma = db; diff --git a/src/styles/globals.css b/src/styles/globals.css deleted file mode 100644 index 8fe04fa..0000000 --- a/src/styles/globals.css +++ /dev/null @@ -1,6 +0,0 @@ -@import "tailwindcss"; - -@theme { - --font-sans: var(--font-geist-sans), ui-sans-serif, system-ui, sans-serif, - "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; -} diff --git a/src/trpc/query-client.ts b/src/trpc/query-client.ts deleted file mode 100644 index bda6439..0000000 --- a/src/trpc/query-client.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { - defaultShouldDehydrateQuery, - QueryClient, -} from "@tanstack/react-query"; -import SuperJSON from "superjson"; - -export const createQueryClient = () => - new QueryClient({ - defaultOptions: { - queries: { - // With SSR, we usually want to set some default staleTime - // above 0 to avoid refetching immediately on the client - staleTime: 30 * 1000, - }, - dehydrate: { - serializeData: SuperJSON.serialize, - shouldDehydrateQuery: (query) => - defaultShouldDehydrateQuery(query) || - query.state.status === "pending", - }, - hydrate: { - deserializeData: SuperJSON.deserialize, - }, - }, - }); diff --git a/src/trpc/react.tsx b/src/trpc/react.tsx deleted file mode 100644 index 378290c..0000000 --- a/src/trpc/react.tsx +++ /dev/null @@ -1,78 +0,0 @@ -"use client"; - -import { QueryClientProvider, type QueryClient } from "@tanstack/react-query"; -import { httpBatchStreamLink, loggerLink } from "@trpc/client"; -import { createTRPCReact } from "@trpc/react-query"; -import { type inferRouterInputs, type inferRouterOutputs } from "@trpc/server"; -import { useState } from "react"; -import SuperJSON from "superjson"; - -import { type AppRouter } from "~/server/api/root"; -import { createQueryClient } from "./query-client"; - -let clientQueryClientSingleton: QueryClient | undefined = undefined; -const getQueryClient = () => { - if (typeof window === "undefined") { - // Server: always make a new query client - return createQueryClient(); - } - // Browser: use singleton pattern to keep the same query client - clientQueryClientSingleton ??= createQueryClient(); - - return clientQueryClientSingleton; -}; - -export const api = createTRPCReact(); - -/** - * Inference helper for inputs. - * - * @example type HelloInput = RouterInputs['example']['hello'] - */ -export type RouterInputs = inferRouterInputs; - -/** - * Inference helper for outputs. - * - * @example type HelloOutput = RouterOutputs['example']['hello'] - */ -export type RouterOutputs = inferRouterOutputs; - -export function TRPCReactProvider(props: { children: React.ReactNode }) { - const queryClient = getQueryClient(); - - const [trpcClient] = useState(() => - api.createClient({ - links: [ - loggerLink({ - enabled: (op) => - process.env.NODE_ENV === "development" || - (op.direction === "down" && op.result instanceof Error), - }), - httpBatchStreamLink({ - transformer: SuperJSON, - url: getBaseUrl() + "/api/trpc", - headers: () => { - const headers = new Headers(); - headers.set("x-trpc-source", "nextjs-react"); - return headers; - }, - }), - ], - }) - ); - - return ( - - - {props.children} - - - ); -} - -function getBaseUrl() { - if (typeof window !== "undefined") return window.location.origin; - if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`; - return `http://localhost:${process.env.PORT ?? 3000}`; -} diff --git a/src/trpc/server.ts b/src/trpc/server.ts deleted file mode 100644 index 91e557e..0000000 --- a/src/trpc/server.ts +++ /dev/null @@ -1,30 +0,0 @@ -import "server-only"; - -import { createHydrationHelpers } from "@trpc/react-query/rsc"; -import { headers } from "next/headers"; -import { cache } from "react"; - -import { createCaller, type AppRouter } from "~/server/api/root"; -import { createTRPCContext } from "~/server/api/trpc"; -import { createQueryClient } from "./query-client"; - -/** - * This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when - * handling a tRPC call from a React Server Component. - */ -const createContext = cache(async () => { - const heads = new Headers(await headers()); - heads.set("x-trpc-source", "rsc"); - - return createTRPCContext({ - headers: heads, - }); -}); - -const getQueryClient = cache(createQueryClient); -const caller = createCaller(createContext); - -export const { trpc: api, HydrateClient } = createHydrationHelpers( - caller, - getQueryClient -); diff --git a/tsconfig.json b/tsconfig.json index 3eb759e..c4d3897 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,42 +1,35 @@ { "compilerOptions": { - /* Base Options: */ - "esModuleInterop": true, - "skipLibCheck": true, - "target": "es2022", + "target": "ES2017", + "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, - "resolveJsonModule": true, - "moduleDetection": "force", - "isolatedModules": true, - "verbatimModuleSyntax": true, - - /* Strictness */ + "skipLibCheck": true, "strict": true, - "noUncheckedIndexedAccess": true, - "checkJs": true, - - /* Bundled projects */ - "lib": ["dom", "dom.iterable", "ES2022"], "noEmit": true, - "module": "ESNext", - "moduleResolution": "Bundler", - "jsx": "preserve", - "plugins": [{ "name": "next" }], + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "bundler", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "react-jsx", "incremental": true, - - /* Path Aliases */ - "baseUrl": ".", + "plugins": [ + { + "name": "next" + } + ], "paths": { - "~/*": ["./src/*"] + "@/*": ["./*"], + "~/*": ["./*"] } }, "include": [ "next-env.d.ts", "**/*.ts", "**/*.tsx", - "**/*.cjs", - "**/*.js", - ".next/types/**/*.ts" + ".next/types/**/*.ts", + ".next/dev/types/**/*.ts", + "**/*.mts" ], - "exclude": ["node_modules", "generated"] + "exclude": ["node_modules"] }