单应用项目,可以创建很多独立工具类页面 ,不用登录 初始化的页面
zhangchen
2025-09-24 3b2e941a83ad49d3167df864a5a06a81ef944470
src/utils/httpApi.ts
@@ -14,8 +14,9 @@
    message: string;
}
const apiBaseUrl = 'https://backend.ihemodialysis.com'; // 替换为你的API基础URL
// const apiBaseUrl = 'https://backend.ihemodialysis.com'; // 替换为你的API基础URL
// const apiBaseUrl = 'https://testbs.ihemodialysis.com'; // 替换为你的API基础URL
const apiBaseUrl = import.meta.env.VITE_API_BASE_URL;
export const setTimeoutAlert = async (requestData: SetTimeoutAlertRequest): Promise<ApiResponse> => {
    try {
@@ -29,4 +30,85 @@
        console.error('Error setting timeout alert:', error);
        throw error;
    }
};
};
export const sendValidateCode = async (requestData): Promise<ApiResponse> => {
    try {
        const response = await axios.post(`${apiBaseUrl}/user/info/sendValidateCodeForRegister`, requestData, {
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        });
        return response.data;
    } catch (error) {
        console.error('Error setting timeout alert:', error);
        throw error;
    }
};
export const registerForNutrition = async (requestData): Promise<ApiResponse> => {
    try {
        const response = await axios.post(`${apiBaseUrl}/user/info/registerForNutrition`, requestData, {
            headers: {
                'Content-Type': 'application/json'
            }
        });
        return response.data;
    } catch (error) {
        console.error('Error setting timeout alert:', error);
        throw error;
    }
};
/**
 * 停止定时任务
 * @param deviceCode
 * @returns
 */
export const stopTimeoutAlert = async (deviceCode: string) => {
    try {
        const response = await axios.post(`${apiBaseUrl}/patient/hemo/med/record/stopTimeoutAlert`, { deviceCode }, {
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        });
        return response.data;
    } catch (error) {
        throw error;
    }
}
/**
 * 获取副屏最新的版本号Api
 * @returns
 */
export const getServiceVersionApi = async(version: string) => {
    try {
        const response = await axios.post(`${apiBaseUrl}/system/version/subscreen/showVersionDiff`, { version }, {
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        });
        return response.data;
    } catch (error) {
        throw error;
    }
}
/**
 * 推出登录
 * @param deviceCode
 * @returns
 */
export const logoutForSubScreen = async(deviceCode: string) => {
    try {
        const response = await axios.post(`${apiBaseUrl}/user/info/logoutForSubScreen`, { deviceCode }, {
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        });
        return response.data
    } catch (error) {
        throw error;
    }
}