feat: add PDF export functionality to share modal (#9300)

* feat: add PDF export functionality to share modal

- Create usePdfExport hook with jsPDF and html2canvas
- Add "Export as PDF" button to screenshot tab in share modal
- Support multi-page PDFs for long conversations
- Add required dependencies: jspdf@^2.5.2 and html2canvas@^1.4.1
- Add localization support for PDF export button

Fixes #9299

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: LobeHub Bot <lobehubbot@users.noreply.github.com>

* ♻️ refactor: convert PDF export to separate tab with backend generation

- Create new SharePdf tab component with PDF.js preview
- Move PDF generation from frontend to backend via tRPC
- Add server-side PDF generation using jsPDF
- Remove old PDF export button from ShareImage component
- Add proper loading states and error handling
- Update localization for PDF tab

Co-authored-by: Shinji-Li <ONLY-yours@users.noreply.github.com>

* 🐛 fix: resolve unicorn/no-await-expression-member lint error in PDF exporter

Split await expression member access to avoid linting error in exporter.ts

Co-authored-by: Shinji-Li <ONLY-yours@users.noreply.github.com>

* feat: add i18n

* feat: use pdfkit to export a pdf

* feat: add fullscreen preview

* feat: update pdf preview styles

* feat: add i18n locales

* feat: add single pdf share modal

* feat: update css & client mode cant use pdf genertate

* fix: mobile style fixed

* fix: delete console.log & useless packagejson

* feat: use online otf link

---------

Co-authored-by: Shinji-Li <ONLY-yours@users.noreply.github.com>
This commit is contained in:
Shinji-Li
2025-10-21 16:32:17 +08:00
committed by GitHub
parent 6734a47759
commit 2b7761c36e
33 changed files with 1840 additions and 60 deletions
+5 -6
View File
@@ -201,7 +201,6 @@ const nextConfig: NextConfig = {
},
},
reactStrictMode: true,
redirects: async () => [
{
destination: '/sitemap-index.xml',
@@ -272,7 +271,7 @@ const nextConfig: NextConfig = {
],
// when external packages in dev mode with turbopack, this config will lead to bundle error
serverExternalPackages: isProd ? ['@electric-sql/pglite'] : undefined,
serverExternalPackages: isProd ? ['@electric-sql/pglite', "pdfkit"] : ["pdfkit"],
transpilePackages: ['pdfjs-dist', 'mermaid'],
typescript: {
@@ -337,10 +336,10 @@ const withBundleAnalyzer = process.env.ANALYZE === 'true' ? analyzer() : noWrapp
const withPWA =
isProd && !isDesktop
? withSerwistInit({
register: false,
swDest: 'public/sw.js',
swSrc: 'src/app/sw.ts',
})
register: false,
swDest: 'public/sw.js',
swSrc: 'src/app/sw.ts',
})
: noWrapper;
export default withBundleAnalyzer(withPWA(nextConfig as NextConfig));