debug_furniture_business_categories.js 1.6 KB

1234567891011121314151617181920212223242526272829
  1. const { chromium } = require('playwright');
  2. (async () => {
  3. const browser = await chromium.launch({ headless: true, executablePath: 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe' });
  4. const page = await browser.newPage({ viewport: { width: 1365, height: 900 } });
  5. const errors = [];
  6. page.on('pageerror', error => errors.push(error.message));
  7. await page.goto('http://127.0.0.1:8931/AI%E5%BF%AB%E9%80%9F%E6%8A%A5%E4%BB%B7_Demo2.html?v=business-category-test', { waitUntil: 'load' });
  8. const result = await page.evaluate(() => {
  9. const names = category => [...document.querySelectorAll('.q-furniture-category[data-category="' + category + '"] .q-furniture-tool')]
  10. .map(el => el.dataset.furnitureType);
  11. const standard = qGetCabinetPricingRule({ cabinetType: '餐边柜' }, 2, 2.4);
  12. const master = qGetCabinetPricingRule({ cabinetType: '主卧衣柜' }, 2, 2.4);
  13. const kitchen = qGetCabinetPricingRule({ cabinetType: '厨房' }, 4, 2.4);
  14. const highCabinet = qGetCabinetPricingRule({ cabinetType: '厨房', kitchenItem: '高柜' }, 2, 2.4);
  15. return {
  16. wardrobe: names('wardrobe'),
  17. cabinet: names('cabinet'),
  18. standard,
  19. master,
  20. kitchen,
  21. highCabinet,
  22. allKitchenLinear: DEFAULT_RULES.kitchen.every(rule => rule.method === '按延米' && rule.unit === '元/m'),
  23. legacyPackageRules: DEFAULT_RULES.kitchen.filter(rule => /套餐|超3米/.test(rule.name)).map(rule => rule.name)
  24. };
  25. });
  26. console.log(JSON.stringify({ ...result, errors }));
  27. await browser.close();
  28. })().catch(error => { console.error(error); process.exit(1); });