create-nextdevtpl 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/catalog.json +385 -0
- package/dist/catalog.d.ts +3 -0
- package/dist/catalog.js +112 -0
- package/dist/catalog.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +115 -0
- package/dist/cli.js.map +1 -0
- package/dist/filesystem.d.ts +10 -0
- package/dist/filesystem.js +86 -0
- package/dist/filesystem.js.map +1 -0
- package/dist/generate.d.ts +5 -0
- package/dist/generate.js +758 -0
- package/dist/generate.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/selection.d.ts +2 -0
- package/dist/selection.js +111 -0
- package/dist/selection.js.map +1 -0
- package/dist/service-templates.d.ts +4 -0
- package/dist/service-templates.js +180 -0
- package/dist/service-templates.js.map +1 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -0
- package/template/.dockerignore +14 -0
- package/template/.env.example +282 -0
- package/template/.gitattributes +17 -0
- package/template/.node-version +1 -0
- package/template/Dockerfile +45 -0
- package/template/LICENSE +21 -0
- package/template/README.md +267 -0
- package/template/biome.json +68 -0
- package/template/cloudflare/templates/logger.ts +162 -0
- package/template/cloudflare/templates/mail/server.ts +6 -0
- package/template/cloudflare/templates/mail/templates.ts +87 -0
- package/template/cloudflare/templates/mail/utils.ts +69 -0
- package/template/cloudflare/worker.mjs +25 -0
- package/template/components.json +22 -0
- package/template/compose.yaml +74 -0
- package/template/deploy/check-health.mjs +25 -0
- package/template/deploy/docker/README.md +14 -0
- package/template/deploy/server/README.md +24 -0
- package/template/deploy/server/build.sh +24 -0
- package/template/deploy/server/nextdevtpl.service +19 -0
- package/template/deploy/server/start.sh +19 -0
- package/template/deploy/vercel/README.md +16 -0
- package/template/deploy/verify-production-health.mjs +86 -0
- package/template/drizzle.config.ts +47 -0
- package/template/gitignore +62 -0
- package/template/manifest.json +35 -0
- package/template/messages/en.json +766 -0
- package/template/messages/zh.json +762 -0
- package/template/next.config.mjs +28 -0
- package/template/open-next.config.ts +3 -0
- package/template/package.json +125 -0
- package/template/pnpm-lock.yaml +15901 -0
- package/template/postcss.config.mjs +7 -0
- package/template/public/file.svg +1 -0
- package/template/public/globe.svg +1 -0
- package/template/public/logo.svg +6 -0
- package/template/public/next.svg +1 -0
- package/template/public/vercel.svg +1 -0
- package/template/public/window.svg +1 -0
- package/template/sentry.client.config.ts +10 -0
- package/template/sentry.edge.config.ts +10 -0
- package/template/sentry.server.config.ts +10 -0
- package/template/source.config.ts +59 -0
- package/template/src/adapters/ai/anthropic.ts +113 -0
- package/template/src/adapters/ai/index.ts +6 -0
- package/template/src/adapters/ai/openai-compatible.ts +88 -0
- package/template/src/adapters/ai/workers-ai.ts +63 -0
- package/template/src/adapters/index.ts +10 -0
- package/template/src/adapters/jobs/cloudflare-workflows.ts +46 -0
- package/template/src/adapters/jobs/index.ts +5 -0
- package/template/src/adapters/jobs/inngest/adapter.ts +29 -0
- package/template/src/adapters/jobs/inngest/client.ts +8 -0
- package/template/src/adapters/jobs/inngest/functions.ts +17 -0
- package/template/src/adapters/jobs/inngest/handler.ts +6 -0
- package/template/src/adapters/jobs/inngest/index.ts +4 -0
- package/template/src/adapters/mail/cloudflare-email.ts +50 -0
- package/template/src/adapters/mail/disabled.ts +17 -0
- package/template/src/adapters/mail/index.ts +7 -0
- package/template/src/adapters/mail/resend.ts +76 -0
- package/template/src/adapters/mail/smtp.ts +82 -0
- package/template/src/adapters/payment/creem.ts +269 -0
- package/template/src/adapters/payment/index.ts +2 -0
- package/template/src/adapters/payment/stripe.ts +302 -0
- package/template/src/adapters/rate-limit/cloudflare.ts +42 -0
- package/template/src/adapters/rate-limit/index.ts +6 -0
- package/template/src/adapters/rate-limit/noop.ts +27 -0
- package/template/src/adapters/rate-limit/upstash.ts +113 -0
- package/template/src/adapters/registry.ts +228 -0
- package/template/src/adapters/storage/index.ts +3 -0
- package/template/src/adapters/storage/r2-binding.ts +105 -0
- package/template/src/adapters/storage/s3-compatible.ts +149 -0
- package/template/src/app/[locale]/(admin)/admin/layout.tsx +36 -0
- package/template/src/app/[locale]/(admin)/admin/page.tsx +345 -0
- package/template/src/app/[locale]/(admin)/admin/tickets/[id]/page.tsx +261 -0
- package/template/src/app/[locale]/(admin)/admin/tickets/page.tsx +236 -0
- package/template/src/app/[locale]/(admin)/admin/users/page.tsx +557 -0
- package/template/src/app/[locale]/(auth)/forgot-password/page.tsx +9 -0
- package/template/src/app/[locale]/(auth)/layout.tsx +28 -0
- package/template/src/app/[locale]/(auth)/sign-in/page.tsx +9 -0
- package/template/src/app/[locale]/(auth)/sign-up/page.tsx +9 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/credits/buy/buy-credits-view.tsx +170 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/credits/buy/page.tsx +12 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/credits/page.tsx +5 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/loading.tsx +41 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/page.tsx +299 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/settings/page.tsx +38 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/support/[id]/page.tsx +220 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/support/new/page.tsx +183 -0
- package/template/src/app/[locale]/(dashboard)/dashboard/support/page.tsx +145 -0
- package/template/src/app/[locale]/(dashboard)/layout.tsx +35 -0
- package/template/src/app/[locale]/(marketing)/blog/[slug]/page.tsx +178 -0
- package/template/src/app/[locale]/(marketing)/blog/blog-post-card.tsx +95 -0
- package/template/src/app/[locale]/(marketing)/blog/page.tsx +127 -0
- package/template/src/app/[locale]/(marketing)/demo/plan-badges/page.tsx +36 -0
- package/template/src/app/[locale]/(marketing)/layout.tsx +15 -0
- package/template/src/app/[locale]/(marketing)/legal/[slug]/page.tsx +130 -0
- package/template/src/app/[locale]/(marketing)/page.tsx +94 -0
- package/template/src/app/[locale]/(marketing)/pseo/[slug]/page.tsx +68 -0
- package/template/src/app/[locale]/(marketing)/pseo/page.tsx +137 -0
- package/template/src/app/[locale]/docs/[[...slug]]/page.tsx +63 -0
- package/template/src/app/[locale]/docs/layout.tsx +39 -0
- package/template/src/app/[locale]/layout.tsx +80 -0
- package/template/src/app/[locale]/opengraph-image.tsx +20 -0
- package/template/src/app/[locale]/twitter-image.tsx +20 -0
- package/template/src/app/api/auth/[...all]/route.ts +20 -0
- package/template/src/app/api/health/route.ts +45 -0
- package/template/src/app/api/inngest/route.ts +12 -0
- package/template/src/app/api/jobs/credits/expire/route.ts +102 -0
- package/template/src/app/api/search/route.ts +17 -0
- package/template/src/app/api/upload/presigned/route.ts +98 -0
- package/template/src/app/api/webhooks/payment/route.ts +363 -0
- package/template/src/app/globals.css +406 -0
- package/template/src/app/icon.svg +6 -0
- package/template/src/app/image-proxy/[...path]/route.ts +137 -0
- package/template/src/app/layout.tsx +73 -0
- package/template/src/app/robots.ts +29 -0
- package/template/src/app/sitemap.ts +68 -0
- package/template/src/components/motion/reveal.tsx +49 -0
- package/template/src/components/seo/json-ld.tsx +87 -0
- package/template/src/components/seo/og-image-template.tsx +118 -0
- package/template/src/components/ui/accordion.tsx +66 -0
- package/template/src/components/ui/alert-dialog.tsx +195 -0
- package/template/src/components/ui/avatar.tsx +53 -0
- package/template/src/components/ui/badge.tsx +46 -0
- package/template/src/components/ui/button.tsx +65 -0
- package/template/src/components/ui/card.tsx +92 -0
- package/template/src/components/ui/checkbox.tsx +32 -0
- package/template/src/components/ui/collapsible.tsx +33 -0
- package/template/src/components/ui/dialog.tsx +124 -0
- package/template/src/components/ui/dropdown-menu.tsx +257 -0
- package/template/src/components/ui/form.tsx +233 -0
- package/template/src/components/ui/index.ts +2 -0
- package/template/src/components/ui/input.tsx +21 -0
- package/template/src/components/ui/label.tsx +24 -0
- package/template/src/components/ui/navigation-menu.tsx +167 -0
- package/template/src/components/ui/pagination.tsx +125 -0
- package/template/src/components/ui/popover.tsx +48 -0
- package/template/src/components/ui/progress.tsx +27 -0
- package/template/src/components/ui/radio-group.tsx +45 -0
- package/template/src/components/ui/select.tsx +190 -0
- package/template/src/components/ui/separator.tsx +28 -0
- package/template/src/components/ui/sheet.tsx +140 -0
- package/template/src/components/ui/switch.tsx +31 -0
- package/template/src/components/ui/tabs.tsx +75 -0
- package/template/src/components/ui/textarea.tsx +18 -0
- package/template/src/config/index.ts +31 -0
- package/template/src/config/nav.ts +238 -0
- package/template/src/config/payment.ts +282 -0
- package/template/src/config/site.ts +53 -0
- package/template/src/config/subscription-plan.ts +164 -0
- package/template/src/content/blog/en/hello-world.mdx +48 -0
- package/template/src/content/blog/zh/hello-world.mdx +48 -0
- package/template/src/content/blog/zh/nextdevtpl-linuxdo-intro.mdx +98 -0
- package/template/src/content/docs/en/admin-and-support.mdx +65 -0
- package/template/src/content/docs/en/authentication.mdx +71 -0
- package/template/src/content/docs/en/background-jobs.mdx +53 -0
- package/template/src/content/docs/en/configuration.mdx +71 -0
- package/template/src/content/docs/en/credits.mdx +69 -0
- package/template/src/content/docs/en/customization.mdx +95 -0
- package/template/src/content/docs/en/database.mdx +66 -0
- package/template/src/content/docs/en/deployment.mdx +62 -0
- package/template/src/content/docs/en/email.mdx +48 -0
- package/template/src/content/docs/en/index.mdx +48 -0
- package/template/src/content/docs/en/internationalization.mdx +78 -0
- package/template/src/content/docs/en/meta.json +22 -0
- package/template/src/content/docs/en/observability.mdx +69 -0
- package/template/src/content/docs/en/payments.mdx +64 -0
- package/template/src/content/docs/en/project-structure.mdx +82 -0
- package/template/src/content/docs/en/quick-start.mdx +113 -0
- package/template/src/content/docs/en/storage.mdx +51 -0
- package/template/src/content/docs/zh/admin-and-support.mdx +65 -0
- package/template/src/content/docs/zh/authentication.mdx +71 -0
- package/template/src/content/docs/zh/background-jobs.mdx +53 -0
- package/template/src/content/docs/zh/configuration.mdx +70 -0
- package/template/src/content/docs/zh/credits.mdx +69 -0
- package/template/src/content/docs/zh/customization.mdx +95 -0
- package/template/src/content/docs/zh/database.mdx +66 -0
- package/template/src/content/docs/zh/deployment.mdx +61 -0
- package/template/src/content/docs/zh/email.mdx +47 -0
- package/template/src/content/docs/zh/index.mdx +48 -0
- package/template/src/content/docs/zh/internationalization.mdx +78 -0
- package/template/src/content/docs/zh/meta.json +22 -0
- package/template/src/content/docs/zh/observability.mdx +68 -0
- package/template/src/content/docs/zh/payments.mdx +64 -0
- package/template/src/content/docs/zh/project-structure.mdx +82 -0
- package/template/src/content/docs/zh/quick-start.mdx +110 -0
- package/template/src/content/docs/zh/storage.mdx +51 -0
- package/template/src/content/legal/en/cookie-policy.mdx +78 -0
- package/template/src/content/legal/en/privacy.mdx +131 -0
- package/template/src/content/legal/en/terms.mdx +93 -0
- package/template/src/content/legal/zh/cookie-policy.mdx +78 -0
- package/template/src/content/legal/zh/privacy.mdx +131 -0
- package/template/src/content/legal/zh/terms.mdx +92 -0
- package/template/src/core/modules/contract.ts +225 -0
- package/template/src/core/modules/index.ts +1 -0
- package/template/src/core/services/ai.ts +31 -0
- package/template/src/core/services/common.ts +112 -0
- package/template/src/core/services/index.ts +8 -0
- package/template/src/core/services/jobs.ts +24 -0
- package/template/src/core/services/mail.ts +35 -0
- package/template/src/core/services/manifest.ts +51 -0
- package/template/src/core/services/payment.ts +92 -0
- package/template/src/core/services/rate-limit.ts +47 -0
- package/template/src/core/services/storage.ts +42 -0
- package/template/src/db/index.ts +71 -0
- package/template/src/db/schema/auth.ts +67 -0
- package/template/src/db/schema/credits.ts +94 -0
- package/template/src/db/schema/index.ts +5 -0
- package/template/src/db/schema/mail.ts +14 -0
- package/template/src/db/schema/subscription.ts +21 -0
- package/template/src/db/schema/support.ts +56 -0
- package/template/src/db/schema.ts +2 -0
- package/template/src/features/admin/components/admin-sidebar.tsx +213 -0
- package/template/src/features/admin/components/index.ts +2 -0
- package/template/src/features/admin/index.ts +3 -0
- package/template/src/features/admin/manifest.ts +41 -0
- package/template/src/features/analytics/components/analytics.tsx +62 -0
- package/template/src/features/analytics/components/index.ts +2 -0
- package/template/src/features/analytics/index.ts +3 -0
- package/template/src/features/analytics/manifest.ts +13 -0
- package/template/src/features/auth/components/auth-brand-panel.tsx +82 -0
- package/template/src/features/auth/components/auth-error-alert.tsx +28 -0
- package/template/src/features/auth/components/auth-footer.tsx +52 -0
- package/template/src/features/auth/components/auth-logo.tsx +30 -0
- package/template/src/features/auth/components/forgot-password-form.tsx +146 -0
- package/template/src/features/auth/components/index.ts +9 -0
- package/template/src/features/auth/components/sign-in-form.tsx +241 -0
- package/template/src/features/auth/components/sign-up-form.tsx +307 -0
- package/template/src/features/auth/index.ts +3 -0
- package/template/src/features/auth/manifest.ts +30 -0
- package/template/src/features/blog/components/blog-post-item.tsx +72 -0
- package/template/src/features/blog/components/index.ts +1 -0
- package/template/src/features/blog/data/mock-posts.ts +62 -0
- package/template/src/features/blog/index.ts +3 -0
- package/template/src/features/blog/manifest.ts +22 -0
- package/template/src/features/credits/account.ts +76 -0
- package/template/src/features/credits/actions.ts +427 -0
- package/template/src/features/credits/components/credit-balance-badge.tsx +54 -0
- package/template/src/features/credits/components/credit-usage-section.tsx +160 -0
- package/template/src/features/credits/components/index.ts +7 -0
- package/template/src/features/credits/components/transaction-history.tsx +346 -0
- package/template/src/features/credits/config.ts +70 -0
- package/template/src/features/credits/consume.ts +140 -0
- package/template/src/features/credits/core.ts +23 -0
- package/template/src/features/credits/errors.ts +26 -0
- package/template/src/features/credits/expire.ts +112 -0
- package/template/src/features/credits/grant.ts +168 -0
- package/template/src/features/credits/index.ts +6 -0
- package/template/src/features/credits/manifest.ts +36 -0
- package/template/src/features/credits/query.ts +65 -0
- package/template/src/features/credits/types.ts +48 -0
- package/template/src/features/dashboard/components/index.ts +3 -0
- package/template/src/features/dashboard/components/main-wrapper.tsx +100 -0
- package/template/src/features/dashboard/components/sidebar.tsx +341 -0
- package/template/src/features/dashboard/context/index.ts +2 -0
- package/template/src/features/dashboard/context/sidebar-context.tsx +72 -0
- package/template/src/features/dashboard/index.ts +4 -0
- package/template/src/features/dashboard/manifest.ts +28 -0
- package/template/src/features/mail/actions.ts +175 -0
- package/template/src/features/mail/index.ts +5 -0
- package/template/src/features/mail/manifest.ts +13 -0
- package/template/src/features/mail/server.ts +8 -0
- package/template/src/features/mail/templates/index.ts +11 -0
- package/template/src/features/mail/templates/primary-action-email.tsx +224 -0
- package/template/src/features/mail/templates/welcome-email.tsx +121 -0
- package/template/src/features/mail/utils.ts +190 -0
- package/template/src/features/marketing/components/animated-price.tsx +51 -0
- package/template/src/features/marketing/components/cookie-consent.tsx +255 -0
- package/template/src/features/marketing/components/cta-section.tsx +50 -0
- package/template/src/features/marketing/components/faq-section.tsx +59 -0
- package/template/src/features/marketing/components/feature-grid.tsx +80 -0
- package/template/src/features/marketing/components/footer.tsx +128 -0
- package/template/src/features/marketing/components/header.tsx +255 -0
- package/template/src/features/marketing/components/hero-section.tsx +323 -0
- package/template/src/features/marketing/components/how-it-works.tsx +115 -0
- package/template/src/features/marketing/components/index.ts +14 -0
- package/template/src/features/marketing/components/nav-menu.tsx +236 -0
- package/template/src/features/marketing/components/pricing-section.tsx +446 -0
- package/template/src/features/marketing/components/testimonials.tsx +59 -0
- package/template/src/features/marketing/components/use-cases-section.tsx +78 -0
- package/template/src/features/marketing/index.ts +3 -0
- package/template/src/features/marketing/manifest.ts +35 -0
- package/template/src/features/payment/actions.ts +182 -0
- package/template/src/features/payment/index.ts +4 -0
- package/template/src/features/payment/manifest.ts +18 -0
- package/template/src/features/payment/server.ts +7 -0
- package/template/src/features/payment/types.ts +202 -0
- package/template/src/features/pseo/components/index.ts +6 -0
- package/template/src/features/pseo/components/pseo-cta.tsx +51 -0
- package/template/src/features/pseo/components/pseo-faq.tsx +40 -0
- package/template/src/features/pseo/components/pseo-feature-grid.tsx +74 -0
- package/template/src/features/pseo/components/pseo-hero.tsx +106 -0
- package/template/src/features/pseo/components/pseo-related.tsx +62 -0
- package/template/src/features/pseo/components/pseo-use-cases.tsx +50 -0
- package/template/src/features/pseo/data/pseo-pages.json +534 -0
- package/template/src/features/pseo/index.ts +4 -0
- package/template/src/features/pseo/lib/pseo-data.ts +140 -0
- package/template/src/features/pseo/manifest.ts +22 -0
- package/template/src/features/settings/actions/delete-account.ts +50 -0
- package/template/src/features/settings/actions/index.ts +3 -0
- package/template/src/features/settings/actions/update-profile.ts +49 -0
- package/template/src/features/settings/components/billing-section.tsx +283 -0
- package/template/src/features/settings/components/index.ts +3 -0
- package/template/src/features/settings/components/profile-form.tsx +154 -0
- package/template/src/features/settings/components/security-section.tsx +158 -0
- package/template/src/features/settings/components/settings-profile-view.tsx +506 -0
- package/template/src/features/settings/index.ts +5 -0
- package/template/src/features/settings/manifest.ts +28 -0
- package/template/src/features/settings/schemas/index.ts +2 -0
- package/template/src/features/settings/schemas/update-profile.ts +21 -0
- package/template/src/features/shared/components/cookie-settings-dialog.tsx +282 -0
- package/template/src/features/shared/components/index.ts +5 -0
- package/template/src/features/shared/components/language-switcher.tsx +82 -0
- package/template/src/features/shared/components/max-width-wrapper.tsx +49 -0
- package/template/src/features/shared/components/mode-toggle.tsx +119 -0
- package/template/src/features/shared/icons/google-icon.tsx +39 -0
- package/template/src/features/shared/icons/index.ts +7 -0
- package/template/src/features/shared/index.ts +5 -0
- package/template/src/features/shared/manifest.ts +13 -0
- package/template/src/features/shared/providers.tsx +59 -0
- package/template/src/features/storage/actions.ts +107 -0
- package/template/src/features/storage/index.ts +6 -0
- package/template/src/features/storage/manifest.ts +22 -0
- package/template/src/features/storage/types.ts +143 -0
- package/template/src/features/storage/utils.ts +85 -0
- package/template/src/features/storage/validation.ts +151 -0
- package/template/src/features/subscription/actions/get-user-plan.ts +26 -0
- package/template/src/features/subscription/actions/index.ts +5 -0
- package/template/src/features/subscription/components/current-plan-badge.tsx +18 -0
- package/template/src/features/subscription/components/index.ts +6 -0
- package/template/src/features/subscription/components/plan-badge.tsx +98 -0
- package/template/src/features/subscription/index.ts +25 -0
- package/template/src/features/subscription/manifest.ts +13 -0
- package/template/src/features/subscription/services/user-plan.ts +181 -0
- package/template/src/features/support/actions/admin-ticket.ts +172 -0
- package/template/src/features/support/actions/admin-users.ts +295 -0
- package/template/src/features/support/actions/index.ts +22 -0
- package/template/src/features/support/actions/ticket.ts +12 -0
- package/template/src/features/support/actions/user-ticket.ts +153 -0
- package/template/src/features/support/components/admin-ticket-reply-form.tsx +109 -0
- package/template/src/features/support/components/admin-ticket-status-select.tsx +119 -0
- package/template/src/features/support/components/index.ts +6 -0
- package/template/src/features/support/components/ticket-message-form.tsx +99 -0
- package/template/src/features/support/components/user-role-select.tsx +107 -0
- package/template/src/features/support/index.ts +5 -0
- package/template/src/features/support/manifest.ts +53 -0
- package/template/src/features/support/schemas/index.ts +15 -0
- package/template/src/features/support/schemas/ticket.ts +81 -0
- package/template/src/hooks/index.ts +2 -0
- package/template/src/i18n/index.ts +12 -0
- package/template/src/i18n/request.ts +24 -0
- package/template/src/i18n/routing.ts +23 -0
- package/template/src/instrumentation.ts +19 -0
- package/template/src/lib/ai/index.ts +16 -0
- package/template/src/lib/api-logger.ts +24 -0
- package/template/src/lib/auth/admin.ts +54 -0
- package/template/src/lib/auth/api.ts +17 -0
- package/template/src/lib/auth/client.ts +227 -0
- package/template/src/lib/auth/edge.ts +84 -0
- package/template/src/lib/auth/errors.ts +99 -0
- package/template/src/lib/auth/index.ts +159 -0
- package/template/src/lib/auth/server.ts +46 -0
- package/template/src/lib/auth/session-context.tsx +96 -0
- package/template/src/lib/cloudflare/bindings.ts +31 -0
- package/template/src/lib/cookie-consent.ts +33 -0
- package/template/src/lib/file-utils.ts +45 -0
- package/template/src/lib/fingerprint/index.ts +73 -0
- package/template/src/lib/health/checks.ts +6 -0
- package/template/src/lib/health/core.ts +86 -0
- package/template/src/lib/health/index.ts +11 -0
- package/template/src/lib/health/types.ts +13 -0
- package/template/src/lib/index.ts +2 -0
- package/template/src/lib/logger/index.ts +258 -0
- package/template/src/lib/monitoring/index.ts +384 -0
- package/template/src/lib/rate-limit/anonymous.ts +85 -0
- package/template/src/lib/rate-limit/index.ts +111 -0
- package/template/src/lib/safe-action.ts +127 -0
- package/template/src/lib/seo/json-ld.ts +188 -0
- package/template/src/lib/source.ts +122 -0
- package/template/src/lib/utils.ts +6 -0
- package/template/src/middleware.ts +162 -0
- package/template/src/modules/index.ts +10 -0
- package/template/src/modules/presets.ts +8 -0
- package/template/src/modules/registry.ts +34 -0
- package/template/src/modules/selection.ts +45 -0
- package/template/src/services/ai.ts +49 -0
- package/template/src/services/index.ts +6 -0
- package/template/src/services/jobs.ts +3 -0
- package/template/src/services/mail.ts +7 -0
- package/template/src/services/payment.ts +3 -0
- package/template/src/services/rate-limit.ts +12 -0
- package/template/src/services/storage.ts +3 -0
- package/template/src/types/fumadocs-source.d.ts +14 -0
- package/template/src/types/index.ts +2 -0
- package/template/tsconfig.json +53 -0
- package/template/vercel.json +11 -0
- package/template/vitest.config.ts +51 -0
- package/template/wrangler.jsonc +30 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineModule } from "@/core/modules";
|
|
2
|
+
|
|
3
|
+
export const analyticsModule = defineModule({
|
|
4
|
+
id: "analytics",
|
|
5
|
+
name: "Analytics",
|
|
6
|
+
description: "页面分析与可选监控脚本",
|
|
7
|
+
kind: "optional",
|
|
8
|
+
dependencies: [],
|
|
9
|
+
routes: [],
|
|
10
|
+
navigation: [],
|
|
11
|
+
translations: [],
|
|
12
|
+
schema: [],
|
|
13
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Check } from "lucide-react";
|
|
4
|
+
import { useTranslations } from "next-intl";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Auth 品牌分屏的左侧面板
|
|
8
|
+
*
|
|
9
|
+
* 根节点挂 `dark` class,让所有 token 类强制解析成暗色值——这样无论用户当前
|
|
10
|
+
* 是亮色还是暗色主题,品牌面板始终是"深色 + Spruce 主色"的高级对比效果,
|
|
11
|
+
* 与右侧跟随主题的表单形成分屏。不用写死任意颜色,全走 token。
|
|
12
|
+
*/
|
|
13
|
+
const POINTS = ["ship", "own", "stack"] as const;
|
|
14
|
+
|
|
15
|
+
export function AuthBrandPanel() {
|
|
16
|
+
const t = useTranslations("Auth.brand");
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<aside className="dark relative hidden flex-col justify-between overflow-hidden bg-background p-12 lg:flex">
|
|
20
|
+
{/* 氛围层(dark 作用域下,光晕/网格变量解析为暗色版) */}
|
|
21
|
+
<div aria-hidden className="aura pointer-events-none absolute inset-0" />
|
|
22
|
+
<div
|
|
23
|
+
aria-hidden
|
|
24
|
+
className="bg-grid pointer-events-none absolute inset-0 opacity-60 [mask-image:radial-gradient(72%_72%_at_28%_18%,black,transparent)]"
|
|
25
|
+
/>
|
|
26
|
+
|
|
27
|
+
{/* 顶部 logo */}
|
|
28
|
+
<div className="relative flex items-center gap-2">
|
|
29
|
+
{/* biome-ignore lint/a11y/noSvgWithoutTitle: decorative logo */}
|
|
30
|
+
<svg
|
|
31
|
+
className="h-6 w-6 text-primary"
|
|
32
|
+
viewBox="0 0 24 24"
|
|
33
|
+
fill="none"
|
|
34
|
+
stroke="currentColor"
|
|
35
|
+
strokeWidth={2.4}
|
|
36
|
+
strokeLinecap="round"
|
|
37
|
+
strokeLinejoin="round"
|
|
38
|
+
>
|
|
39
|
+
<path d="M3 17 L9 7 L13 14 L21 4" />
|
|
40
|
+
<circle cx="9" cy="7" r="1.4" fill="currentColor" stroke="none" />
|
|
41
|
+
<circle cx="21" cy="4" r="1.4" fill="currentColor" stroke="none" />
|
|
42
|
+
</svg>
|
|
43
|
+
<span className="text-lg font-bold tracking-tight text-foreground">
|
|
44
|
+
NextDev<span className="text-muted-foreground">Tpl</span>
|
|
45
|
+
</span>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
{/* 中部:标题 + 卖点 */}
|
|
49
|
+
<div className="relative max-w-md space-y-8">
|
|
50
|
+
<div className="space-y-4">
|
|
51
|
+
<h2 className="text-balance text-[clamp(1.75rem,2.4vw,2.5rem)] font-extrabold leading-[1.08] tracking-tight text-foreground">
|
|
52
|
+
{t("headline")}
|
|
53
|
+
</h2>
|
|
54
|
+
<p className="leading-relaxed text-muted-foreground">{t("sub")}</p>
|
|
55
|
+
</div>
|
|
56
|
+
<ul className="space-y-3">
|
|
57
|
+
{POINTS.map((k) => (
|
|
58
|
+
<li
|
|
59
|
+
key={k}
|
|
60
|
+
className="flex items-center gap-3 text-sm text-foreground/90"
|
|
61
|
+
>
|
|
62
|
+
<span className="flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground">
|
|
63
|
+
<Check className="h-3 w-3" strokeWidth={3} />
|
|
64
|
+
</span>
|
|
65
|
+
{t(`points.${k}`)}
|
|
66
|
+
</li>
|
|
67
|
+
))}
|
|
68
|
+
</ul>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
{/* 底部:仓库指标 */}
|
|
72
|
+
<div className="relative flex items-center gap-4 border-t border-border pt-6">
|
|
73
|
+
<div className="mono-data text-3xl font-bold tracking-tight text-foreground">
|
|
74
|
+
{t("stat.k")}
|
|
75
|
+
</div>
|
|
76
|
+
<div className="max-w-[16rem] text-xs text-muted-foreground">
|
|
77
|
+
{t("stat.v")}
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</aside>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 认证错误提示组件
|
|
3
|
+
*
|
|
4
|
+
* 用于显示登录、注册等认证流程中的错误信息
|
|
5
|
+
* 统一的错误提示样式
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
interface AuthErrorAlertProps {
|
|
9
|
+
/** 错误信息,为 null 时不显示 */
|
|
10
|
+
message: string | null;
|
|
11
|
+
/** 自定义类名 */
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function AuthErrorAlert({ message, className }: AuthErrorAlertProps) {
|
|
16
|
+
// 没有错误信息时不渲染
|
|
17
|
+
if (!message) return null;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
className={
|
|
22
|
+
className || "rounded-md bg-destructive/10 p-3 text-sm text-destructive"
|
|
23
|
+
}
|
|
24
|
+
>
|
|
25
|
+
{message}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import Link from "next/link";
|
|
4
|
+
import { useTranslations } from "next-intl";
|
|
5
|
+
|
|
6
|
+
import { siteConfig } from "@/config";
|
|
7
|
+
import { CookieSettingsDialog } from "@/features/shared";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Auth 页面底部组件
|
|
11
|
+
*
|
|
12
|
+
* 包含版权信息和法律链接
|
|
13
|
+
* Cookie Settings 链接会打开设置对话框
|
|
14
|
+
*/
|
|
15
|
+
export function AuthFooter() {
|
|
16
|
+
const t = useTranslations("Auth.footer");
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<footer className="border-t bg-background py-6">
|
|
20
|
+
<div className="container mx-auto flex flex-col items-center justify-between gap-4 px-4 sm:flex-row">
|
|
21
|
+
<p className="text-sm text-muted-foreground">
|
|
22
|
+
{t("copyright", {
|
|
23
|
+
year: new Date().getFullYear(),
|
|
24
|
+
name: siteConfig.name,
|
|
25
|
+
})}
|
|
26
|
+
</p>
|
|
27
|
+
<nav className="flex gap-6">
|
|
28
|
+
<Link
|
|
29
|
+
href="/legal/privacy"
|
|
30
|
+
className="text-sm text-muted-foreground transition-colors hover:text-foreground"
|
|
31
|
+
>
|
|
32
|
+
{t("privacy")}
|
|
33
|
+
</Link>
|
|
34
|
+
<Link
|
|
35
|
+
href="/legal/terms"
|
|
36
|
+
className="text-sm text-muted-foreground transition-colors hover:text-foreground"
|
|
37
|
+
>
|
|
38
|
+
{t("terms")}
|
|
39
|
+
</Link>
|
|
40
|
+
<CookieSettingsDialog>
|
|
41
|
+
<button
|
|
42
|
+
type="button"
|
|
43
|
+
className="text-sm text-muted-foreground transition-colors hover:text-foreground"
|
|
44
|
+
>
|
|
45
|
+
{t("cookies")}
|
|
46
|
+
</button>
|
|
47
|
+
</CookieSettingsDialog>
|
|
48
|
+
</nav>
|
|
49
|
+
</div>
|
|
50
|
+
</footer>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 认证页面 Logo 组件
|
|
3
|
+
*
|
|
4
|
+
* 用于登录、注册等认证页面的品牌标识展示
|
|
5
|
+
* 图标 + 文字组合
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export function AuthLogo() {
|
|
9
|
+
return (
|
|
10
|
+
<div className="flex items-center gap-2">
|
|
11
|
+
<svg
|
|
12
|
+
className="h-7 w-7 text-primary"
|
|
13
|
+
viewBox="0 0 24 24"
|
|
14
|
+
fill="none"
|
|
15
|
+
stroke="currentColor"
|
|
16
|
+
strokeWidth={2.4}
|
|
17
|
+
strokeLinecap="round"
|
|
18
|
+
strokeLinejoin="round"
|
|
19
|
+
>
|
|
20
|
+
<title>Logo</title>
|
|
21
|
+
<path d="M3 17 L9 7 L13 14 L21 4" />
|
|
22
|
+
<circle cx="9" cy="7" r="1.4" fill="currentColor" stroke="none" />
|
|
23
|
+
<circle cx="21" cy="4" r="1.4" fill="currentColor" stroke="none" />
|
|
24
|
+
</svg>
|
|
25
|
+
<span className="text-xl font-bold tracking-tight">
|
|
26
|
+
NextDev<span className="text-muted-foreground">Tpl</span>
|
|
27
|
+
</span>
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { KeyRound, Loader2, Mail } from "lucide-react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
|
|
7
|
+
import { Button } from "@/components/ui/button";
|
|
8
|
+
import { Input } from "@/components/ui/input";
|
|
9
|
+
import { Label } from "@/components/ui/label";
|
|
10
|
+
import { forgetPassword } from "@/lib/auth/client";
|
|
11
|
+
|
|
12
|
+
import { AuthErrorAlert } from "./auth-error-alert";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 忘记密码表单组件
|
|
16
|
+
*
|
|
17
|
+
* 功能:
|
|
18
|
+
* - 输入邮箱地址
|
|
19
|
+
* - 发送密码重置链接
|
|
20
|
+
* - 显示成功/错误状态
|
|
21
|
+
*/
|
|
22
|
+
export function ForgotPasswordForm() {
|
|
23
|
+
// 表单状态
|
|
24
|
+
const [email, setEmail] = useState("");
|
|
25
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
26
|
+
const [error, setError] = useState<string | null>(null);
|
|
27
|
+
const [isSuccess, setIsSuccess] = useState(false);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 处理表单提交
|
|
31
|
+
*/
|
|
32
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
|
|
35
|
+
if (!email) {
|
|
36
|
+
setError("Please enter your email address");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
setIsLoading(true);
|
|
42
|
+
setError(null);
|
|
43
|
+
|
|
44
|
+
await forgetPassword(email, "/reset-password");
|
|
45
|
+
|
|
46
|
+
setIsSuccess(true);
|
|
47
|
+
} catch {
|
|
48
|
+
setError("Failed to send reset link. Please try again.");
|
|
49
|
+
} finally {
|
|
50
|
+
setIsLoading(false);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// 成功状态显示
|
|
55
|
+
if (isSuccess) {
|
|
56
|
+
return (
|
|
57
|
+
<div className="w-full max-w-md space-y-6">
|
|
58
|
+
{/* 图标 */}
|
|
59
|
+
<div className="flex flex-col items-center space-y-4 text-center">
|
|
60
|
+
<div className="flex h-12 w-12 items-center justify-center rounded-lg bg-success/15 text-success">
|
|
61
|
+
<Mail className="h-6 w-6" />
|
|
62
|
+
</div>
|
|
63
|
+
<h1 className="text-2xl font-semibold tracking-tight">
|
|
64
|
+
Check your email
|
|
65
|
+
</h1>
|
|
66
|
+
<p className="text-sm text-muted-foreground">
|
|
67
|
+
We've sent a password reset link to{" "}
|
|
68
|
+
<span className="font-medium text-foreground">{email}</span>
|
|
69
|
+
</p>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
{/* 返回登录 */}
|
|
73
|
+
<div className="text-center">
|
|
74
|
+
<Link
|
|
75
|
+
href="/sign-in"
|
|
76
|
+
className="text-sm text-muted-foreground hover:text-foreground"
|
|
77
|
+
>
|
|
78
|
+
<span className="underline">Back to Login</span>
|
|
79
|
+
</Link>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div className="w-full max-w-md space-y-6">
|
|
87
|
+
{/* Logo 和标题 */}
|
|
88
|
+
<div className="flex flex-col items-center space-y-4 text-center">
|
|
89
|
+
{/* Logo 图标 */}
|
|
90
|
+
<div className="flex h-12 w-12 items-center justify-center rounded-lg bg-primary text-primary-foreground">
|
|
91
|
+
<KeyRound className="h-6 w-6" />
|
|
92
|
+
</div>
|
|
93
|
+
<h1 className="text-2xl font-semibold tracking-tight">
|
|
94
|
+
Forgot your password?
|
|
95
|
+
</h1>
|
|
96
|
+
<p className="text-sm text-muted-foreground">
|
|
97
|
+
Enter your email below and we'll send you a link to reset it.
|
|
98
|
+
</p>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
{/* 错误提示 */}
|
|
102
|
+
<AuthErrorAlert message={error} />
|
|
103
|
+
|
|
104
|
+
{/* 表单 */}
|
|
105
|
+
<form onSubmit={handleSubmit} className="space-y-4">
|
|
106
|
+
{/* 邮箱输入 */}
|
|
107
|
+
<div className="space-y-2">
|
|
108
|
+
<Label htmlFor="email">Email address</Label>
|
|
109
|
+
<Input
|
|
110
|
+
id="email"
|
|
111
|
+
type="email"
|
|
112
|
+
placeholder="jane@example.com"
|
|
113
|
+
value={email}
|
|
114
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
115
|
+
disabled={isLoading}
|
|
116
|
+
autoComplete="email"
|
|
117
|
+
autoFocus
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
{/* 提交按钮 */}
|
|
122
|
+
<Button type="submit" className="w-full" disabled={isLoading}>
|
|
123
|
+
{isLoading ? (
|
|
124
|
+
<>
|
|
125
|
+
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
|
126
|
+
Sending...
|
|
127
|
+
</>
|
|
128
|
+
) : (
|
|
129
|
+
"Send reset password link"
|
|
130
|
+
)}
|
|
131
|
+
</Button>
|
|
132
|
+
</form>
|
|
133
|
+
|
|
134
|
+
{/* 返回登录链接 */}
|
|
135
|
+
<p className="text-center text-sm text-muted-foreground">
|
|
136
|
+
Remember your password?{" "}
|
|
137
|
+
<Link
|
|
138
|
+
href="/sign-in"
|
|
139
|
+
className="font-medium text-foreground hover:underline"
|
|
140
|
+
>
|
|
141
|
+
Back to Login
|
|
142
|
+
</Link>
|
|
143
|
+
</p>
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Auth 功能模块组件导出
|
|
2
|
+
|
|
3
|
+
export { AuthBrandPanel } from "./auth-brand-panel";
|
|
4
|
+
export { AuthErrorAlert } from "./auth-error-alert";
|
|
5
|
+
export { AuthFooter } from "./auth-footer";
|
|
6
|
+
export { AuthLogo } from "./auth-logo";
|
|
7
|
+
export { ForgotPasswordForm } from "./forgot-password-form";
|
|
8
|
+
export { SignInForm } from "./sign-in-form";
|
|
9
|
+
export { SignUpForm } from "./sign-up-form";
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Eye, EyeOff } from "lucide-react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { useTranslations } from "next-intl";
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { toast } from "sonner";
|
|
8
|
+
|
|
9
|
+
import { Button } from "@/components/ui/button";
|
|
10
|
+
import { Input } from "@/components/ui/input";
|
|
11
|
+
import { Label } from "@/components/ui/label";
|
|
12
|
+
import { Separator } from "@/components/ui/separator";
|
|
13
|
+
import { GoogleIcon } from "@/features/shared";
|
|
14
|
+
import {
|
|
15
|
+
resendVerificationEmail,
|
|
16
|
+
signInWithEmail,
|
|
17
|
+
signInWithGoogle,
|
|
18
|
+
} from "@/lib/auth/client";
|
|
19
|
+
|
|
20
|
+
import { AuthErrorAlert } from "./auth-error-alert";
|
|
21
|
+
import { AuthLogo } from "./auth-logo";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 登录表单组件
|
|
25
|
+
*
|
|
26
|
+
* 功能:
|
|
27
|
+
* - Google OAuth 登录
|
|
28
|
+
* - 邮箱密码登录
|
|
29
|
+
*/
|
|
30
|
+
export function SignInForm() {
|
|
31
|
+
const t = useTranslations("Auth.signIn");
|
|
32
|
+
const tCommon = useTranslations("Auth.common");
|
|
33
|
+
|
|
34
|
+
// 表单状态
|
|
35
|
+
const [email, setEmail] = useState("");
|
|
36
|
+
const [password, setPassword] = useState("");
|
|
37
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
38
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
39
|
+
const [error, setError] = useState<string | null>(null);
|
|
40
|
+
const [showResend, setShowResend] = useState(false);
|
|
41
|
+
const [resendCooldown, setResendCooldown] = useState(0);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 重新发送验证邮件
|
|
45
|
+
*/
|
|
46
|
+
const handleResendEmail = async () => {
|
|
47
|
+
if (resendCooldown > 0 || !email) return;
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
await resendVerificationEmail(email);
|
|
51
|
+
setResendCooldown(60);
|
|
52
|
+
const timer = setInterval(() => {
|
|
53
|
+
setResendCooldown((prev) => {
|
|
54
|
+
if (prev <= 1) {
|
|
55
|
+
clearInterval(timer);
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
return prev - 1;
|
|
59
|
+
});
|
|
60
|
+
}, 1000);
|
|
61
|
+
} catch {
|
|
62
|
+
// 静默失败
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 处理 Google 登录
|
|
68
|
+
*/
|
|
69
|
+
const handleGoogleSignIn = async () => {
|
|
70
|
+
try {
|
|
71
|
+
setIsLoading(true);
|
|
72
|
+
setError(null);
|
|
73
|
+
await signInWithGoogle();
|
|
74
|
+
} catch {
|
|
75
|
+
setError(t("errors.google"));
|
|
76
|
+
} finally {
|
|
77
|
+
setIsLoading(false);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 处理邮箱密码登录
|
|
83
|
+
*/
|
|
84
|
+
const handleEmailSignIn = async (e: React.FormEvent) => {
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
|
|
87
|
+
if (!email || !password) {
|
|
88
|
+
setError(t("errors.missingFields"));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
setIsLoading(true);
|
|
94
|
+
setError(null);
|
|
95
|
+
const result = await signInWithEmail(email, password);
|
|
96
|
+
|
|
97
|
+
if (result.error) {
|
|
98
|
+
if (result.error.code === "EMAIL_NOT_VERIFIED") {
|
|
99
|
+
setError(t("errors.emailNotVerified"));
|
|
100
|
+
setShowResend(true);
|
|
101
|
+
} else {
|
|
102
|
+
setError(t("errors.invalidCredentials"));
|
|
103
|
+
setShowResend(false);
|
|
104
|
+
}
|
|
105
|
+
setIsLoading(false);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// 登录成功,提示并跳转
|
|
110
|
+
toast.success(t("success"));
|
|
111
|
+
window.location.href = "/dashboard";
|
|
112
|
+
} catch {
|
|
113
|
+
setError(t("errors.invalidCredentials"));
|
|
114
|
+
setIsLoading(false);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<div className="w-full max-w-md space-y-6">
|
|
120
|
+
{/* Logo 和标题 */}
|
|
121
|
+
<div className="flex flex-col items-center space-y-2 text-center">
|
|
122
|
+
<AuthLogo />
|
|
123
|
+
<h1 className="text-2xl font-semibold tracking-tight">{t("title")}</h1>
|
|
124
|
+
<p className="text-sm text-muted-foreground">{t("subtitle")}</p>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
{/* 错误提示 */}
|
|
128
|
+
<AuthErrorAlert message={error} />
|
|
129
|
+
|
|
130
|
+
{/* 重发验证邮件 */}
|
|
131
|
+
{showResend && (
|
|
132
|
+
<Button
|
|
133
|
+
variant="outline"
|
|
134
|
+
className="w-full"
|
|
135
|
+
onClick={handleResendEmail}
|
|
136
|
+
disabled={resendCooldown > 0}
|
|
137
|
+
>
|
|
138
|
+
{resendCooldown > 0
|
|
139
|
+
? t("resendCooldown", { seconds: resendCooldown })
|
|
140
|
+
: t("resendVerification")}
|
|
141
|
+
</Button>
|
|
142
|
+
)}
|
|
143
|
+
|
|
144
|
+
{/* OAuth 登录按钮 */}
|
|
145
|
+
<div className="space-y-3">
|
|
146
|
+
<Button
|
|
147
|
+
variant="outline"
|
|
148
|
+
className="w-full"
|
|
149
|
+
onClick={handleGoogleSignIn}
|
|
150
|
+
disabled={isLoading}
|
|
151
|
+
>
|
|
152
|
+
<GoogleIcon className="mr-2 h-4 w-4" />
|
|
153
|
+
{tCommon("google")}
|
|
154
|
+
</Button>
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
{/* 分隔线 */}
|
|
158
|
+
<div className="relative">
|
|
159
|
+
<div className="absolute inset-0 flex items-center">
|
|
160
|
+
<Separator className="w-full" />
|
|
161
|
+
</div>
|
|
162
|
+
<div className="relative flex justify-center text-xs uppercase">
|
|
163
|
+
<span className="bg-background px-2 text-muted-foreground">
|
|
164
|
+
{tCommon("or")}
|
|
165
|
+
</span>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
{/* 邮箱密码表单 */}
|
|
170
|
+
<form onSubmit={handleEmailSignIn} className="space-y-4">
|
|
171
|
+
{/* 邮箱输入 */}
|
|
172
|
+
<div className="space-y-2">
|
|
173
|
+
<Label htmlFor="email">{t("emailLabel")}</Label>
|
|
174
|
+
<Input
|
|
175
|
+
id="email"
|
|
176
|
+
type="email"
|
|
177
|
+
placeholder={t("emailPlaceholder")}
|
|
178
|
+
value={email}
|
|
179
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
180
|
+
disabled={isLoading}
|
|
181
|
+
autoComplete="email"
|
|
182
|
+
/>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
{/* 密码输入 */}
|
|
186
|
+
<div className="space-y-2">
|
|
187
|
+
<Label htmlFor="password">{t("passwordLabel")}</Label>
|
|
188
|
+
<div className="relative">
|
|
189
|
+
<Input
|
|
190
|
+
id="password"
|
|
191
|
+
type={showPassword ? "text" : "password"}
|
|
192
|
+
value={password}
|
|
193
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
194
|
+
disabled={isLoading}
|
|
195
|
+
autoComplete="current-password"
|
|
196
|
+
className="pr-10"
|
|
197
|
+
/>
|
|
198
|
+
<button
|
|
199
|
+
type="button"
|
|
200
|
+
onClick={() => setShowPassword(!showPassword)}
|
|
201
|
+
className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors"
|
|
202
|
+
tabIndex={-1}
|
|
203
|
+
>
|
|
204
|
+
{showPassword ? (
|
|
205
|
+
<EyeOff className="h-4 w-4" />
|
|
206
|
+
) : (
|
|
207
|
+
<Eye className="h-4 w-4" />
|
|
208
|
+
)}
|
|
209
|
+
</button>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
{/* 忘记密码链接 */}
|
|
214
|
+
<div className="text-left">
|
|
215
|
+
<Link
|
|
216
|
+
href="/forgot-password"
|
|
217
|
+
className="text-sm text-muted-foreground underline hover:text-foreground transition-colors"
|
|
218
|
+
>
|
|
219
|
+
{t("forgotPassword")}
|
|
220
|
+
</Link>
|
|
221
|
+
</div>
|
|
222
|
+
|
|
223
|
+
{/* 提交按钮 */}
|
|
224
|
+
<Button type="submit" className="w-full" disabled={isLoading}>
|
|
225
|
+
{isLoading ? t("loading") : t("submit")}
|
|
226
|
+
</Button>
|
|
227
|
+
</form>
|
|
228
|
+
|
|
229
|
+
{/* 注册链接 */}
|
|
230
|
+
<p className="text-center text-sm text-muted-foreground">
|
|
231
|
+
{t("noAccount")}{" "}
|
|
232
|
+
<Link
|
|
233
|
+
href="/sign-up"
|
|
234
|
+
className="font-medium text-foreground hover:underline"
|
|
235
|
+
>
|
|
236
|
+
{t("signUpLink")}
|
|
237
|
+
</Link>
|
|
238
|
+
</p>
|
|
239
|
+
</div>
|
|
240
|
+
);
|
|
241
|
+
}
|