Explorar o código

feat: 优化登录流程

bill hai 3 meses
pai
achega
187fcd8198
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  1. 5 2
      src/example/fuse/enter.ts

+ 5 - 2
src/example/fuse/enter.ts

@@ -64,9 +64,12 @@ const postFile = (url: string, data: Record<string, any>) => {
 
 const login = (isBack = true) => {
   if (import.meta.env.VITE_LOGIN_VIEW) {
+    const curUrl = new URL(location.href)
+    curUrl.searchParams.delete('token')
+
     const link = isBack
       ? tempStrFill(import.meta.env.VITE_LOGIN_VIEW, {
-          redirect: escape(location.href),
+          redirect: escape(curUrl.toString()),
         })
       : import.meta.env.VITE_LOGIN_VIEW;
     const url = new URL(link)
@@ -79,7 +82,7 @@ const login = (isBack = true) => {
 
 const after = async (fet: Promise<Response>) => {
   const res = await fet.then((res) => res.json());
-  if (res.code === 4008) {
+  if ([4008, 4010].includes(res.code)) {
     setTimeout(() => {
       login();
     }, 1000);