From e36d363c571cb8906ec6f67fb0269bf39ed0ae63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Fri, 23 Oct 2026 23:38:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(common-tools):=20=E8=B5=84=E6=96=99?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=94=B9=E6=8C=82=E7=AB=99=E7=82=B9=20/stati?= =?UTF-8?q?c/=20=E9=9D=99=E6=80=81=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /materials/ 是不在发布白名单里的新目录,deploy_app_web.py 只上传 index.html+assets+/static/ 清单 ⇒ 上线即 404。改走既有 /static/(nginx 已配), 发布清单在 ops 仓 deploy_app_web.py 同步登记 4 个文件。 --- frontend-vue/src/pages/amazon/pricing-resources.ts | 8 +++++--- frontend-vue/tests/mount/common-tools-pages.mount.test.ts | 4 ++-- frontend-vue/tests/pricing-resources.test.ts | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/frontend-vue/src/pages/amazon/pricing-resources.ts b/frontend-vue/src/pages/amazon/pricing-resources.ts index bf3dbd91e..5bfb463da 100644 --- a/frontend-vue/src/pages/amazon/pricing-resources.ts +++ b/frontend-vue/src/pages/amazon/pricing-resources.ts @@ -2,8 +2,8 @@ * 定价利润换算页 · 常用链接与资料下载 * * 链接清单源自桌面版 shufu_calc_app.py 的 PAGE_LINKS / 资料页(2026-10-23 实测可达), - * 下载文件随前端 public/materials/ 一并部署(源自「数富资料下载_独立版_v1.0.0」; - * 目录名避开 .gitignore 的 downloads/ 规则)。 + * 下载文件源自「数富资料下载_独立版_v1.0.0」,源文件在 public/materials/, + * 发布时由 scripts/deploy_app_web.py 的 EXPECTED_STATIC 白名单上传到站点 /static/。 */ export type CommonLink = { @@ -37,5 +37,7 @@ export const PRICING_DOWNLOADS: ReadonlyArray = [ ] export function downloadHref(file: string): string { - return `/materials/${encodeURI(file)}` + // 走既有 /static/ 静态位(nginx 已配,deploy_app_web.py 的 EXPECTED_STATIC 白名单同步登记); + // /materials/ 这类新目录不在发布清单里,上线即 404。 + return `/static/${encodeURI(file)}` } diff --git a/frontend-vue/tests/mount/common-tools-pages.mount.test.ts b/frontend-vue/tests/mount/common-tools-pages.mount.test.ts index 071619bce..7737e091b 100644 --- a/frontend-vue/tests/mount/common-tools-pages.mount.test.ts +++ b/frontend-vue/tests/mount/common-tools-pages.mount.test.ts @@ -90,14 +90,14 @@ describe('定价利润换算页', () => { expect(page.findAll('.result-value')[3]?.text()).toBe('3.7500') }) - it('资料下载四个锚点落在 /materials/ 且 href 无裸空格;常用链接均为 http(s)', async () => { + it('资料下载四个锚点落在 /static/ 且 href 无裸空格;常用链接均为 http(s)', async () => { const page = mountPage(PricingCalcPage) const downloadHrefs = page .findAll('a[download]') .map((a) => a.attributes('href') ?? '') expect(downloadHrefs).toHaveLength(4) for (const href of downloadHrefs) { - expect(href.startsWith('/materials/')).toBe(true) + expect(href.startsWith('/static/')).toBe(true) expect(href.includes(' ')).toBe(false) } const linkHrefs = page diff --git a/frontend-vue/tests/pricing-resources.test.ts b/frontend-vue/tests/pricing-resources.test.ts index 4e89474c5..e34f41548 100644 --- a/frontend-vue/tests/pricing-resources.test.ts +++ b/frontend-vue/tests/pricing-resources.test.ts @@ -13,11 +13,11 @@ import { const here = dirname(fileURLToPath(import.meta.url)) const ROOT = resolve(here, '..') -test('downloadHref:落在 /materials/ 下,空格与非 ASCII 都按 encodeURI 转义', () => { - assert.equal(downloadHref('百分30利润表格.xlsx'), `/materials/${encodeURI('百分30利润表格.xlsx')}`) +test('downloadHref:落在 /static/ 下,空格与非 ASCII 都按 encodeURI 转义', () => { + assert.equal(downloadHref('百分30利润表格.xlsx'), `/static/${encodeURI('百分30利润表格.xlsx')}`) assert.equal( downloadHref('设置最低价ASIN 批量文档格式.xlsx'), - '/materials/%E8%AE%BE%E7%BD%AE%E6%9C%80%E4%BD%8E%E4%BB%B7ASIN%20%E6%89%B9%E9%87%8F%E6%96%87%E6%A1%A3%E6%A0%BC%E5%BC%8F.xlsx', + '/static/%E8%AE%BE%E7%BD%AE%E6%9C%80%E4%BD%8E%E4%BB%B7ASIN%20%E6%89%B9%E9%87%8F%E6%96%87%E6%A1%A3%E6%A0%BC%E5%BC%8F.xlsx', ) // 不允许出现裸空格(浏览器会容忍,但 href 里必须是编码后的形态) for (const item of PRICING_DOWNLOADS) {