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) {