hyb
2026-01-30 15bc7727b58bf9ca0c8f21702fa893daac232b8d
测试组/Test_platform/Interface_automation/frontend/src/restful/api.js
@@ -10,15 +10,14 @@
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;
@@ -58,12 +57,6 @@
                        duration: 2000
                    });
                }
                if (status === 403) {
                    Message.error({
                        message: error.response.data.detail,
                        duration: 2000
                    });
                }
            } catch (e) {
                Message.error({
                    message: "服务器连接超时, 请重试",
@@ -77,6 +70,10 @@
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 => {
@@ -143,7 +140,7 @@
export const getGroupList = () => {
    return axios
        .get("/api/lunarlink/project/groups")
        .get("/api/user/groups")
        .then(res => res.data);
};
@@ -527,3 +524,31 @@
    }).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);
};