Skip to content

12 个视觉参考图库与浏览器无限画布 AI 创作台(5,700+ 素材、中英提示词、多图对比、ComfyUI & MCP)· Visual reference library & infinite-canvas AI studio in the browser

734 B
Raw Blame
// Serve the real source UI with fixture catalogs. No preview process or network is needed.
const fs = require('node:fs');
const path = require('node:path');

const origin = 'http://posewear.test';
const source = path.resolve(__dirname, '../../src');

function serveSite(catalogs = {}) {
  return route => {
    const url = new URL(route.request().url());
    if (url.origin !== origin) return route.abort();
    const name = url.pathname.slice(1) || 'index.html';
    if (name.endsWith('.json')) return route.fulfill({json:catalogs[name] || []});
    const file = path.join(source,name);
    return fs.existsSync(file) ? route.fulfill({path:file}) : route.fulfill({status:404,body:''});
  };
}

module.exports = {origin, serveSite};