| | |
| | | |
| | | axios.interceptors.request.use( |
| | | function(config) { |
| | | if ( |
| | | !config.url.startsWith("/api/user") || |
| | | config.url === "/api/user/list" || |
| | | config.url === "/api/user/login_log" |
| | | ) { |
| | | // 在请求拦截中,每次请求,都会加上一个Authorization头 |
| | | const noAuthUrls = [ |
| | | '/api/user/login', |
| | | '/api/user/register', |
| | | '/api/user/groups' |
| | | ]; |
| | | |
| | | if (!noAuthUrls.includes(config.url)) { |
| | | config.headers.Authorization = store.token; |
| | | |
| | | // 取url地址的第四位作为projectId, 如果不存在,默认设置为0 |
| | | let projectId = window.location.pathname.split("/")[3]; |
| | | projectId = projectId ? projectId : 0; |
| | | config.headers["Project"] = projectId; |
| | |
| | | duration: 2000 |
| | | }); |
| | | } |
| | | if (status === 403) { |
| | | Message.error({ |
| | | message: error.response.data.detail, |
| | | duration: 2000 |
| | | }); |
| | | } |
| | | } catch (e) { |
| | | Message.error({ |
| | | message: "服务器连接超时, 请重试", |
| | |
| | | |
| | | export const login = params => { |
| | | return axios.post("/api/user/login", params).then(res => res.data); |
| | | }; |
| | | |
| | | export const register = params => { |
| | | return axios.post("/api/user/register", params).then(res => res.data); |
| | | }; |
| | | |
| | | export const addProject = params => { |
| | |
| | | export const getProjectYapiInfo = pk => { |
| | | return axios |
| | | .get("/api/lunarlink/project/yapi/" + pk) |
| | | .then(res => res.data); |
| | | }; |
| | | |
| | | export const getGroupList = () => { |
| | | return axios |
| | | .get("/api/user/groups") |
| | | .then(res => res.data); |
| | | }; |
| | | |
| | |
| | | }).then(res => res.data); |
| | | }; |
| | | |
| | | export const getUserManagementList = (params) => { |
| | | return axios.get("/api/user/management/", { params }).then(res => res.data); |
| | | }; |
| | | |
| | | export const createUser = (data) => { |
| | | return axios.post("/api/user/management/", data).then(res => res.data); |
| | | }; |
| | | |
| | | export const updateUser = (userId, data) => { |
| | | return axios.patch(`/api/user/management/${userId}/`, data).then(res => res.data); |
| | | }; |
| | | |
| | | export const deleteUser = (userId) => { |
| | | return axios.delete(`/api/user/management/${userId}/`).then(res => res.data); |
| | | }; |
| | | |
| | | export const getUserDetail = (userId) => { |
| | | return axios.get(`/api/user/management/${userId}/`).then(res => res.data); |
| | | }; |
| | | |
| | | export const getUserApprovalList = (params) => { |
| | | return axios.get("/api/user/approval/", { params }).then(res => res.data); |
| | | }; |
| | | |
| | | export const approveUser = (userId, data) => { |
| | | return axios.post(`/api/user/approval/${userId}/approve/`, data).then(res => res.data); |
| | | }; |
| | | |