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,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 更新用户资料的 Zod Schema
|
|
5
|
+
*
|
|
6
|
+
* @field name - 用户显示名称,最少 2 个字符,最多 50 个字符
|
|
7
|
+
* @field image - 用户头像 (存储键名),可选
|
|
8
|
+
*/
|
|
9
|
+
export const updateProfileSchema = z.object({
|
|
10
|
+
name: z
|
|
11
|
+
.string()
|
|
12
|
+
.min(2, "名称至少需要 2 个字符")
|
|
13
|
+
.max(50, "名称最多 50 个字符")
|
|
14
|
+
.optional(),
|
|
15
|
+
image: z.string().max(255, "头像路径过长").optional(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 表单数据类型,从 Zod Schema 推断
|
|
20
|
+
*/
|
|
21
|
+
export type UpdateProfileInput = z.infer<typeof updateProfileSchema>;
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { ChevronDown } from "lucide-react";
|
|
4
|
+
import { useTranslations } from "next-intl";
|
|
5
|
+
import { useCallback, useEffect, useState } from "react";
|
|
6
|
+
|
|
7
|
+
import { Button } from "@/components/ui/button";
|
|
8
|
+
import {
|
|
9
|
+
Collapsible,
|
|
10
|
+
CollapsibleContent,
|
|
11
|
+
CollapsibleTrigger,
|
|
12
|
+
} from "@/components/ui/collapsible";
|
|
13
|
+
import {
|
|
14
|
+
Dialog,
|
|
15
|
+
DialogContent,
|
|
16
|
+
DialogHeader,
|
|
17
|
+
DialogTitle,
|
|
18
|
+
DialogTrigger,
|
|
19
|
+
} from "@/components/ui/dialog";
|
|
20
|
+
import { Switch } from "@/components/ui/switch";
|
|
21
|
+
import {
|
|
22
|
+
COOKIE_CONSENT_CHANGE_EVENT,
|
|
23
|
+
COOKIE_CONSENT_KEY,
|
|
24
|
+
COOKIE_PREFERENCES_KEY,
|
|
25
|
+
type CookieConsentType,
|
|
26
|
+
type CookiePreferences,
|
|
27
|
+
} from "@/lib/cookie-consent";
|
|
28
|
+
import { cn } from "@/lib/utils";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 默认 Cookie 偏好
|
|
32
|
+
*/
|
|
33
|
+
const DEFAULT_PREFERENCES: CookiePreferences = {
|
|
34
|
+
analytics: true,
|
|
35
|
+
marketing: true,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Cookie Settings Dialog 组件属性
|
|
40
|
+
*/
|
|
41
|
+
interface CookieSettingsDialogProps {
|
|
42
|
+
/** 触发按钮的子元素 */
|
|
43
|
+
children: React.ReactNode;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Cookie Settings Dialog 组件
|
|
48
|
+
*
|
|
49
|
+
* 功能:
|
|
50
|
+
* - 显示 Cookie 偏好设置对话框
|
|
51
|
+
* - 可展开的 Cookie 类别
|
|
52
|
+
* - 支持 Accept all / Reject all / Accept current selection
|
|
53
|
+
*/
|
|
54
|
+
export function CookieSettingsDialog({ children }: CookieSettingsDialogProps) {
|
|
55
|
+
const t = useTranslations("Cookie");
|
|
56
|
+
const [open, setOpen] = useState(false);
|
|
57
|
+
const [preferences, setPreferences] =
|
|
58
|
+
useState<CookiePreferences>(DEFAULT_PREFERENCES);
|
|
59
|
+
const [expandedItems, setExpandedItems] = useState<string[]>(["necessary"]);
|
|
60
|
+
|
|
61
|
+
const cookieCategories = [
|
|
62
|
+
{
|
|
63
|
+
id: "necessary",
|
|
64
|
+
title: t("essential.title"),
|
|
65
|
+
description: t("essential.description"),
|
|
66
|
+
required: true,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "analytics",
|
|
70
|
+
title: t("analytics.title"),
|
|
71
|
+
description: t("analytics.description"),
|
|
72
|
+
required: false,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: "marketing",
|
|
76
|
+
title: t("marketing.title"),
|
|
77
|
+
description: t("marketing.description"),
|
|
78
|
+
required: false,
|
|
79
|
+
},
|
|
80
|
+
] as const;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 加载已保存的偏好设置
|
|
84
|
+
*/
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (open) {
|
|
87
|
+
const savedPreferences = localStorage.getItem(COOKIE_PREFERENCES_KEY);
|
|
88
|
+
if (savedPreferences) {
|
|
89
|
+
try {
|
|
90
|
+
setPreferences(JSON.parse(savedPreferences));
|
|
91
|
+
} catch {
|
|
92
|
+
// 忽略解析错误
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}, [open]);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 切换展开状态
|
|
100
|
+
*/
|
|
101
|
+
const toggleExpanded = (id: string) => {
|
|
102
|
+
setExpandedItems((prev) =>
|
|
103
|
+
prev.includes(id) ? prev.filter((item) => item !== id) : [...prev, id]
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 保存 Cookie 同意设置
|
|
109
|
+
*/
|
|
110
|
+
const saveConsent = useCallback(
|
|
111
|
+
(consent: CookieConsentType, prefs: CookiePreferences) => {
|
|
112
|
+
localStorage.setItem(COOKIE_CONSENT_KEY, consent || "");
|
|
113
|
+
localStorage.setItem(COOKIE_PREFERENCES_KEY, JSON.stringify(prefs));
|
|
114
|
+
// 触发自定义事件通知 Analytics 组件
|
|
115
|
+
window.dispatchEvent(new CustomEvent(COOKIE_CONSENT_CHANGE_EVENT));
|
|
116
|
+
setOpen(false);
|
|
117
|
+
},
|
|
118
|
+
[]
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 处理接受全部 Cookie
|
|
123
|
+
*/
|
|
124
|
+
const handleAcceptAll = useCallback(() => {
|
|
125
|
+
const allPreferences: CookiePreferences = {
|
|
126
|
+
analytics: true,
|
|
127
|
+
marketing: true,
|
|
128
|
+
};
|
|
129
|
+
setPreferences(allPreferences);
|
|
130
|
+
saveConsent("all", allPreferences);
|
|
131
|
+
}, [saveConsent]);
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* 处理拒绝全部(仅必要)
|
|
135
|
+
*/
|
|
136
|
+
const handleRejectAll = useCallback(() => {
|
|
137
|
+
const essentialPreferences: CookiePreferences = {
|
|
138
|
+
analytics: false,
|
|
139
|
+
marketing: false,
|
|
140
|
+
};
|
|
141
|
+
setPreferences(essentialPreferences);
|
|
142
|
+
saveConsent("essential", essentialPreferences);
|
|
143
|
+
}, [saveConsent]);
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 处理保存当前选择
|
|
147
|
+
*/
|
|
148
|
+
const handleSavePreferences = useCallback(() => {
|
|
149
|
+
const consentType: CookieConsentType =
|
|
150
|
+
preferences.analytics || preferences.marketing ? "all" : "essential";
|
|
151
|
+
saveConsent(consentType, preferences);
|
|
152
|
+
}, [preferences, saveConsent]);
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 更新偏好设置
|
|
156
|
+
*/
|
|
157
|
+
const updatePreference = (key: keyof CookiePreferences, value: boolean) => {
|
|
158
|
+
setPreferences((prev) => ({ ...prev, [key]: value }));
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 获取某个类别的开关状态
|
|
163
|
+
*/
|
|
164
|
+
const getCategoryValue = (id: string): boolean => {
|
|
165
|
+
if (id === "necessary") return true;
|
|
166
|
+
if (id === "analytics") return preferences.analytics;
|
|
167
|
+
if (id === "marketing") return preferences.marketing;
|
|
168
|
+
return false;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 处理某个类别的开关变化
|
|
173
|
+
*/
|
|
174
|
+
const handleCategoryChange = (id: string, value: boolean) => {
|
|
175
|
+
if (id === "analytics") updatePreference("analytics", value);
|
|
176
|
+
if (id === "marketing") updatePreference("marketing", value);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
181
|
+
<DialogTrigger asChild>{children}</DialogTrigger>
|
|
182
|
+
<DialogContent
|
|
183
|
+
className="max-h-[90vh] max-w-2xl overflow-hidden p-0 [&>button]:hidden"
|
|
184
|
+
overlayClassName="bg-black/30"
|
|
185
|
+
>
|
|
186
|
+
{/* Header */}
|
|
187
|
+
<DialogHeader className="border-b px-6 py-4">
|
|
188
|
+
<div className="flex items-center justify-between">
|
|
189
|
+
<DialogTitle className="text-lg font-semibold">
|
|
190
|
+
{t("dialog.title")}
|
|
191
|
+
</DialogTitle>
|
|
192
|
+
</div>
|
|
193
|
+
</DialogHeader>
|
|
194
|
+
|
|
195
|
+
{/* Content */}
|
|
196
|
+
<div className="max-h-[60vh] overflow-y-auto px-6 py-4">
|
|
197
|
+
{/* Description */}
|
|
198
|
+
<div className="mb-6">
|
|
199
|
+
<h3 className="mb-2 font-semibold">{t("dialog.heading")}</h3>
|
|
200
|
+
<p className="text-sm text-muted-foreground">
|
|
201
|
+
{t("dialog.description")}
|
|
202
|
+
</p>
|
|
203
|
+
</div>
|
|
204
|
+
|
|
205
|
+
{/* Cookie Categories */}
|
|
206
|
+
<div className="space-y-3">
|
|
207
|
+
{cookieCategories.map((category) => {
|
|
208
|
+
const isExpanded = expandedItems.includes(category.id);
|
|
209
|
+
const isChecked = getCategoryValue(category.id);
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<Collapsible
|
|
213
|
+
key={category.id}
|
|
214
|
+
open={isExpanded}
|
|
215
|
+
onOpenChange={() => toggleExpanded(category.id)}
|
|
216
|
+
>
|
|
217
|
+
<div className="rounded-lg border">
|
|
218
|
+
{/* Category Header */}
|
|
219
|
+
<div className="flex items-center justify-between p-4">
|
|
220
|
+
<CollapsibleTrigger asChild>
|
|
221
|
+
<button
|
|
222
|
+
type="button"
|
|
223
|
+
className="flex items-center gap-2 text-left"
|
|
224
|
+
>
|
|
225
|
+
<ChevronDown
|
|
226
|
+
className={cn(
|
|
227
|
+
"h-4 w-4 text-muted-foreground transition-transform",
|
|
228
|
+
isExpanded && "rotate-180"
|
|
229
|
+
)}
|
|
230
|
+
/>
|
|
231
|
+
<span className="font-medium">{category.title}</span>
|
|
232
|
+
</button>
|
|
233
|
+
</CollapsibleTrigger>
|
|
234
|
+
<Switch
|
|
235
|
+
checked={isChecked}
|
|
236
|
+
onCheckedChange={(value) =>
|
|
237
|
+
handleCategoryChange(category.id, value)
|
|
238
|
+
}
|
|
239
|
+
disabled={category.required}
|
|
240
|
+
/>
|
|
241
|
+
</div>
|
|
242
|
+
|
|
243
|
+
{/* Category Description */}
|
|
244
|
+
<CollapsibleContent>
|
|
245
|
+
<div className="border-t px-4 py-3">
|
|
246
|
+
<p className="text-sm text-muted-foreground">
|
|
247
|
+
{category.description}
|
|
248
|
+
</p>
|
|
249
|
+
</div>
|
|
250
|
+
</CollapsibleContent>
|
|
251
|
+
</div>
|
|
252
|
+
</Collapsible>
|
|
253
|
+
);
|
|
254
|
+
})}
|
|
255
|
+
</div>
|
|
256
|
+
</div>
|
|
257
|
+
|
|
258
|
+
{/* Footer */}
|
|
259
|
+
<div className="flex items-center justify-between border-t px-6 py-4">
|
|
260
|
+
<div className="flex gap-2">
|
|
261
|
+
<Button
|
|
262
|
+
onClick={handleAcceptAll}
|
|
263
|
+
className="bg-primary text-primary-foreground hover:bg-primary/90"
|
|
264
|
+
>
|
|
265
|
+
{t("acceptAll")}
|
|
266
|
+
</Button>
|
|
267
|
+
<Button
|
|
268
|
+
variant="outline"
|
|
269
|
+
onClick={handleRejectAll}
|
|
270
|
+
className="border-border text-foreground hover:bg-muted"
|
|
271
|
+
>
|
|
272
|
+
{t("rejectAll")}
|
|
273
|
+
</Button>
|
|
274
|
+
</div>
|
|
275
|
+
<Button variant="outline" onClick={handleSavePreferences}>
|
|
276
|
+
{t("dialog.acceptCurrentSelection")}
|
|
277
|
+
</Button>
|
|
278
|
+
</div>
|
|
279
|
+
</DialogContent>
|
|
280
|
+
</Dialog>
|
|
281
|
+
);
|
|
282
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Globe } from "lucide-react";
|
|
4
|
+
import { useParams } from "next/navigation";
|
|
5
|
+
import { useLocale } from "next-intl";
|
|
6
|
+
import { useTransition } from "react";
|
|
7
|
+
|
|
8
|
+
import { Button } from "@/components/ui/button";
|
|
9
|
+
import {
|
|
10
|
+
DropdownMenu,
|
|
11
|
+
DropdownMenuContent,
|
|
12
|
+
DropdownMenuItem,
|
|
13
|
+
DropdownMenuTrigger,
|
|
14
|
+
} from "@/components/ui/dropdown-menu";
|
|
15
|
+
import { usePathname, useRouter } from "@/i18n/routing";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 支持的语言配置
|
|
19
|
+
*/
|
|
20
|
+
const locales = [
|
|
21
|
+
{ code: "en", label: "English", flag: "🇺🇸" },
|
|
22
|
+
{ code: "zh", label: "中文", flag: "🇨🇳" },
|
|
23
|
+
] as const;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 语言切换器组件
|
|
27
|
+
*
|
|
28
|
+
* 功能:
|
|
29
|
+
* - 显示当前语言
|
|
30
|
+
* - 下拉菜单切换语言
|
|
31
|
+
* - 切换时保持当前路径
|
|
32
|
+
*/
|
|
33
|
+
export function LanguageSwitcher() {
|
|
34
|
+
const locale = useLocale();
|
|
35
|
+
const router = useRouter();
|
|
36
|
+
const pathname = usePathname();
|
|
37
|
+
const params = useParams();
|
|
38
|
+
const [isPending, startTransition] = useTransition();
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 切换语言
|
|
42
|
+
*/
|
|
43
|
+
const handleLocaleChange = (newLocale: string) => {
|
|
44
|
+
startTransition(() => {
|
|
45
|
+
router.replace(
|
|
46
|
+
// @ts-expect-error -- TypeScript will validate that only known `params`
|
|
47
|
+
// are used in combination with a given `pathname`. Since the two will
|
|
48
|
+
// always match for the current route, we can skip runtime checks.
|
|
49
|
+
{ pathname, params },
|
|
50
|
+
{ locale: newLocale }
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<DropdownMenu>
|
|
57
|
+
<DropdownMenuTrigger asChild>
|
|
58
|
+
<Button
|
|
59
|
+
variant="ghost"
|
|
60
|
+
size="icon"
|
|
61
|
+
disabled={isPending}
|
|
62
|
+
className="relative"
|
|
63
|
+
>
|
|
64
|
+
<Globe className="h-5 w-5" />
|
|
65
|
+
<span className="sr-only">切换语言</span>
|
|
66
|
+
</Button>
|
|
67
|
+
</DropdownMenuTrigger>
|
|
68
|
+
<DropdownMenuContent align="end">
|
|
69
|
+
{locales.map((loc) => (
|
|
70
|
+
<DropdownMenuItem
|
|
71
|
+
key={loc.code}
|
|
72
|
+
onClick={() => handleLocaleChange(loc.code)}
|
|
73
|
+
className={locale === loc.code ? "bg-accent" : ""}
|
|
74
|
+
>
|
|
75
|
+
<span className="mr-2">{loc.flag}</span>
|
|
76
|
+
{loc.label}
|
|
77
|
+
</DropdownMenuItem>
|
|
78
|
+
))}
|
|
79
|
+
</DropdownMenuContent>
|
|
80
|
+
</DropdownMenu>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { cn } from "@/lib/utils";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 最大宽度容器组件
|
|
5
|
+
*
|
|
6
|
+
* 功能:
|
|
7
|
+
* - 提供统一的页面内容最大宽度限制
|
|
8
|
+
* - 自动居中对齐
|
|
9
|
+
* - 响应式内边距
|
|
10
|
+
*
|
|
11
|
+
* 使用场景:
|
|
12
|
+
* - 包裹页面主要内容区域
|
|
13
|
+
* - 确保内容在大屏幕上不会过宽
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
interface MaxWidthWrapperProps {
|
|
17
|
+
/**
|
|
18
|
+
* 子元素
|
|
19
|
+
*/
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* 自定义类名
|
|
23
|
+
*/
|
|
24
|
+
className?: string;
|
|
25
|
+
/**
|
|
26
|
+
* 是否使用较小的最大宽度
|
|
27
|
+
* - false: max-w-7xl (默认, 80rem)
|
|
28
|
+
* - true: max-w-5xl (64rem)
|
|
29
|
+
*/
|
|
30
|
+
narrow?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function MaxWidthWrapper({
|
|
34
|
+
children,
|
|
35
|
+
className,
|
|
36
|
+
narrow = false,
|
|
37
|
+
}: MaxWidthWrapperProps) {
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
className={cn(
|
|
41
|
+
"mx-auto w-full px-4 sm:px-6 lg:px-8",
|
|
42
|
+
narrow ? "max-w-5xl" : "max-w-7xl",
|
|
43
|
+
className
|
|
44
|
+
)}
|
|
45
|
+
>
|
|
46
|
+
{children}
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Monitor, Moon, Sun } from "lucide-react";
|
|
4
|
+
import { useTheme } from "next-themes";
|
|
5
|
+
|
|
6
|
+
import { Button } from "@/components/ui/button";
|
|
7
|
+
import {
|
|
8
|
+
DropdownMenu,
|
|
9
|
+
DropdownMenuContent,
|
|
10
|
+
DropdownMenuItem,
|
|
11
|
+
DropdownMenuTrigger,
|
|
12
|
+
} from "@/components/ui/dropdown-menu";
|
|
13
|
+
import { cn } from "@/lib/utils";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 主题切换组件
|
|
17
|
+
*
|
|
18
|
+
* 功能:
|
|
19
|
+
* - 在浅色、深色、系统主题之间切换
|
|
20
|
+
* - 使用 next-themes 管理主题状态
|
|
21
|
+
* - 支持两种显示模式: dropdown 和 inline
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
interface ModeToggleProps {
|
|
25
|
+
/**
|
|
26
|
+
* 显示模式
|
|
27
|
+
* - dropdown: 下拉菜单形式 (默认)
|
|
28
|
+
* - inline: 并排按钮形式
|
|
29
|
+
*/
|
|
30
|
+
variant?: "dropdown" | "inline";
|
|
31
|
+
/**
|
|
32
|
+
* 自定义类名
|
|
33
|
+
*/
|
|
34
|
+
className?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function ModeToggle({
|
|
38
|
+
variant = "dropdown",
|
|
39
|
+
className,
|
|
40
|
+
}: ModeToggleProps) {
|
|
41
|
+
const { theme, setTheme } = useTheme();
|
|
42
|
+
|
|
43
|
+
// 内联按钮模式
|
|
44
|
+
if (variant === "inline") {
|
|
45
|
+
return (
|
|
46
|
+
<div className={cn("flex items-center gap-1", className)}>
|
|
47
|
+
<button
|
|
48
|
+
type="button"
|
|
49
|
+
onClick={() => setTheme("light")}
|
|
50
|
+
className={cn(
|
|
51
|
+
"flex h-9 w-9 items-center justify-center rounded-md transition-colors",
|
|
52
|
+
theme === "light"
|
|
53
|
+
? "bg-muted text-foreground"
|
|
54
|
+
: "text-muted-foreground hover:bg-muted hover:text-foreground"
|
|
55
|
+
)}
|
|
56
|
+
title="浅色模式"
|
|
57
|
+
>
|
|
58
|
+
<Sun className="h-4 w-4" />
|
|
59
|
+
<span className="sr-only">浅色模式</span>
|
|
60
|
+
</button>
|
|
61
|
+
<button
|
|
62
|
+
type="button"
|
|
63
|
+
onClick={() => setTheme("dark")}
|
|
64
|
+
className={cn(
|
|
65
|
+
"flex h-9 w-9 items-center justify-center rounded-md transition-colors",
|
|
66
|
+
theme === "dark"
|
|
67
|
+
? "bg-muted text-foreground"
|
|
68
|
+
: "text-muted-foreground hover:bg-muted hover:text-foreground"
|
|
69
|
+
)}
|
|
70
|
+
title="深色模式"
|
|
71
|
+
>
|
|
72
|
+
<Moon className="h-4 w-4" />
|
|
73
|
+
<span className="sr-only">深色模式</span>
|
|
74
|
+
</button>
|
|
75
|
+
<button
|
|
76
|
+
type="button"
|
|
77
|
+
onClick={() => setTheme("system")}
|
|
78
|
+
className={cn(
|
|
79
|
+
"flex h-9 w-9 items-center justify-center rounded-md transition-colors",
|
|
80
|
+
theme === "system"
|
|
81
|
+
? "bg-primary/10 text-primary dark:bg-primary/20 dark:text-primary"
|
|
82
|
+
: "text-muted-foreground hover:bg-muted hover:text-foreground"
|
|
83
|
+
)}
|
|
84
|
+
title="跟随系统"
|
|
85
|
+
>
|
|
86
|
+
<Monitor className="h-4 w-4" />
|
|
87
|
+
<span className="sr-only">跟随系统</span>
|
|
88
|
+
</button>
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 下拉菜单模式 (默认)
|
|
94
|
+
return (
|
|
95
|
+
<DropdownMenu>
|
|
96
|
+
<DropdownMenuTrigger asChild>
|
|
97
|
+
<Button variant="ghost" size="icon" className={className}>
|
|
98
|
+
<Sun className="h-5 w-5 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
|
|
99
|
+
<Moon className="absolute h-5 w-5 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
|
|
100
|
+
<span className="sr-only">切换主题</span>
|
|
101
|
+
</Button>
|
|
102
|
+
</DropdownMenuTrigger>
|
|
103
|
+
<DropdownMenuContent align="end">
|
|
104
|
+
<DropdownMenuItem onClick={() => setTheme("light")}>
|
|
105
|
+
<Sun className="mr-2 h-4 w-4" />
|
|
106
|
+
浅色
|
|
107
|
+
</DropdownMenuItem>
|
|
108
|
+
<DropdownMenuItem onClick={() => setTheme("dark")}>
|
|
109
|
+
<Moon className="mr-2 h-4 w-4" />
|
|
110
|
+
深色
|
|
111
|
+
</DropdownMenuItem>
|
|
112
|
+
<DropdownMenuItem onClick={() => setTheme("system")}>
|
|
113
|
+
<Monitor className="mr-2 h-4 w-4" />
|
|
114
|
+
跟随系统
|
|
115
|
+
</DropdownMenuItem>
|
|
116
|
+
</DropdownMenuContent>
|
|
117
|
+
</DropdownMenu>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google 图标组件
|
|
3
|
+
*
|
|
4
|
+
* 用于 OAuth 登录按钮显示 Google 品牌图标
|
|
5
|
+
* 使用官方 Google 品牌颜色
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
interface GoogleIconProps {
|
|
9
|
+
/** 自定义类名 */
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function GoogleIcon({ className }: GoogleIconProps) {
|
|
14
|
+
return (
|
|
15
|
+
<svg className={className} viewBox="0 0 24 24">
|
|
16
|
+
<title>Google</title>
|
|
17
|
+
{/* Google 蓝色 - 右侧弧形 */}
|
|
18
|
+
<path
|
|
19
|
+
d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"
|
|
20
|
+
fill="#4285F4"
|
|
21
|
+
/>
|
|
22
|
+
{/* Google 绿色 - 底部弧形 */}
|
|
23
|
+
<path
|
|
24
|
+
d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"
|
|
25
|
+
fill="#34A853"
|
|
26
|
+
/>
|
|
27
|
+
{/* Google 黄色 - 左侧弧形 */}
|
|
28
|
+
<path
|
|
29
|
+
d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"
|
|
30
|
+
fill="#FBBC05"
|
|
31
|
+
/>
|
|
32
|
+
{/* Google 红色 - 顶部弧形 */}
|
|
33
|
+
<path
|
|
34
|
+
d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"
|
|
35
|
+
fill="#EA4335"
|
|
36
|
+
/>
|
|
37
|
+
</svg>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineModule } from "@/core/modules";
|
|
2
|
+
|
|
3
|
+
export const sharedModule = defineModule({
|
|
4
|
+
id: "shared",
|
|
5
|
+
name: "Shared UI",
|
|
6
|
+
description: "跨页面复用的基础组件、图标和 Provider",
|
|
7
|
+
kind: "core",
|
|
8
|
+
dependencies: [],
|
|
9
|
+
routes: [],
|
|
10
|
+
navigation: [],
|
|
11
|
+
translations: ["Common", "Cookie"],
|
|
12
|
+
schema: [],
|
|
13
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { RootProvider } from "fumadocs-ui/provider/next";
|
|
4
|
+
import { ThemeProvider } from "next-themes";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 全局 Providers 组件
|
|
8
|
+
*
|
|
9
|
+
* 功能:
|
|
10
|
+
* - 主题管理 (next-themes)
|
|
11
|
+
* - Fumadocs UI 框架支持 (RootProvider)
|
|
12
|
+
* - 可扩展添加其他 Provider (如 QueryClient, SessionProvider 等)
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
interface ProvidersProps {
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
locale?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const docsLocales = [
|
|
21
|
+
{ locale: "en", name: "English" },
|
|
22
|
+
{ locale: "zh", name: "中文" },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const zhDocsTranslations = {
|
|
26
|
+
search: "搜索",
|
|
27
|
+
searchNoResult: "没有找到结果",
|
|
28
|
+
toc: "本页目录",
|
|
29
|
+
tocNoHeadings: "没有标题",
|
|
30
|
+
lastUpdate: "最后更新于",
|
|
31
|
+
chooseLanguage: "选择语言",
|
|
32
|
+
nextPage: "下一页",
|
|
33
|
+
previousPage: "上一页",
|
|
34
|
+
chooseTheme: "选择主题",
|
|
35
|
+
editOnGithub: "在 GitHub 编辑",
|
|
36
|
+
} as const;
|
|
37
|
+
|
|
38
|
+
export function Providers({ children, locale = "en" }: ProvidersProps) {
|
|
39
|
+
const docsLocale = locale === "zh" ? "zh" : "en";
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<ThemeProvider
|
|
43
|
+
attribute="class"
|
|
44
|
+
defaultTheme="system"
|
|
45
|
+
enableSystem
|
|
46
|
+
disableTransitionOnChange
|
|
47
|
+
>
|
|
48
|
+
<RootProvider
|
|
49
|
+
i18n={{
|
|
50
|
+
locale: docsLocale,
|
|
51
|
+
locales: docsLocales,
|
|
52
|
+
...(docsLocale === "zh" ? { translations: zhDocsTranslations } : {}),
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
{children}
|
|
56
|
+
</RootProvider>
|
|
57
|
+
</ThemeProvider>
|
|
58
|
+
);
|
|
59
|
+
}
|