瀏覽代碼

联登消息提醒

huiqi 19 小時之前
父節點
當前提交
1e098ce8b2
共有 1 個文件被更改,包括 20 次插入2 次删除
  1. 20 2
      app/components/home.tsx

+ 20 - 2
app/components/home.tsx

@@ -353,8 +353,26 @@ export function Home() {
   }, url: string, fullUrl: string) => {
     try {
       const res = await api.post('frame_login', data);
-      localStorage.setItem('userInfo', JSON.stringify(res.data));
-      location.replace(url);
+      console.log(res);
+      const resData = res?.data || {};
+      const msg = res.data.msg;
+      if(msg) {
+        Modal.error({
+          title: '登录信息',
+          content: msg,
+        });
+        // 延迟5秒执行存储和跳转
+        //setTimeout(() => {
+          // 存储前再次校验数据,避免 JSON.stringify 报错
+          if (resData) {
+            localStorage.setItem('userInfo', JSON.stringify(resData));
+          }
+          //location.replace(url);
+        //}, 5000);
+      } else {
+        localStorage.setItem('userInfo', JSON.stringify(resData));
+        //location.replace(url);
+      }
     } catch (error: any) {
       Modal.error({
         title: '登录失败',