/**
 * 因 ts 不鼓励写全局变量，鼓励用模块系统
 * 故，全部请求服务地址统一存放在 serviceURL 这个对象中
 *
 * 使用例子：
 * import { serviceURL } from '@/services/request/serviceURL';
 *
 * serviceURL.commSearchUrl
 */

interface URL {
    commSearchUrl: string;
    goCommonSearchUrl: string;
    hsbyBankSignZone: string;
    hsbyPayUrlWeb: string;
    hsbyRegister: string;
    hsbySignUp: string;
    mobileAuthUrl: string;
    mobileOpenUrl: string;
    newsUrl: string;
    openApiUrl: string;
    quoteHost: string;
    quotePort: string;
    quoteUrl: string;
    tradeHost: string;
    tradePort: string;
    tradeUrl: string;
    uploadUrl: string;
    iOS: string;
    android: string;
    pcNewsUrl: string;
    pcMangerUrl: string;
    oem: string;
}

export let serviceURL: URL = {
    commSearchUrl: '',
    goCommonSearchUrl: '',
    hsbyBankSignZone: '',
    hsbyRegister: '',
    hsbyPayUrlWeb: '',
    hsbySignUp: '',
    mobileAuthUrl: '',
    mobileOpenUrl: '',
    newsUrl: '',
    openApiUrl: '',
    quoteHost: '',
    quotePort: '',
    quoteUrl: '',
    tradeHost: '',
    tradePort: '',
    tradeUrl: '',
    uploadUrl: '',
    oem: '',
    iOS: '',
    android: '',
    pcNewsUrl: '',
    pcMangerUrl: '',
};

/**
 * go 通用查询地址模板
 * @param url
 */
export const goCommonSearchUrl = (url: string): string => {
    return serviceURL.goCommonSearchUrl + url;
};

/**
 * 管理端查询地址模板
 * @param url
 */
export const commonSearchUrl = (url: string): string => {
    return serviceURL.commSearchUrl + url;
};

export const getUplodaUrl = (): string => {
    return serviceURL.uploadUrl
}

export const setServiceURL = (config: URL): void => {
    // console.log('URL', config);
    //外网环境（175），外包同事使用
    serviceURL = config;
    // if (process.env.NODE_ENV === 'development') {
    //     serviceURL.goCommonSearchUrl = 'http://218.17.158.45:21001/api';
    //     serviceURL.quoteUrl = 'ws://218.17.158.45:21004';
    //     serviceURL.tradeUrl = 'ws://218.17.158.45:21005';
    // }
    console.log('api地址：', serviceURL);
};