
import ENV_CONFIG from "@/config.json";
import tokenInfo from '@/stores/modules/token';
const tokenInfoStore = tokenInfo();
import configInfo from "@/stores/modules/config";

//获取文件路径
export  function getFilePath (file_path){
    if(file_path) return file_path;
    return null
}


//获取路由地址
export  function getRouterUrl (href){
    return window.location.origin+window.location.pathname+href
}



//获取TKK地址
export  function getWebUrlrUrl (config:{
    url:string,
    query:Object
}){

    const useConfigInfoStore = configInfo();
    let env =  useConfigInfoStore.appConfig.env
    const tkkWebUrl = ENV_CONFIG[env]?.tkkWebUrl || 'https://tkk.valimart.net';


    let params = '?source=camera&token=' + tokenInfoStore.getToken
    if(config.query){
        params +=  '&'
        params += Object.keys(config.query).map(key => {
            return encodeURIComponent(key) + '=' + encodeURIComponent(config.query[key])
        }).join('&')
    }
    let url  = tkkWebUrl + config.url + params
    return url
}
