pnpm dev访问:
http://127.0.0.1:8765/
先构建静态产物:
pnpm build再启动共享服务:
pnpm share查看你的 Mac 局域网 IP:
ipconfig getifaddr en0如果你连的是有线网,也可以试:
ipconfig getifaddr en1然后把下面这个地址发给同一网络内的其他人:
http://你的局域网IP:8765/
例如:
http://192.168.1.23:8765/
注意:共享服务只适合同一局域网或公司内网访问。SQL 格式化和字段解析都在访问者自己的浏览器里执行,不会把 SQL 发回服务器。
当前项目通过 GitHub Pages 对外发布,线上地址:
https://syxkira.github.io/local-sql-formatter/
仓库地址:
https://github.com/syxKira/local-sql-formatter
- 在 GitHub 创建仓库,例如:
syxKira/local-sql-formatter
- 本地初始化 Git 仓库并推送到 GitHub:
git init -b main
git add .
git commit -m "Set up SQL formatter app deployment"
git remote add origin git@github.com:syxKira/local-sql-formatter.git
git push -u origin main- 在 GitHub 仓库中打开 Pages 设置:
Settings -> Pages -> Build and deployment -> Source
选择:
GitHub Actions
- 项目已经内置 GitHub Pages 自动部署配置:
.github/workflows/deploy-pages.yml
推送到 main 分支后,GitHub Actions 会自动执行:
pnpm install --frozen-lockfile
pnpm build并把 dist/ 发布到 GitHub Pages。
- 部署成功后,在 Actions 页面可以看到
Deploy Pages成功记录:
https://github.com/syxKira/local-sql-formatter/actions
最终用户访问:
https://syxkira.github.io/local-sql-formatter/
每次修改代码后,只需要提交并推送:
git add .
git commit -m "Describe your change"
git pushGitHub Actions 会自动重新构建并发布,用户继续访问同一个 URL 即可使用最新版。
这个网页不依赖本地电脑运行。部署到 GitHub Pages 后,即使本机关闭,用户也可以继续访问。SQL 格式化和字段解析都在用户自己的浏览器中执行,不会把 SQL 发回服务器。