refactor: 主题系统 → monorepo 五个独立网站

- packages/core: @aidir/core 底座库(src/pages 页面组件体 1:1 镜像路由树 / kit 站点外壳工厂 / content/blog / scripts)
- sites/: 5 个独立 Next.js 网站(ai-stack / launchai / the-ai-ledger / devai-tools / findai)
  - 每站独立 package.json / next.config / tailwind / messages / .env / 构建
  - src/app 约 56 个薄路由文件(re-export 底座页面 + 内联路由段配置 revalidate/dynamic)
  - src/site/brand.tsx 站点配置 + src/site/home.tsx 站点首页(createMarketingLayout / createHomePage 工厂)
- generate-site.mjs: 站点生成器(新增网站 = SITES 加条目,零 Core 修改)
- start-all-sites.sh: 一键启动 3001-3005
- next-config.mjs: 底座统一 Next 配置工厂(next-intl + MDX + standalone)
- 五站共享同一套 PostgreSQL / Better Auth / Admin(设计文档 §42)
- 验证: 5 站 build OK / typecheck OK / 55 路由冒烟 200 / 品牌-内容-截图 差异确认 / 登录-投票-重复检测 e2e PASS
This commit is contained in:
AI Directory Platform
2026-09-08 19:19:33 +00:00
parent e46b4b52a3
commit 4a1a034386
699 changed files with 19829 additions and 2029 deletions
@@ -0,0 +1,63 @@
/**
* # 脚本 e2e-interaction
* 说明:端到端交互验证 —— 登录 → 投票(DB 前后对比)→ 重复提交检测。
* 在 monorepo 多站点架构下运行(共享同一套 Auth/DB)。
*/
import { chromium } from "playwright";
import postgres from "postgres";
const BASE = process.env.E2E_BASE || "http://localhost:3001";
const sql = postgres(
process.env.DATABASE_URL || "postgresql://postgres:postgres@127.0.0.1:15433/ai_directory",
{ prepare: false }
);
const results: string[] = [];
const browser = await chromium.launch();
const context = await browser.newContext({ viewport: { width: 1440, height: 900 } });
const page = await context.newPage();
const countClaudeVotes = async () =>
Number((await sql`SELECT COUNT(*) FROM vote WHERE tool_id='tool_claude'`)[0].count);
// 1) 登录
await page.goto(`${BASE}/login`, { waitUntil: "domcontentloaded" });
await page.fill('input[type="email"]', "bob@demo.dev");
await page.fill('input[type="password"]', "password123");
await page.click('button[type="submit"]');
await page.waitForTimeout(2500);
results.push(`1) 登录后 URL: ${page.url()}`);
await page.screenshot({ path: "/tmp/aidir-mono/e2e-after-login.png" });
results.push(`1b) 登录后用户菜单存在: ${await page.locator("header img, header button").count() > 0}`);
// 2) 投票 toggle(DB 前后对比)
const before = await countClaudeVotes();
await page.goto(`${BASE}/tools/claude`, { waitUntil: "domcontentloaded" });
await page.waitForTimeout(1500);
await page.screenshot({ path: "/tmp/aidir-mono/e2e-detail.png" });
const btnCount = await page.locator("button", { hasText: /Upvote|Upvoted/ }).count();
results.push(`2a) 找到投票按钮数: ${btnCount}`);
const btn = page.locator("button", { hasText: /Upvote|Upvoted/ }).first();
await btn.click();
await page.waitForTimeout(2500);
const after = await countClaudeVotes();
results.push(`2) 投票: DB ${before}→${after},按钮 "${((await btn.textContent()) ?? "").trim()}" → ${before !== after ? "PASS" : "FAIL"}`);
await btn.click();
await page.waitForTimeout(2500);
const restored = await countClaudeVotes();
results.push(`3) 取消投票: DB 回到 ${restored} → ${restored === before ? "PASS" : "FAIL"}`);
// 4) 重复提交检测
await page.goto(`${BASE}/submit`, { waitUntil: "domcontentloaded" });
await page.fill('input[placeholder="ChatGPT"]', "ChatGPT");
await page.fill('input[type="url"]', "https://chatgpt.com");
await page.locator('input[type="url"]').blur();
await page.waitForTimeout(1500);
const dupVisible = await page.locator("text=already be listed").count();
results.push(`4) 重复检测: ${dupVisible > 0 ? "PASS" : "FAIL"}`);
await page.screenshot({ path: "/tmp/aidir-mono/e2e-duplicate.png" });
await browser.close();
await sql.end();
console.log(results.join("\n"));