XWX-AI commited on
Commit
2c58405
·
1 Parent(s): 24a2ddf

feat(pdf): 页脚品牌文案支持插件传入 brandText(唯一事实来源迁至插件 watermark.js,未传回退默认值向后兼容)+ 品牌名统一 XWX Exporter,bump v3.0.0

Browse files
Files changed (3) hide show
  1. package.json +1 -1
  2. reproduce-realistic.js +1 -1
  3. server.js +7 -3
package.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "pdf-server",
3
- "version": "2.1.11",
4
  "description": "Puppeteer PDF + Widget Renderer for XWX AI Chat Exporter",
5
  "main": "server.js",
6
  "dependencies": {
 
1
  {
2
  "name": "pdf-server",
3
+ "version": "3.0.0",
4
  "description": "Puppeteer PDF + Widget Renderer for XWX AI Chat Exporter",
5
  "main": "server.js",
6
  "dependencies": {
reproduce-realistic.js CHANGED
@@ -718,7 +718,7 @@ function generateLargeHtml(targetSizeMB) {
718
  <div class="chat-container">\`;
719
 
720
  const footerHtml = \` </div>
721
- <div class="pdf-footer"><span>Powered by <a href="https://xwxexporter.com/tools/chat-exporter" target="_blank">XWX AI Chat Exporter</a></span></div>
722
  </body>
723
  </html>\`;
724
 
 
718
  <div class="chat-container">\`;
719
 
720
  const footerHtml = \` </div>
721
+ <div class="pdf-footer"><span>Powered by <a href="https://xwxexporter.com/tools/chat-exporter" target="_blank">XWX Exporter</a></span></div>
722
  </body>
723
  </html>\`;
724
 
server.js CHANGED
@@ -227,7 +227,7 @@ app.post('/api/generate_pdf', async (req, res) => {
227
  const startTime = Date.now();
228
 
229
  // ── 功能性字段(PDF渲染业务逻辑依赖,保持顶层) ──
230
- const { html, textOnlySizeMB, codeTheme, showWatermark,
231
  imageCount, totalImageSizeMB, messageCount } = req.body;
232
 
233
  // ── 遥测数据:通用 metadata 对象,后端不做任何解析/格式化,原样透传 ──
@@ -272,7 +272,11 @@ app.post('/api/generate_pdf', async (req, res) => {
272
  htmlToProcess = highlightHtmlWithShiki(html, 'github');
273
  }
274
 
275
- const brandText = showWatermark !== false ? 'Powered by XWX AI Chat Exporter' : '';
 
 
 
 
276
  const htmlSizeMBNum = Buffer.byteLength(html, 'utf8') / (1024 * 1024);
277
  const htmlSizeMB = htmlSizeMBNum.toFixed(2);
278
  const imgCount = imageCount || 0;
@@ -547,7 +551,7 @@ app.post('/api/generate_pdf', async (req, res) => {
547
  headerTemplate: '<div></div>',
548
  footerTemplate: `
549
  <div style="font-size: 10px; font-family: Arial, sans-serif; color: #999; width: 100%; padding: 0 15mm; display: flex; justify-content: space-between; align-items: center;">
550
- <div style="flex: 1; text-align: left;">${brandText}</div>
551
  <div style="flex: 1; text-align: right;"><span class="pageNumber"></span> / <span class="totalPages"></span></div>
552
  </div>
553
  `,
 
227
  const startTime = Date.now();
228
 
229
  // ── 功能性字段(PDF渲染业务逻辑依赖,保持顶层) ──
230
+ const { html, textOnlySizeMB, codeTheme, showWatermark, brandText,
231
  imageCount, totalImageSizeMB, messageCount } = req.body;
232
 
233
  // ── 遥测数据:通用 metadata 对象,后端不做任何解析/格式化,原样透传 ──
 
272
  htmlToProcess = highlightHtmlWithShiki(html, 'github');
273
  }
274
 
275
+ // 每页页脚品牌文案:优先使用插件传入的 brandText(唯一事实来源在插件 src/utils/watermark.js),
276
+ // 未传时回退默认值,向后兼容旧版插件
277
+ const brandTextResolved = showWatermark !== false
278
+ ? (typeof brandText === 'string' && brandText.trim() ? brandText : 'Powered by XWX AI Chat Exporter')
279
+ : '';
280
  const htmlSizeMBNum = Buffer.byteLength(html, 'utf8') / (1024 * 1024);
281
  const htmlSizeMB = htmlSizeMBNum.toFixed(2);
282
  const imgCount = imageCount || 0;
 
551
  headerTemplate: '<div></div>',
552
  footerTemplate: `
553
  <div style="font-size: 10px; font-family: Arial, sans-serif; color: #999; width: 100%; padding: 0 15mm; display: flex; justify-content: space-between; align-items: center;">
554
+ <div style="flex: 1; text-align: left;">${brandTextResolved}</div>
555
  <div style="flex: 1; text-align: right;"><span class="pageNumber"></span> / <span class="totalPages"></span></div>
556
  </div>
557
  `,