mirror of
https://github.com/primedigitaltech/azon_seeker.git
synced 2026-10-04 14:53:22 +08:00
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:
parent
bde6022230
commit
147616c697
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "azon-seeker",
|
"name": "azon-seeker",
|
||||||
"displayName": "Azon Seeker v0.7.1.10-beta",
|
"displayName": "Azon Seeker v0.7.1.11-beta",
|
||||||
"version": "0.7.2",
|
"version": "0.7.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Starter modify by honestfox101 and PetrichorFun",
|
"description": "Starter modify by honestfox101 and PetrichorFun",
|
||||||
|
|||||||
@ -210,13 +210,57 @@ const filteredData = computed(() => {
|
|||||||
return data;
|
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 handleExport = async (opt: 'local' | 'cloud') => {
|
||||||
const headers = getItemHeaders();
|
let headers = getItemHeaders();
|
||||||
const items = toRaw(filteredData.value);
|
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 = [
|
const fragments = [
|
||||||
{
|
{
|
||||||
data: items,
|
data: items,
|
||||||
headers: headers,
|
headers,
|
||||||
imageColumn: ['A+截图', '商品图片链接'],
|
imageColumn: ['A+截图', '商品图片链接'],
|
||||||
name: 'items',
|
name: 'items',
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user