appfun.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import ENV_CONFIG from "@/config.json";
  2. import tokenInfo from '@/stores/modules/token';
  3. const tokenInfoStore = tokenInfo();
  4. import configInfo from "@/stores/modules/config";
  5. //获取文件路径
  6. export function getFilePath (file_path){
  7. if(file_path) return file_path;
  8. return null
  9. }
  10. //获取路由地址
  11. export function getRouterUrl (href){
  12. return window.location.origin+window.location.pathname+href
  13. }
  14. //获取TKK地址
  15. export function getWebUrlrUrl (config:{
  16. url:string,
  17. query:Object
  18. }){
  19. const useConfigInfoStore = configInfo();
  20. let env = useConfigInfoStore.appConfig.env
  21. const tkkWebUrl = ENV_CONFIG[env]?.tkkWebUrl || 'https://tkk.valimart.net';
  22. let params = '?source=camera&token=' + tokenInfoStore.getToken
  23. if(config.query){
  24. params += '&'
  25. params += Object.keys(config.query).map(key => {
  26. return encodeURIComponent(key) + '=' + encodeURIComponent(config.query[key])
  27. }).join('&')
  28. }
  29. let url = tkkWebUrl + config.url + params
  30. return url
  31. }