Posts

Implementation of Ajax Interceptor

Image
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 = XMLHttpRequest.prototype.open; let send = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.open = function () { requestCallback(); open.call(this, method, url); }; XMLHttpRequest.prototype.send = function () { //当Ajax的状态码改变时调用 this.addEventListener('readystatechange', function () { //请求成功时调用,也可设置别的状态码时调用的函数 if (this.readyState === 4 && this.status === 200) { //响应拦截器,返回有用的data let response = JSON.parse(this

axios完整二次封装及使用

Image
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

Image
                                                           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

Review of front-end assessment tasks——Spirited Away Introduction Webpage (can be used as an entry-level practice project)

Image
Table Of Contents Introduction When sorting out the files, I found a round of assessment projects when I entered the studio as a freshman. At that time, I only learned the front-end for more than a month. The code writing had many shortcomings, but I still missed it so I reviewed and improved it. This webpage is about the movie about Spirited Away. The design and writing of the webpage are all done by me, and the soundtrack is performed by myself. It can be used as homework for elective courses such as web design. video demo PS:只有使用翻墙软件才可查看视频 Partial display of the page code brief This webpage mainly uses HTML+CSS, and JS is used for the carousel part, and a JS encapsulation demo for manually realizing the carousel is uploaded The principle of js to realize the carousel map is mainly encapsulated with animation functions (the position of the box is constantly moved through the timer setInterval(), the function needs to pass 2 parameters, the animati

大学资料分享——广工计院各个科目实验报告、课设及期末复习资料!!

各位师弟师妹,我今年即将从广工毕业,因工作毕设都已差不多完成,整理资料时最终还是决定分享自己大学期间积累的各科资料。本人是广工计院一名本科生,在校绩点四年综合4.0左右,我相信这些资料对你们的学习和实验有非常大的实用性和价值。也真心希望大家能做好时间效率管理,一些不必要的课程不用浪费很多时间,把时间多留给自己所走的方向,希望各位师弟师妹好好利用我的资料,提升自己。如果本篇文章对你有帮助,请多来网站阅览并点击下页面的谷歌广告支持一下,十分感谢~~ 本博客除资源分享外还会 定期发布前端相关的行业动态、前端面试题系列等,后续也会逐步将自己的秋招总结发到谷歌博客上,同方向的师弟师妹们可以关注下,毕竟我也是在最寒冬秋招中获得好几个知名厂offer的,相信对你们将来的工作和面试也会非常实用 。 University special design: Specialised design IPV6 Experiment Report: GDUT IPV6 GDUT matlab digital signal processing experiment report: Matlab Experiment Report The latest operating system experiment and course design report: OS Experiment Report Virtualization and Cloud Computing-Hadoop Deployment Experiment Report: Hadoop Report GDUT C language programming experiment report 1-4: C language programming experiment report Summary of Physics Data of GDUT : Physics GDUT DEA experiment + big assessment (source code, waveform diagram) + test paper information: EDA Data summary of GDUT Electrician: University Ele

University special design

Image
 This project is designed as a WeChat applet, and the code has been tested and can be run directly. But currently only the source code is provided, and those who want the course design report can get it from me by contacting me. The content of the report generally includes background, demand analysis, overall design scheme, functional design, summary and experience, etc. The main function of this applet is Pomodoro clock plus schedule management, which can be used for programming related to self-discipline and other topics. The main design function of this applet is: by urging users to plan a few tasks to be completed today at the beginning of each day, focus on work within the optional range of 1~40 minutes of the Pomodoro clock until the end of the countdown, cooperate with memorandum schedule management, effective It solves the problems that users do not make a reasonable and clear time plan, the degree of completion of time arrangement is not high, and they cannot concentrate, so t

2022-Guangdong University of Technology Ipv6 Experiment

Image
The compressed file contains all the reports and project files of Ipv6 experiments and course design. However, due to the GNS3 software version problem, some project files may be opened incorrectly, but they can be submitted directly and the specific implementation code and process are given in the report. The specific experiment is: Experiment 1: Setting up the experimental environment (some teachers will not ask for this report) Experiment 2: Subnetting and Static Address Configuration Experiment 3: IPv6 Dynamic Address Allocation Experiment 4: IPv6 Routing Protocol Configuration Experiment 5: Transition from IPv4 to IPv6 Course design: A university has 4 campuses, and a new IPv6 network is built on the basis of the original IPv4 network I hope it will be helpful to all brothers and sisters OBTAIN LINK:https://pan.baidu.com/s/18dlU2zUepVQBM6O02Y0cyg CODE:h3fq

How to modify node_modules

 Why modify node_modules? In normal development, it is rarely necessary to change the code in node_modules, but there are many cases that need to be modified. For example, I encountered a scene last time, I used a middleware package for interface forwarding, but I encountered a problem: this package limits the uploaded file format But in fact, I want to let go of uploading all file formats, so I am forced to modify the code of this package in node_modules and let go of its restrictions, so as to achieve the effect I want, so how should I change it? This is a problem The first method: direct change This is easy to understand, just go directly to node_modules, find the code of that package, modify the code in the corresponding place, and then restart the project to achieve the effect I want. But in fact, this approach has too many disadvantages! 1. You can only use the code you modified locally, and your colleagues cannot use it 2. After the next npm i, the code of the package will be re