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, '每日进销存数据'); });