25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
chore(site): add static export preview script
t8y262fab080e852
diff --git a/docs/package.json b/docs/package.jsonindex 793c111288..219b67bf4b 100644--- a/docs/package.json+++ b/docs/package.json@@ -4,6 +4,7 @@"license": "Apache-2.0","scripts": {"dev": "next dev",+ "preview": "node scripts/preview-server.mjs","content:check": "node scripts/verify-doc-content.mjs","prebuild": "node scripts/verify-doc-content.mjs","build": "next build",diff --git a/docs/scripts/preview-server.mjs b/docs/scripts/preview-server.mjsnew file mode 100644index 0000000000..d73d34404c--- /dev/null+++ b/docs/scripts/preview-server.mjs@@ -0,0 +1,66 @@+// Local preview for the static export, mimicking Cloudflare Workers asset+// resolution: exact file first, then /foo -> /foo.html, then /foo/ ->+// /foo/index.html, and unknown paths fall back to 404.html like+// not_found_handling: "404-page". Run `pnpm build` before this script.+//+// Usage: node scripts/preview-server.mjs [port]+import { createServer } from "node:http";+import { readFile, stat } from "node:fs/promises";+import { extname, join, resolve } from "node:path";++const ROOT = resolve(import.meta.dirname, "../out");+const PORT = Number(process.argv[2] ?? 3000);+const types = {+ ".html": "text/html; charset=utf-8",+ ".js": "text/javascript",+ ".css": "text/css",+ ".txt": "text/plain",+ ".png": "image/png",+ ".svg": "image/svg+xml",+ ".webp": "image/webp",+ ".json": "application/json",+ ".xml": "application/xml",+ ".ico": "image/x-icon",+ ".map": "application/json",+ ".woff2": "font/woff2",+};++async function tryFile(rel) {+ const file = join(ROOT, rel);+ try {+ const info = await stat(file);+ if (!info.isFile()) return null;+ return { file, type: types[extname(file)] ?? "application/octet-stream" };+ } catch {+ return null;+ }+}++createServer(async (req, res) => {+ try {+ const path = decodeURIComponent(new URL(req.url, "http://localhost").pathname);+ if (path.includes("..")) {+ res.writeHead(400);+ return res.end();+ }+ const hit =+ (await tryFile(path)) ??+ (path.endsWith("/") ? await tryFile(join(path, "index.html")) : await tryFile(`${path}.html`));+ if (hit) {+ res.writeHead(200, { "content-type": hit.type, "cache-control": "no-store" });+ return res.end(await readFile(hit.file));+ }+ const fallback = await tryFile("404.html");+ if (fallback) {+ res.writeHead(404, { "content-type": fallback.type, "cache-control": "no-store" });+ return res.end(await readFile(fallback.file));+ }+ res.writeHead(404, { "content-type": "text/plain" });+ res.end("404");+ } catch (error) {+ res.writeHead(500);+ res.end(String(error));+ }+}).listen(PORT, () => {+ console.log(`Preview serving ${ROOT} at http://localhost:${PORT}`);+});