Skip to content

TimeTrain

前端向后端发送验证码请求的流程: 调用 getCaptcha 函数: 当调用 getCaptcha 函数时,它会进一步调用在另一个文件中定义的 captcha 函数。 1const getCaptcha = () => { 2 captcha().then((res:any) => { ... }); 3}; 发送 HTTP 请求: 在 captcha 函数中,它使用 request 函数(由 axios 实例提供)向服务器发送一个 GET 请求。 1export function captcha(){ 2 return request({ 3 url:"/api/v1/pub/captcha/get", 4 method:"get" 5 }); 6} 请求拦截: 在发送请求之前,axios 的请求拦截器会被触发。如果在 Session 中存 Read more

storage.ts 整体分析 这个 utils/storage.ts 文件提供了两个模块:Local 和 Session,分别封装了 window.localStorage 和 window.sessionStorage 的常用方法。这两个对象是HTML5提供的,允许你在用户的浏览器中存储键/值对。 让我们详细分析一下: 1. Local 这部分封装了浏览器的 localStorage 方法,它允许网页存储键值对在一个永久的地方,这些数据会保留在浏览器关闭后仍然存在。 set: 保存一个值到 Read more