Half Pencil用户说得对。我之前的改法是全局替换 ../assets/ → ./assets/,这太暴力了。如果业务代码里恰好有 ../assets/ 这样的字符串字面量(比如某个
硬编码路径),也会被误改。无法区分「真正的资源引入」和「恰巧相同的业务字符串」。
就这个案例,不能怪我指令下的不对,AI的解决方案是字符串替换。能解决吗? 能, 有问题吗? 有。
const auth = G.headers().bind(headers => {
// TODO 认证
return G.pure(void 0)
})
const get = G.get().semiBind(G.pureText("get"))
const post = G.post().semiBind(G.pureText("post"))
const del = G.delete().semiBind(G.pureText("delete"))
// 所有不需要鉴权的路由
const pubRoute = G.path("/pub").semiBind(G.alts(
G.exactPath("/one/:a").bind(params => G.pureJson(params)),
G.exactPath("/two/:a").bind(params => G.pureJson(params)),
))
// 需要鉴权的路由
const authRoute = auth.semiBind(
get.alt(post).alt(del)
)
export const api = G.path("/api").semiBind(
pubRoute.alt(authRoute)
)
自己设计的,自己用,自己难受。
Half Pencilconst auth = G.headers().bind(headers => {
// TODO 认证
return G.pure(void 0)
})
const get = G.get().semiBind(G.pureText("get"))
const post = G.post().semiBind(G.pureText("post"))
const del = G.delete().semiBind(G.pureText("delete"))
// 所有不需要鉴权的路由
const pubRoute = G.path("/pub").semiBind(G.a
链接
点击显示
点击显示
看起來很像是 https://elysiajs.com/ 的設計
const server = serve({
routes: {
// Serve index.html for all unmatched routes.
"/*": index,
"/api/*": req=> {
return api.runWith404(req)
}
},
development: process.env.NODE_ENV !== "production" && {
// Enable browser hot reloading in development
hmr: true,
// Echo console logs from the browser to the server
console: true,
},
});
链接
点击显示
点击显示
https://github.com/diqye/piko
vibe coding 了一个 胶囊 App, 19M 。 秒打开。
我只搭好了环境(vibe 或者 通过npx init搭建的环境太拉跨), 定好了文件规则,其它都是pi coding 做的。