first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
## 问题记录
1routing-controllers 的坑 1
Bug: 使用注解 @Render 渲染模板后,第二次访问其他页面但是展示效果还是上次的页面,页面不进行渲染
原因: 1action.renderedTemplate 被放入js闭包中, 一旦中间件初始化,视图将永远不会改变。
2根本原因在于框架的开发者团队对koa2不熟悉。
路径node_modules/_routing-controllers@0.7.7@routing-controllers/driver/koa/KoaDriver.js
行数249行
解决: 增加代码使用 options.response.render强制渲染模板
return options.response.render(action.renderedTemplate, renderOptions_1);
注意: 插件开发者已经解决该问题,但开发者未合并修改到主分支
所以 `yarn add routing-controllers` 下载下来的还是有Bug的代码需要自己手动修改插件源码
Github 问题反馈地址https://github.com/typestack/routing-controllers/pull/434
Github 修复分支记录https://github.com/typestack/routing-controllers/pull/434/files/001b45a416e3f1dbde33e7e91fadb09111d4061d
2routing-controllers 的坑 2
虽然按照上面方法暂时解决了问题但是当我在前端页面和api数据之间进行来回访问api接口界面会从正常变为前端模板页面问题依旧存在
作者没有时间继续维护项目其他开发者解决了这个github commit 提交记录的地址:
https://github.com/typestack/routing-controllers/pull/434/commits/001b45a416e3f1dbde33e7e91fadb09111d4061d
解决:删除框架中 249行渲染代码只保留 [坑1] 中添加的代码即可。
建议:下载 routing-controllers 的 typescript 源码修改源码编译后上传到自己的npm市场
防止每次解决依赖后都需要重新修改框架源码,编译有难度和坑..mmp.....