Explorar o código

fix: redirect with deploy on non-root path (#8141)

云深 %!s(int64=4) %!d(string=hai) anos
pai
achega
d9d8d4fa6e
Modificáronse 2 ficheiros con 4 adicións e 0 borrados
  1. 3 0
      src/models/login.ts
  2. 1 0
      src/typings.d.ts

+ 3 - 0
src/models/login.ts

@@ -49,6 +49,9 @@ const Model: LoginModelType = {
           const redirectUrlParams = new URL(redirect);
           if (redirectUrlParams.origin === urlParams.origin) {
             redirect = redirect.substr(urlParams.origin.length);
+            if (window.routerBase !== '/') {
+              redirect = redirect.replace(window.routerBase, '/');
+            }
             if (redirect.match(/^\/.*#/)) {
               redirect = redirect.substr(redirect.indexOf('#') + 1);
             }

+ 1 - 0
src/typings.d.ts

@@ -33,6 +33,7 @@ interface Window {
     fieldsObject: GAFieldsObject | string,
   ) => void;
   reloadAuthorized: () => void;
+  routerBase: string;
 }
 
 declare let ga: () => void;