feat(common-tools): 定价换算页补常用链接与资料下载区

链接清单与桌面版资料页同源(2026-10-23 实测可达),4 个资料文件随
public/materials/ 部署(目录名避开 .gitignore 的 downloads/ 规则)。
This commit is contained in:
2026-10-23 22:38:06 +08:00
parent eb6dd9bf44
commit b5d08ed77e
7 changed files with 260 additions and 1 deletions
@@ -0,0 +1,38 @@
@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion
echo 正在执行 PowerShell 命令解除文件锁定...
powershell -Command "Get-ChildItem -Path \"%cd%\" -Recurse | Unblock-File"
if %errorlevel% equ 0 (
echo 文件解锁完成
) else (
echo 文件解锁失败,请检查 PowerShell 权限
)
echo.
echo 检查 ShuFuAi.exe.config 文件...
if exist "ShuFuAi.exe.config" (
echo ShuFuAi.exe.config 已存在,跳过创建
) else (
echo 正在创建 ShuFuAi.exe.config...
(
echo ^<?xml version="1.0" encoding="utf-8" ?^>
echo ^<configuration^>
echo ^<runtime^>
echo ^<loadFromRemoteSources enabled="true"/^>
echo ^</runtime^>
echo ^</configuration^>
) > "ShuFuAi.exe.config"
if exist "ShuFuAi.exe.config" (
echo ShuFuAi.exe.config 创建成功
) else (
echo ShuFuAi.exe.config 创建失败,请检查权限
)
)
echo.
echo 操作完成!
pause
@@ -0,0 +1,41 @@
/**
* 定价利润换算页 · 常用链接与资料下载
*
* 链接清单源自桌面版 shufu_calc_app.py 的 PAGE_LINKS / 资料页(2026-10-23 实测可达),
* 下载文件随前端 public/materials/ 一并部署(源自「数富资料下载_独立版_v1.0.0」;
* 目录名避开 .gitignore 的 downloads/ 规则)。
*/
export type CommonLink = {
name: string
url: string
}
export type DownloadItem = {
name: string
/** public/materials/ 下的文件名(含空格/中文,渲染时 encodeURI) */
file: string
}
export const PRICING_COMMON_LINKS: ReadonlyArray<CommonLink> = [
{ name: 'Aliprice 1688 采集插件', url: 'https://www.aiprice.com/?ext_id=10100&channel=chrome_offline&platform=1688&version=4.0.5' },
{ name: '店小密导出设置', url: 'https://www.dianxiaomi.com/web/orderSetting/export' },
{ name: '数富AI BUG登记系统', url: 'https://bug.aishufu.top/bug-tracker/' },
{ name: '代理IP提取', url: 'https://www.jikip.com/user/extractapi' },
{ name: 'LLM 平台', url: 'https://ai.t8star.org/' },
{ name: '豆包CDN短链', url: 'https://aka.doubaocdn.com/s/O1DRPbr9rd#f=1' },
{ name: '紫鸟浏览器下载', url: 'https://www.ziniao.com/download/?from=97340' },
{ name: '无影下载', url: 'https://www.aliyun.com/product/wuying/download' },
{ name: 'WebView2 运行时', url: 'https://go.microsoft.com/fwlink/p/?LinkId=2124703' },
]
export const PRICING_DOWNLOADS: ReadonlyArray<DownloadItem> = [
{ name: 'winsrc兼容补丁.bat', file: 'winsrc兼容补丁.bat' },
{ name: '百分30利润表格.xlsx', file: '百分30利润表格.xlsx' },
{ name: '虚拟桌面任务工作_结构化.xlsx', file: '虚拟桌面任务工作_结构化.xlsx' },
{ name: '设置最低价ASIN 批量文档格式.xlsx', file: '设置最低价ASIN 批量文档格式.xlsx' },
]
export function downloadHref(file: string): string {
return `/materials/${encodeURI(file)}`
}
@@ -84,6 +84,40 @@
</ul>
<p class="formula-note">切换站点会清空当前结果;金额输入支持带 ¥/¥ 与千分位逗号。</p>
</section>
<section class="calc-panel">
<div class="panel-title">常用链接与资料下载</div>
<div class="resource-grid">
<div class="resource-block">
<div class="resource-block-title">常用链接</div>
<ul class="resource-list">
<li v-for="link in PRICING_COMMON_LINKS" :key="link.url" class="resource-item">
<span class="resource-name" :title="link.url">{{ link.name }}</span>
<a
class="resource-action"
:href="safeHttpUrl(link.url)"
target="_blank"
rel="noopener"
>打开</a>
<button
type="button"
class="resource-copy"
@click="copyText(link.url, `「${link.name}」链接已复制`)"
>复制</button>
</li>
</ul>
</div>
<div class="resource-block">
<div class="resource-block-title">资料下载</div>
<ul class="resource-list">
<li v-for="item in PRICING_DOWNLOADS" :key="item.file" class="resource-item">
<span class="resource-name">{{ item.name }}</span>
<a class="resource-action" :href="downloadHref(item.file)" download>下载</a>
</li>
</ul>
</div>
</div>
</section>
</div>
</AmazonToolPageShell>
</div>
@@ -94,6 +128,12 @@ import { computed, ref } from 'vue'
import { ElMessage } from 'element-plus'
import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.vue'
import {
downloadHref,
PRICING_COMMON_LINKS,
PRICING_DOWNLOADS,
} from '@/pages/amazon/pricing-resources'
import { safeHttpUrl } from '@/shared/utils/safe-url'
import {
calcPricing,
formatExchangeRate,
@@ -146,6 +186,15 @@ function resetAll() {
freightInput.value = ''
result.value = null
}
/** 复制常用链接(口径与 FiveAsinPage 一致:clipboard + toast,失败给明确提示) */
function copyText(text: string, successText: string) {
if (!text) return
navigator.clipboard
.writeText(text)
.then(() => ElMessage.success(successText))
.catch(() => ElMessage.error('复制失败,请手动复制'))
}
</script>
<style scoped>
@@ -329,9 +378,82 @@ function resetAll() {
font-size: 12px;
}
.resource-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 18px;
}
.resource-block-title {
margin-bottom: 10px;
color: #c8d2e2;
font-size: 13px;
font-weight: 700;
}
.resource-list {
margin: 0;
padding: 0;
list-style: none;
display: flex;
flex-direction: column;
gap: 8px;
}
.resource-item {
display: flex;
align-items: center;
gap: 10px;
padding: 8px 12px;
border: 1px solid #3e4a62;
border-radius: 6px;
background: #2b3447;
}
.resource-name {
flex: 1;
min-width: 0;
overflow: hidden;
color: #f5f8fc;
font-size: 13px;
text-overflow: ellipsis;
white-space: nowrap;
}
.resource-action {
flex-shrink: 0;
color: #f59e0b;
font-size: 12px;
font-weight: 700;
text-decoration: none;
}
.resource-action:hover {
text-decoration: underline;
}
.resource-copy {
flex-shrink: 0;
padding: 4px 12px;
border: 1px solid #3e4a62;
border-radius: 4px;
background: transparent;
color: #c8d2e2;
font-size: 12px;
font-family: inherit;
cursor: pointer;
transition: all 0.2s;
}
.resource-copy:hover {
border-color: #f59e0b;
color: #f59e0b;
}
@media (max-width: 900px) {
.input-grid,
.result-grid {
.result-grid,
.resource-grid {
grid-template-columns: 1fr;
}
@@ -0,0 +1,58 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readdirSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { dirname, join, resolve } from 'node:path'
import {
downloadHref,
PRICING_COMMON_LINKS,
PRICING_DOWNLOADS,
} from '../src/pages/amazon/pricing-resources.ts'
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')}`)
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',
)
// 不允许出现裸空格(浏览器会容忍,但 href 里必须是编码后的形态)
for (const item of PRICING_DOWNLOADS) {
assert.ok(!downloadHref(item.file).includes(' '), `${item.file} 的 href 含裸空格`)
}
})
test('资料下载清单与 public/materials/ 实际文件一一对应(少一个下载就 404)', () => {
const dir = join(ROOT, 'public', 'materials')
const onDisk = readdirSync(dir)
assert.ok(onDisk.length >= PRICING_DOWNLOADS.length, 'public/materials 里的文件比清单还少')
for (const item of PRICING_DOWNLOADS) {
assert.ok(onDisk.includes(item.file), `public/materials/ 缺少清单文件:${item.file}`)
}
})
test('常用链接清单:名称/地址非空、http(s) 协议、无重复', () => {
assert.ok(PRICING_COMMON_LINKS.length >= 5, `常用链接只有 ${PRICING_COMMON_LINKS.length} 条,桌面版清单不止这些`)
const names = new Set<string>()
const urls = new Set<string>()
for (const link of PRICING_COMMON_LINKS) {
assert.ok(link.name.trim(), '存在空名称的常用链接')
assert.match(link.url, /^https?:\/\//, `${link.name} 的地址不是 http(s):${link.url}`)
assert.ok(!names.has(link.name), `链接名称重复:${link.name}`)
assert.ok(!urls.has(link.url), `链接地址重复:${link.url}`)
names.add(link.name)
urls.add(link.url)
}
})
test('下载清单:名称与文件字段成对、无重复文件', () => {
const files = new Set<string>()
for (const item of PRICING_DOWNLOADS) {
assert.ok(item.name.trim() && item.file.trim(), '存在空的名称或文件名')
assert.ok(!files.has(item.file), `下载文件重复:${item.file}`)
files.add(item.file)
}
})