Browse Source

1.优化登录

armg 4 days ago
parent
commit
f46012b30d

+ 2 - 2
src/main.ts

@@ -50,10 +50,10 @@ Vue.component('el-collapse', ElCollapse);
 Vue.component('el-collapse-item', ElCollapseItem);
 Vue.component('el-image', ElImage);
 // 引入并初始化 vConsole(仅在非生产环境启用,避免线上暴露调试工具)
-// if (process.env.NODE_ENV !== 'production') {
+if (process.env.NODE_ENV !== 'production') {
   const VConsole = require('vconsole')
   new VConsole() // 初始化后,移动端页面会出现 vConsole 悬浮按钮
-// }
+}
 import {
   Swipe,
   SwipeItem,

+ 2 - 0
src/router/index.ts

@@ -86,6 +86,7 @@ const router = new VueRouter({
 });
 // 全局前置守卫:只对需要登录的页面进行登录校验
 router.beforeEach((to, from, next) => {
+  // console.log("-------页面链接=", window.location.href)
   if (!to.meta || (to.meta && !to.meta.requiresAuth)) {
     next();
     return;
@@ -101,6 +102,7 @@ router.beforeEach((to, from, next) => {
     if (code) {
       doWecomLogin(code)
         .then(() => {
+          next();
           console.log(`登录成功,即将进入 ${to.path}`);
         })
         .catch(() => {

+ 4 - 2
src/utils/requestAI.js

@@ -49,10 +49,12 @@ service.interceptors.response.use(res => {
     } else if (code === 420) {
         window.localStorage.clear();
         let url, appid, agentid;
-        url = encodeURIComponent(process.env.VUE_APP_AUTHURL);
+        // url = encodeURIComponent(process.env.VUE_APP_AUTHURL);
+        url = encodeURIComponent(window.location.href);
         appid = process.env.VUE_APP_APPID;
         agentid = process.env.VUE_APP_AGENTID;
-        window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${url}&response_type=code&scope=snsapi_base&state=&agentid=${agentid}#wechat_redirect&t=${new Date().getTime()}`;
+        // console.log("--url=",url)
+        window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${url}&response_type=code&scope=snsapi_base&state=&agentid=${agentid}&&t=${new Date().getTime()}#wechat_redirect`;
     } else if (code !== 200 && code !== 204) {
         Toast(msg);
         return Promise.reject('error')

+ 5 - 4
src/utils/wecomLogin.ts

@@ -60,7 +60,6 @@ export const initGuidInfo = (): void => {
         // 无缓存-存储
         window.localStorage.setItem('guidInfo', JSON.stringify(newGuidInfo));
     }
-    console.log("guidInfo=", window.localStorage.getItem('guidInfo'))
 };
 /**
  * 企业微信登录核心流程(获取 code → 兑换 AIToken)
@@ -91,8 +90,9 @@ export const doWecomLogin = async (code: string): Promise<void> => {
             // 登录成功:存储 AIToken
             window.localStorage.setItem('AIToken', res.Data.token);
             isLogging = false;
+            // console.log("router.currentRoute.fullPath=",router.currentRoute.fullPath)
             // 重新跳转目标页面(此时登录状态已满足)
-            router.push(router.currentRoute.fullPath);
+            // router.push(router.currentRoute.fullPath);
         } else if (res.StatusCode === 403) {
             // 无权限 → 跳错误页
             isLogging = false;
@@ -124,9 +124,10 @@ export const getGuid = () => {
 }
 export const getQyCode = () => {
     let url, appid, agentid;
-    url = encodeURIComponent(process.env.VUE_APP_AUTHURL);
+    // url = encodeURIComponent(process.env.VUE_APP_AUTHURL);
+    url = encodeURIComponent(window.location.href);
     appid = process.env.VUE_APP_APPID;
     agentid = process.env.VUE_APP_AGENTID;
-    
+
     window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${url}&response_type=code&scope=snsapi_base&state=&agentid=${agentid}&t=${new Date().getTime()}#wechat_redirect`;
 }

+ 6 - 2
src/views/AIDesign/design.vue

@@ -1042,11 +1042,15 @@ export default class extends Vue {
           this.GetEntityData(this.$route.query.F_id);
         }
       } else {
-        that.$toast(response.Info)
+        if(response.Info){
+          that.$toast(response.Info)
+        }
         console.log(response.Info);
       }
     }).catch((err) => {
-      that.$toast(err)
+      // if(err){
+      //   that.$toast(err)
+      // }
     })
   }
 

+ 3 - 1
src/views/AIDesign/insideDesign.vue

@@ -517,7 +517,9 @@ export default class extends Vue {
       } else {
         that.projectActionLoadingShow = false;
         that.AIBtnDisabled = false;
-        that.$toast(response.Info);
+        if(response.Info){
+          that.$toast(response.Info);
+        }
       }
     })
       .catch((err) => {