From 97b1b3230e109979e5e1be21c07a02bc1dddb03b Mon Sep 17 00:00:00 2001 From: liushuxiang <276900785@qq.com> Date: Tue, 16 May 2023 18:19:49 +0800 Subject: [PATCH] feat: add announcement --- package.json | 1 + pnpm-lock.yaml | 26 ++++++++ prisma/schema.prisma | 20 ++++++ src/app/[locale]/(account)/account/page.tsx | 2 + .../[locale]/(account)/account/team/page.tsx | 3 +- .../[locale]/(authentication)/login/page.tsx | 7 +-- src/app/[locale]/layout.tsx | 2 + src/app/api/auth/[...nextauth]/route.ts | 21 +++---- src/app/layout.tsx | 6 +- src/components/announcement/index.tsx | 62 +++++++++++++++++++ src/components/auth/avatar.tsx | 6 +- src/components/auth/form.tsx | 24 ++++++- src/locales/en.json | 8 ++- src/locales/zh-CN.json | 6 ++ 14 files changed, 170 insertions(+), 24 deletions(-) create mode 100644 src/components/announcement/index.tsx diff --git a/package.json b/package.json index 9fb2f14..6b64124 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "@radix-ui/react-popover": "1.0.5", "@radix-ui/react-select": "1.2.1", "@radix-ui/react-slider": "1.1.1", + "@radix-ui/react-toast": "^1.1.3", "@sentry/nextjs": "7.52.1", "@svgr/webpack": "8.0.1", "@types/node": "20.1.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 374c704..078e78e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -31,6 +31,9 @@ dependencies: '@radix-ui/react-slider': specifier: 1.1.1 version: 1.1.1(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-toast': + specifier: ^1.1.3 + version: 1.1.3(react-dom@18.2.0)(react@18.2.0) '@sentry/nextjs': specifier: 7.52.1 version: 7.52.1(next@13.4.2)(react@18.2.0) @@ -2250,6 +2253,29 @@ packages: react: 18.2.0 dev: false + /@radix-ui/react-toast@1.1.3(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-yHFgpxi9wjbfPvpSPdYAzivCqw48eA1ofT8m/WqYOVTxKPdmQMuVKRYPlMmj4C1d6tJdFj/LBa1J4iY3fL4OwQ==} + peerDependencies: + react: ^16.8 || ^17.0 || ^18.0 + react-dom: ^16.8 || ^17.0 || ^18.0 + dependencies: + '@babel/runtime': 7.21.5 + '@radix-ui/primitive': 1.0.0 + '@radix-ui/react-collection': 1.0.2(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-compose-refs': 1.0.0(react@18.2.0) + '@radix-ui/react-context': 1.0.0(react@18.2.0) + '@radix-ui/react-dismissable-layer': 1.0.3(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-portal': 1.0.2(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-presence': 1.0.0(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-primitive': 1.0.2(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-use-callback-ref': 1.0.0(react@18.2.0) + '@radix-ui/react-use-controllable-state': 1.0.0(react@18.2.0) + '@radix-ui/react-use-layout-effect': 1.0.0(react@18.2.0) + '@radix-ui/react-visually-hidden': 1.0.2(react-dom@18.2.0)(react@18.2.0) + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + dev: false + /@radix-ui/react-use-callback-ref@1.0.0(react@18.2.0): resolution: {integrity: sha512-GZtyzoHz95Rhs6S63D2t/eqvdFCm7I+yHMLVQheKM7nBD8mbZIt+ct1jz4536MDnaOGKIxynJ8eHTkVGVVkoTg==} peerDependencies: diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 70c92e1..7a4fa5e 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -10,6 +10,25 @@ datasource db { url = env("DATABASE_URL") } +model Account { + id String @id @default(cuid()) + userId String + type String + provider String + providerAccountId String + refresh_token String? @db.Text + access_token String? @db.Text + expires_at Int? + token_type String? + scope String? + id_token String? @db.Text + session_state String? + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + @@unique([provider, providerAccountId]) +} + model Session { id String @id @default(cuid()) sessionToken String @unique @@ -25,6 +44,7 @@ model User { emailVerified DateTime? image String? sessions Session[] + accounts Account[] } model VerificationToken { diff --git a/src/app/[locale]/(account)/account/page.tsx b/src/app/[locale]/(account)/account/page.tsx index 7051369..d33bc2a 100644 --- a/src/app/[locale]/(account)/account/page.tsx +++ b/src/app/[locale]/(account)/account/page.tsx @@ -114,6 +114,8 @@ const Account: React.FC = () => {
{t("avatar")}
onchange(value, "image")} /> diff --git a/src/app/[locale]/(account)/account/team/page.tsx b/src/app/[locale]/(account)/account/team/page.tsx index e11df46..7dbc422 100644 --- a/src/app/[locale]/(account)/account/team/page.tsx +++ b/src/app/[locale]/(account)/account/team/page.tsx @@ -3,11 +3,12 @@ import * as React from "react"; const Team: React.FC = () => { return (
-
团队设置
+
Teams
Manage the Teams that you're a part of, join suggested ones, or create a new one.
+
Todo...
); }; diff --git a/src/app/[locale]/(authentication)/login/page.tsx b/src/app/[locale]/(authentication)/login/page.tsx index 1cc1ea3..51f0a56 100644 --- a/src/app/[locale]/(authentication)/login/page.tsx +++ b/src/app/[locale]/(authentication)/login/page.tsx @@ -1,6 +1,7 @@ import * as React from "react"; import { cn } from "@/lib"; import AuthForm from "@/components/auth/form"; +import Logo from "@/components/logo"; const Login: React.FC = () => { return ( @@ -11,11 +12,7 @@ const Login: React.FC = () => { "dark:border-neutral-600" )} > -
- - L - GPT - -
+
diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index 5cd3eeb..6e0baac 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -1,5 +1,6 @@ import { NextIntlClientProvider } from "next-intl"; import { notFound } from "next/navigation"; +import Announcement from "@/components/announcement"; interface LocaleLayoutProps { children: React.ReactNode; @@ -19,6 +20,7 @@ export default async function LocaleLayout({ return ( + {children} ); diff --git a/src/app/api/auth/[...nextauth]/route.ts b/src/app/api/auth/[...nextauth]/route.ts index 52f154a..5c434eb 100644 --- a/src/app/api/auth/[...nextauth]/route.ts +++ b/src/app/api/auth/[...nextauth]/route.ts @@ -1,6 +1,7 @@ import NextAuth from "next-auth"; import type { NextAuthOptions } from "next-auth"; import GithubProvider from "next-auth/providers/github"; +import GoogleProvider from "next-auth/providers/google"; import EmailProvider from "next-auth/providers/email"; import { PrismaAdapter } from "@next-auth/prisma-adapter"; import { prisma } from "@/lib/prisma"; @@ -19,18 +20,14 @@ export const authOptions: NextAuthOptions = { }, from: process.env.EMAIL_FROM, }), - // EmailProvider({ - // // server: "smtp://276900785@qq.com:fnmvpdkxjtqjbjgc@smtp.qq.com:465", - // server: "smtp://liushuxiang1993:WFCLNBQGTRTMDORC@smtp.163.com:465", - // // from: "NextAuth ", - // // WFCLNBQGTRTMDORC - // // qq: fnmvpdkxjtqjbjgc - // maxAge: 24 * 60 * 60, // 设置邮箱链接失效时间,默认24小时 - // }), - // GithubProvider({ - // clientId: "894f395fe1e70358caca", - // clientSecret: "fd5a93dcc14cc6e2c0566436f983ed0b2578ce05", - // }), + GithubProvider({ + clientId: process.env.GITHUB_ID || "", + clientSecret: process.env.GITHUB_SECRET || "", + }), + GoogleProvider({ + clientId: process.env.GOOGLE_CLIENT_ID || "", + clientSecret: process.env.GOOGLE_CLIENT_SECRET || "", + }), ], secret: process.env.EMAIL_SECRET, callbacks: { diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 50b368f..b891703 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -29,7 +29,11 @@ export default function RootLayout({ children }: RootLayoutProps) {