function GetCurHost() {
    let searchParams = new URLSearchParams(globalThis.location?.search);
    if (searchParams.has("server"))
        return searchParams.get("server");
    else {
        let hostname = globalThis.location?.hostname;
        switch (hostname) {
            case "cfcad.cn":
            case "www.cfcad.cn":
                return "https://api.cfcad.cn";
            case "vip.cfcad.cn":
                return "https://vapi.cfcad.cn";
            case "v.cfcad.cn":
                return "https://vapi.cfcad.cn";
            case "t.cfcad.cn":
                return "https://tapi.cfcad.cn:7779";
            case "tvip.cfcad.cn":
                return "https://tvapi.cfcad.cn:7779";
            case "tv.cfcad.cn":
                return "https://tvapi.cfcad.cn:7779";
            default:
                return "https://tapi.cfcad.cn:7779";
        }
    }
}

export const CURRENT_HOST = GetCurHost();
export const ImgsUrl = {
    get: CURRENT_HOST + "/CAD-imageList",
    upload: CURRENT_HOST + "/CAD-imageUpload",
    delete: CURRENT_HOST + "/CAD-imageDelete",
    logo: CURRENT_HOST + "/CAD-logoUpload",
    update: CURRENT_HOST + "/CAD-imageUpdate"
};
export const MaterialUrls = {
    query: CURRENT_HOST + "/CAD-materialList",
    create: CURRENT_HOST + "/CAD-materialCreate",
    get: CURRENT_HOST + "/CAD-materialList",
    detail: CURRENT_HOST + "/CAD-materialDetail",
    delete: CURRENT_HOST + "/CAD-materialDelete",
    update: CURRENT_HOST + "/CAD-materialUpdate",
    move: CURRENT_HOST + "/CAD-materialMove",
    buy: CURRENT_HOST + "/Materials-openList",
    publishDetail: CURRENT_HOST + "/CAD-materialPublicDetail",
};