getRedirectUrl.ts 681 B

1234567891011121314151617181920
  1. import { useGlobSetting } from '@/hooks/setting';
  2. const { loginApp, cbrainLoginApp, cbrainLoginClientId } = useGlobSetting();
  3. export const getRedirectUrl = () => {
  4. const encodeUrl = encodeURIComponent(window.location.href);
  5. return loginApp + '?redirect=' + encodeUrl;
  6. };
  7. export const getLogoutUrl = () => {
  8. if (!loginApp) return '';
  9. const encodeUrl = encodeURIComponent(location.pathname);
  10. return loginApp + `logout?redirect=${encodeUrl}`;
  11. };
  12. export const getCBrainRedirectUrl = (path?: string) => {
  13. const encodeUrl = encodeURIComponent(path || window.location.href);
  14. return cbrainLoginApp + '&client_id=' + cbrainLoginClientId + '&redirect_uri=' + encodeUrl;
  15. };