aliChoice:SKU分类是原生 select(新增 fillNativeSelects,失败 6/10→8/10);文本必填改为按字段名给值,修正颜色被填成材质词
This commit is contained in:
1 parent
14214862e6
commit
ad9b955d95
2 files changed
+46
-5
No files matched your search
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
import { readFileSync, writeFileSync, appendFileSync } from 'fs';
|
||||
import { newPage, closePage, wait, installHook, readHook } from '/home/admin9webs/shein建品/sh_lib.mjs';
|
||||
import { selectCategory, fillRequiredSelects, fillRequiredTextInputs } from '/home/admin9webs/shein建品/sh_build.mjs';
|
||||
import { selectCategory, fillRequiredSelects, fillRequiredTextInputs, fillNativeSelects } from '/home/admin9webs/shein建品/sh_build.mjs';
|
||||
|
||||
const DIR = '/home/admin9webs/alichoice建品';
|
||||
const P = `document.querySelector('#app').__vue_app__.config.globalProperties.$pinia`;
|
||||
@@ -140,11 +140,24 @@ for (const t of tasks) {
|
||||
if (attrs !== 'none') log(` 必填属性: ${String(attrs).slice(0, 150)}`);
|
||||
await wait(1200);
|
||||
// 文本型必填(aliChoice 的「材质(Material)」是 input,不是 select):按标题里的材质词兜底
|
||||
const matHit = String(it.title || '').match(/plastic|cotton|polyester|stainless steel|metal|silicone|wood|resin|aluminum|alloy|fabric|nylon|glass|ceramic|leather/i);
|
||||
const matVals = [...new Set([matHit ? matHit[0] : null, 'Polyester', 'Other'].filter(Boolean))];
|
||||
const txtAttrs = await fillRequiredTextInputs(c, matVals);
|
||||
const t = String(it.title || '');
|
||||
const matHit = t.match(/plastic|cotton|polyester|stainless steel|metal|silicone|wood|resin|aluminum|alloy|fabric|nylon|glass|ceramic|leather/i);
|
||||
const colorHit = t.match(/black|white|pink|red|blue|green|beige|grey|gray|purple|yellow|brown|khaki|ivory|apricot|silver|gold|multicolou?r/i);
|
||||
// 按字段名给值:颜色别串成材质(曾把「颜色」填成 Resin)
|
||||
const valueFor = (name) => {
|
||||
if (/颜色|Color/i.test(name)) return colorHit ? colorHit[0] : 'Multicolor';
|
||||
if (/材质|Material/i.test(name)) return matHit ? matHit[0] : 'Polyester';
|
||||
if (/图案|Pattern/i.test(name)) return 'Solid';
|
||||
if (/尺寸|Size/i.test(name)) return 'Medium';
|
||||
return 'Other';
|
||||
};
|
||||
const txtAttrs = await fillRequiredTextInputs(c, valueFor);
|
||||
if (txtAttrs !== 'none') log(` 文本必填: ${String(txtAttrs).slice(0, 120)}`);
|
||||
await wait(1200);
|
||||
// 原生 <select>(SKU分类=单品单件、单位=件/个)——antd 选择器够不到
|
||||
const nat = await fillNativeSelects(c, ['单品单件', '件/个']);
|
||||
if (nat !== 'none') log(` 原生下拉: ${String(nat).slice(0, 120)}`);
|
||||
await wait(1200);
|
||||
log(` PC端描述: ${await fillDescription(c, (it.bullets || []).join('<br/>') || it.title)}`);
|
||||
await wait(1500);
|
||||
if (dry) { delete done[t.pid]; log(' ✓ dry 构建完成(未保存)'); await closePage(c); continue; }
|
||||
|
||||
Reference in new issue
Block a user