Files
Web_BAI_Manage_ApiServer/front-end/mock/controller/refreshToken.js
XuJiacheng 9a387f3eec feat: 初始化项目结构并添加基础配置
添加前后端基础项目结构,包括.gitignore、package.json等配置文件
实现前端基础功能模块,包括路由、状态管理、API请求封装等
添加前端UI组件库和样式体系
配置开发环境Mock系统和构建工具链
2026-03-18 14:03:35 +08:00

47 lines
1.4 KiB
JavaScript

const { Random } = require('mockjs')
module.exports = [
{
url: '/expireToken',
type: 'get',
response: (config) => {
const authorization =
config.headers.authorization || config.headers.Authorization
const arr = authorization.split('-')
const tokenTime = parseInt(arr[arr.length - 1])
if (Date.now() - tokenTime > 5000)
return {
code: 402,
msg: '令牌已过期',
}
else
return {
code: 200,
msg: '令牌未过期',
}
},
},
{
url: '/refreshToken',
type: 'get',
response: (config) => {
const authorization =
config.headers.authorization || config.headers.Authorization
let token = ''
if (authorization.includes('admin-token'))
token = `admin-token-${Random.guid()}-${Date.now()}`
if (authorization.includes('editor-token'))
token = `editor-token-${Random.guid()}-${Date.now()}`
if (authorization.includes('test-token'))
token = `test-token-${Random.guid()}-${Date.now()}`
return {
code: 200,
msg: '刷新Token成功',
data: { token },
}
},
},
]