//WAF 验证码seqid相关正则const sig_data = /seqid\\s=\\s"(\\w+)"/gconst waf_id_data = /TencentCaptcha\\((\\'\\d+\\')/gconst service = axios.create({baseURL: '/api',timeout: 10000,withCredentials: true});service.interceptors.response.use((response)=>{const res = response.data;if(res.code === 0){return res;}else{//捕捉错误及渲染验证码const matches = sig_data.exec(res);if(matches){//展示验证码let seqid = matches[1];const wid_matches = waf_id_data.exec(res);let wid = wid_matches[1]var captcha = new TencentCaptcha(wid, function(res){var captchaResult = []captchaResult.push(res.ret)if(res.ret === 0){captchaResult.push(res.ticket)captchaResult.push(res.randstr)captchaResult.push(seqid)}var content = captchaResult.join('\\n')axios.post("/WafCaptcha",content).then().catch();});captcha.show()}else{return res;}}},()=>{});export default service;Vue.prototype.$axios = service;
getTopic:function(){this.$axios.get("/api.php").then(res => {this.topic = res});}
<script src="https://ssl.captcha.qq.com/TCaptcha.js"></script>。<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1.0"><link rel="icon" href="<%= BASE_URL %>favicon.ico"><title><%= htmlWebpackPlugin.options.title %></title></head><body><noscript><strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><script src="https://ssl.captcha.qq.com/TCaptcha.js"></script><div id="app"></div><!-- built files will be auto injected --></body></html>

文档反馈