Showing posts from June, 2023

Implementation of Ajax Interceptor

Table Of Contents 1. 拦截器 拦截器的设置可以让我们在发出 request 或接到 response 之前做一些事情,例如改变 response的数据格式,或是根据不同 request 来添加不同的config 等。请求拦截器的即在请求发送前进行的操作,如设置是否需要token;响应拦截器的即接收到响应后进行操作,如通过状态码设置响应失败的跳转等 若对Ajax的基本使用还不熟悉推荐先看看博客: AJAX详解 2.原生AJAX实现拦截器 需要改变send方法, XMLHttpRequest.prototype.send 在其原型中重新定义了send函数。 const intercept = (method, url, requestCallback, responseCallback) => { let xhr = new XMLHttpRequest(); //修改原型的open和send方法来创建请求和响应拦截器 let open =; let send = XMLHttpRequest.prototype.send; = function () { requestCallback();, method, url); }; XMLHttpRequest.prototype.send = function () { //当Ajax的状态码改变时调用 this.addEventListener('readystatechange', function () { //请求成功时调用,也可设置别的状态码时调用的函数 if (this.readyState === 4 && this.status === 200) { //响应拦截器,返回有用的data let response = JSON.parse(this


Table Of Contents 在前端项目中网络请求的封装必不可少,最近重构了下项目axios的封装故进行记录 axios二次封装 import axios from "axios"; import router from "../router"; //看具体项目封装的路由文件修改 //跳转登陆页面 const toLogin = () => { router.replace({ path: "/login" }); }; //封装状态码错误处理函数 const errorHandle = status => { switch (status) { //登录不成功时跳转到登录页面 case 401: console.log("认证失败,未登录或无权限"); toLogin(); break; case 403: //token过期了,清除token存储 localStorage.removeItem("token"); console.log("token校验失败"); toLogin(); break; case 404: console.log("请求的资源不存在"); break; default: console.log("请求出错,状态码为:" + status); break; } }; // axios二次封装 const devBaseURL = "在开发环境下接口的baseURL"; const proBaseURL = "在生产环境下接口的baseURL"; //在vue的config文件夹下可以看开发环境和生产环境的名称,通常为development和production const baseURL = process.env.NODE_ENV === &

Review of 2023 front-end job hunting experience and summary of interview questions

 2022-2023 is a year when the IT industry will be severely impacted. The industry situation is: many companies have laid off employees, and many employees have lost their jobs... There are all kinds of talents on the market, from big factories, institutions, company closures, etc., looking for Work has become extraordinarily long. Front-end interview experience 1. The correct way to open a resume The correct way to open it is: First invest in small companies or companies that you don’t want to go to Review the interview questions and summarize the knowledge points Optimize your resume, and then apply for the one you want Continue to summarize the interview questions and review (this is very important!!!) 2.Interview questions: Prepare a self-introduction in English, the interviewer will really ask. (asked by the first interviewer) Ask a few basic questions about HTML and CSS. block-level elements inline elements, position these. Do you know BFC? (high frequency) Talk about JS array tra

Guanggong Network Security Experiment

                                                           CONTENT Including all experiments of the network security training system, the first release on the whole network! ! Attached are the 2020 Guanggong Network Security Exam Papers and Experimental Skills I tried 93 at the beginning, and now I have corrected all the mistakes, and the score will not be lower than my original score Cryptographic algorithm coding experiment: Virginia cipher coding experiment RSA encoding experiment DES coding experiment Certificate Service Management in Windows Environment Configuring Web-based SSL Connections in a Windows Environment Install and configure Kerberos under centos7 server Script and malicious webpage virus experiments Analysis experiment of network worm code PE virus experiment Trojan Analysis (Control Analysis) Experiment Trojan horse analysis (implantation analysis) experiment Windows 7 system log clearing experiment Basic experiment of filter table of Iptables Packet filtering