feat: local export splits abouts into point columns

- add prepareLocalExportItemsWithAboutPoints to split abouts array
  into columns point1 pointN for local Excel export
- handleExport calls this only for local export; cloud export keeps
  the original single abouts column

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
PetrichorFun 2026-05-22 15:30:25 +08:00
parent bde6022230
commit 147616c697
2 changed files with 48 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.11-beta",
"version": "0.7.2",
"private": true,
"description": "Starter modify by honestfox101 and PetrichorFun",

View File

@ -210,13 +210,57 @@ const filteredData = computed(() => {
return data;
});
/** 本地导出:将「关于」拆成「要点1…要点n」多列,云端导出仍为单列「关于」 */
function prepareLocalExportItemsWithAboutPoints(
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);
if (opt === 'local') {
const prepared = prepareLocalExportItemsWithAboutPoints(headers, items as AmazonItem[]);
headers = prepared.headers;
items = prepared.items;
}
const fragments = [
{
data: items,
headers: headers,
headers,
imageColumn: ['A+截图', '商品图片链接'],
name: 'items',
},