From c4ea12e9ba4631ed4fae07121a07b66f4506fa0d Mon Sep 17 00:00:00 2001 From: youruo <15018737611@163.com> Date: Thu, 24 Sep 2026 11:59:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E6=88=AA=E5=9B=BE?= =?UTF-8?q?=E7=AB=99=E7=82=B9=E5=9C=B0=E5=9D=80=E4=B8=8E=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E6=AD=A3=E6=96=87=E9=93=BE=E6=8E=A5=EF=BC=8C=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E9=95=9C=E5=83=8F=E8=A1=A5=E5=85=85=20Chromium=20=E4=B8=8E?= =?UTF-8?q?=E4=B8=AD=E6=96=87=E5=AD=97=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 截图默认站点改为生产主站 ck.yydd.ai(原默认值指向无关域名) - 通知正文补充「页面地址」,便于在通知中心直接打开 - 服务身份增加 daily_inventory 页面权限声明 - Dockerfile 安装 Chromium 与 fonts-noto-cjk,否则容器内无法截图且中文显示为方块 --- backend/Dockerfile.production | 9 +++++++-- backend/src/jobs/dailyInventoryNotificationJob.js | 1 + backend/src/services/dailyInventoryScreenshot.js | 3 ++- backend/test/dailyInventoryNotification.test.js | 3 ++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/Dockerfile.production b/backend/Dockerfile.production index dfa160a..b587bb1 100644 --- a/backend/Dockerfile.production +++ b/backend/Dockerfile.production @@ -3,12 +3,17 @@ FROM node:22-bookworm-slim ENV NODE_ENV=production WORKDIR /app +# 每日进销存定时截图需要 Chromium 与中文字体: +# · fonts-noto-cjk —— 否则截图里所有中文都会变成方块 +# · playwright install --with-deps chromium —— 默认镜像不带浏览器 RUN apt-get update \ - && apt-get install -y --no-install-recommends ca-certificates \ + && apt-get install -y --no-install-recommends ca-certificates fonts-noto-cjk \ && rm -rf /var/lib/apt/lists/* COPY package.json package-lock.json ./ -RUN npm ci --omit=dev --no-audit --no-fund +RUN npm ci --omit=dev --no-audit --no-fund \ + && npx playwright install --with-deps chromium \ + && rm -rf /var/lib/apt/lists/* /root/.npm/_cacache COPY . . diff --git a/backend/src/jobs/dailyInventoryNotificationJob.js b/backend/src/jobs/dailyInventoryNotificationJob.js index f397eca..22eac9a 100644 --- a/backend/src/jobs/dailyInventoryNotificationJob.js +++ b/backend/src/jobs/dailyInventoryNotificationJob.js @@ -129,6 +129,7 @@ function buildNotificationContent({ bizDate, takenAt, imageUrl, pageUrl }) { `**数据日期:** ${bizDate}`, `**截图生成时间:** ${takenAt}(${TIMEZONE})`, `**图片地址:** ${imageUrl}`, + `**页面地址:** ${pageUrl}`, '', `点击右下角「${ACTION_TITLE}」可直达每日进销存页面。`, ].join('\n'); diff --git a/backend/src/services/dailyInventoryScreenshot.js b/backend/src/services/dailyInventoryScreenshot.js index e82bdd3..594ade8 100644 --- a/backend/src/services/dailyInventoryScreenshot.js +++ b/backend/src/services/dailyInventoryScreenshot.js @@ -18,7 +18,8 @@ const { uploadFileToDefaultS3 } = require('./objectStorage'); const TIMEZONE = 'Asia/Shanghai'; const PAGE_PATH = '/planning/operation/daily-inventory'; -const DEFAULT_BASE_URL = 'https://pddg.jiansuntuzhi.cn'; +// 生产主站(见《服务器部署规范》):可用 DAILY_INVENTORY_SCREENSHOT_BASE_URL / PUBLIC_SITE_URL 覆盖 +const DEFAULT_BASE_URL = 'https://ck.yydd.ai'; // 页面首次加载要扫订单明细,约 15~20 秒,等待上限给到 3 分钟 const PAGE_READY_TIMEOUT_MS = 3 * 60 * 1000; const SCREENSHOT_SERVICE_USER = Object.freeze({ diff --git a/backend/test/dailyInventoryNotification.test.js b/backend/test/dailyInventoryNotification.test.js index 8225110..941c05c 100644 --- a/backend/test/dailyInventoryNotification.test.js +++ b/backend/test/dailyInventoryNotification.test.js @@ -99,11 +99,12 @@ test('buildNotificationContent 包含数据日期、生成时间、图片地址 bizDate: '2026-09-25', takenAt: '2026/09/25 01:00:00', imageUrl: 'https://cdn.example.com/daily-inventory/2026-09-25/daily-inventory-20260925-010000.png', - pageUrl: 'https://pddg.jiansuntuzhi.cn/planning/operation/daily-inventory', + pageUrl: 'https://ck.yydd.ai/planning/operation/daily-inventory', }); assert.match(content, /2026-09-25/); assert.match(content, /2026\/09\/25 01:00:00/); assert.match(content, /https:\/\/cdn\.example\.com\//); + assert.match(content, /https:\/\/ck\.yydd\.ai\/planning\/operation\/daily-inventory/); assert.match(content, new RegExp(ACTION_TITLE)); assert.equal(NOTIFICATION_TITLE, '每日进销存数据'); });