当前位置:网站首页>egg-swagger-doc 图形验证码解决方案
egg-swagger-doc 图形验证码解决方案
2022-07-27 12:52:00 【雪狼之夜】
序:
应该不只一个人卡到这个bug,egg-swagger-doc的作者github也停更好些日子了,demo里也没找到对应的api,无奈,博主只能去解剖egg-swagger-doc的依赖文件了。但是如果二维码都出不来,swagger基本就变成了摆设,毫无意义,所以没办法,博主还是对依赖包进行了修改
博主原创, 说实话,博主这花了72个小时才调试出这个,如果你生活收入还可以的话,打赏下呗。
博主egg配置和版本如下:
1、"egg": "^2.15.1",
2、 "egg-swagger-doc": "^2.3.2",
3、"captchapng": "^0.0.1",//这玩意是生成图片base64的验证码
先看最终效果 ,如图

博主请求接口/api/verify
返回格式
{
code:"200",
data: "data:image/png;base64,iVBORw0KGgoA......",//这里就是你的base64图片了
msg: "查询成功"
}
解决方案
打开路径:/node_modules/app/swagger-ui-bundle.js

对里面验证方法进行修改就可以了。
位置在下面代码
}, "Unrecognized response type; unable to display.") : null之后加入
if(e.url.indexOf("/api/verify")!=-1){
g=l.default.createElement("img", {
style: {
maxWidth: "100%",
backgroundColor:"#fff"
},
src:JSON.parse(e.content).data
})
};就可以了。

博主原创, 说实话,博主这花了72个小时才调试出这个,如果你生活收入还可以的话,打赏下呗。
边栏推荐
猜你喜欢

for .. of可用于哪些数据的遍历

【C进阶】指针数组 VS 数组指针

MFC FTP creates multi-level folders and uploads files to the specified directory of FTP

赋能金融风控加分项的这30个问题,您都搞懂了吗

How to debug JNI program

Classification and application of slip rings

Evconnlistener of libevent_ new_ bind

OPPO 自研大规模知识图谱及其在数智工程中的应用

Fiddler抓包工具+夜神模拟器

Seata's landing practice in ant International Banking
随机推荐
libevent 之 evconnlistener_new_bind
Interviewers often ask: how to set up a "message queue" and "delayed message queue"?
滑环设备怎么进行维护
2022年7月24日 暑假第二周训练
SCI thesis writing
滑环使用如何固定
Can you tell me the difference between lateinit and lazy in kotlin?
Height collapse and BFC
网络异常流量分析系统设计
Seata 在蚂蚁国际银行业务的落地实践
MTK6765编译环境搭建
evutil_make_internal_pipe_: pipe: Too many open files
Method of changing thread state
纵横靶场-图片的奥秘
元素的层级
高度塌陷和BFC
Set up SSH key based authentication using putty
js基础知识整理之 —— 数组
电滑环的常用类型
V-on basic instruction