feat: 支持 about-points 拆分导出(本地+云端)

合并自 fix/detail-page-image 分支的以下提交:
- feat: local export splits abouts into point columns (147616c)
- refactor: apply about-points expansion to both local and cloud export (f0a5463)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
PetrichorFun 2026-09-10 17:51:39 +08:00
parent b062d96742
commit 0f50620a12
2 changed files with 46 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "azon-seeker",
"displayName": "Azon Seeker v0.7.1.10-beta",
"displayName": "Azon Seeker v0.7.1.12-beta",
"version": "0.7.2",
"private": true,
"description": "Starter modify by honestfox101 and PetrichorFun",

View File

@ -210,13 +210,55 @@ const filteredData = computed(() => {
return data;
});
/** 导出时将「关于」拆成「要点1…要点n」多列 */
function prepareExportItemsWithAboutPoints(
headers: Header[],
items: AmazonItem[],
): { headers: Header[]; items: Record<string, unknown>[] } {
const aboutLines = (item: AmazonItem) => {
const raw = item.abouts;
if (!raw?.length) return [];
return raw
.flatMap((line) => line.split(/\r?\n/))
.map((s) => s.trim())
.filter(Boolean);
};
const nextHeaders = headers.filter((h) => h.prop !== 'abouts');
const lineArrays = items.map(aboutLines);
const maxN = Math.max(1, ...lineArrays.map((l) => l.length));
for (let i = 0; i < maxN; i++) {
nextHeaders.push({
label: `要点${i + 1}`,
prop: `aboutPoint${i + 1}`,
});
}
const nextItems = items.map((item, idx) => {
const row: Record<string, unknown> = { ...item };
const lines = lineArrays[idx];
for (let i = 0; i < maxN; i++) {
row[`aboutPoint${i + 1}`] = lines[i] ?? '';
}
return row;
});
return { headers: nextHeaders, items: nextItems };
}
const handleExport = async (opt: 'local' | 'cloud') => {
const headers = getItemHeaders();
const items = toRaw(filteredData.value);
let headers = getItemHeaders();
let items: Record<string, unknown>[] | AmazonItem[] = toRaw(filteredData.value);
const prepared = prepareExportItemsWithAboutPoints(headers, items as AmazonItem[]);
headers = prepared.headers;
items = prepared.items;
const fragments = [
{
data: items,
headers: headers,
headers,
imageColumn: ['A+截图', '商品图片链接'],
name: 'items',
},