Przeglądaj źródła

feat:新增多租户登录退出逻辑

韩帛霖 1 rok temu
rodzic
commit
3c69d6f94a

+ 26 - 16
zkqy-ui/src/layout/index.vue

@@ -5,7 +5,7 @@
       <el-row>
         <el-col :span="12">
           <div class="logo-title">
-            <img :src="logo" alt="" class="imgg" />
+            <img :src="logo" alt="" class="imgg"/>
             <span class="title">{{ title }}</span>
             <!-- <img src="../assets/images/comlo.png" alt="" class="imgg" /> -->
           </div>
@@ -16,7 +16,7 @@
             trigger="click"
           >
             <div class="avatar-wrapper">
-              <img :src="avatar" class="user-avatar" />
+              <img :src="avatar" class="user-avatar"/>
               <span style="">
                 <button class="jianbiase">{{ username || "默认用户" }}</button>
               </span>
@@ -60,11 +60,11 @@
       >
         <div :class="{ 'fixed-header': fixedHeader }">
           <!-- <navbar /> -->
-          <tags-view v-if="needTagsView" />
+          <tags-view v-if="needTagsView"/>
         </div>
-        <app-main />
+        <app-main/>
         <right-panel>
-          <settings />
+          <settings/>
         </right-panel>
       </div>
     </div>
@@ -72,15 +72,14 @@
 </template>
 
 <script>
-import { mapGetters } from "vuex";
+import {mapGetters} from "vuex";
 import RightPanel from "@/components/RightPanel";
-import { AppMain, Navbar, Settings, Sidebar, TagsView } from "./components";
+import {AppMain, Navbar, Settings, Sidebar, TagsView} from "./components";
 import ResizeMixin from "./mixin/ResizeHandler";
-import { mapState } from "vuex";
+import {mapState} from "vuex";
 import variables from "@/assets/styles/variables.scss";
-import meclogo1 from "@/assets/images/mec-logo1.svg";
 import mecLogoLogin from "@/assets/images/mec-logo-login.svg";
-import comp from "@/assets/images/comp.svg";
+
 export default {
   name: "Layout",
   components: {
@@ -108,6 +107,7 @@ export default {
       needTagsView: (state) => state.settings.tagsView,
       fixedHeader: (state) => state.settings.fixedHeader,
       username: (state) => state.user.name,
+      tenantInfo: (state) => state.user.tenant,
       ...mapGetters(["avatar"]),
     }),
     classObj() {
@@ -135,20 +135,23 @@ export default {
   },
   methods: {
     async logout() {
+      // this.tenantInfo.tenantClientLoginUrl 退出登录后跳转到登录页面
       this.$confirm("确定注销并退出系统吗?", "提示", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
         type: "warning",
       })
         .then(() => {
+          let tenantCode = this.tenantInfo.tenantCode;
           this.$store.dispatch("LogOut").then(() => {
-            location.href = "/index";
+            this.$router.push({path: "/login", query: {tenantCode: tenantCode}});
           });
         })
-        .catch(() => {});
+        .catch(() => {
+        });
     },
     handleClickOutside() {
-      this.$store.dispatch("app/closeSideBar", { withoutAnimation: false });
+      this.$store.dispatch("app/closeSideBar", {withoutAnimation: false});
     },
     getlogo() {
       let logo = sessionStorage.getItem("logo");
@@ -173,6 +176,7 @@ export default {
 <style lang="scss" scoped>
 @import "~@/assets/styles/mixin.scss";
 @import "~@/assets/styles/variables.scss";
+
 .combarr {
   /* height: 100vh !important; */
   /* overflow: scroll; */
@@ -181,9 +185,11 @@ export default {
 .avatar-wrapper {
   white-space: nowrap;
 }
+
 .el-dropdown-menu {
   z-index: 10000 !important;
 }
+
 .sidebar-container {
   background-color: #222653 !important;
 }
@@ -210,9 +216,9 @@ export default {
   height: 37px;
   /* height: 25px; */
   background: linear-gradient(
-    128.13deg,
-    rgba(82, 79, 255, 1) 0%,
-    rgba(255, 74, 74, 1) 100%
+      128.13deg,
+      rgba(82, 79, 255, 1) 0%,
+      rgba(255, 74, 74, 1) 100%
   );
   box-shadow: 0px 4px 16px rgba(179, 192, 231, 1);
   border-radius: 27px;
@@ -225,6 +231,7 @@ export default {
   padding: 0px 20px 0px 25px;
   box-sizing: border-box;
 }
+
 .user-avatar {
   cursor: pointer;
   width: 50px;
@@ -252,6 +259,7 @@ export default {
 #dropdown-menu-1780 {
   z-index: 1000000;
 }
+
 .imgg {
   // width: 553px;
   width: 270px;
@@ -261,10 +269,12 @@ export default {
   margin-bottom: 8px;
   /* margin-left: 50px; */
 }
+
 .logo-title {
   width: 100%;
   display: flex;
   align-items: center;
+
   .title {
     flex: 1;
     margin-left: 5px;

+ 5 - 1
zkqy-ui/src/router/index.js

@@ -136,7 +136,6 @@ export const constantRoutes = [
     component: () => {
       return import('@/views/login')
 
-
       // var url = new URL(window.location.href);
       // var params = new URLSearchParams(url.search);
       // let temp = params.get('tenantId')
@@ -150,6 +149,11 @@ export const constantRoutes = [
     },
     hidden: true
   },
+  {
+    path: '/tenantLogin',
+    component: () => import('@/views/login'),
+    hidden: true
+  },
   {
     path: '/register',
     component: () => import('@/views/register'),

+ 4 - 0
zkqy-ui/src/views/login.vue

@@ -224,18 +224,22 @@ export default {
   methods: {
     // 校验url
     validateTenantId() {
+      console.log(this.$route.query);
       let tenantCode = this.$route.query['tenantCode']
       console.log(tenantCode)
       if (tenantCode != null) {
         // 得到tenantId 查询裤中是否存在该租户
         isTenantExist({tenantCode: tenantCode}).then(res => {
           if (res.data?.tenantId) { // 判断当前编号是否存在库中
+            console.log(res)
             this.tenantId = res.data.tenantId
             // 得到租户的信息
             this.config = res.data.loginPageConfiguration
             // 如果当前租户没有配置登录页面则不可访问
             if (this.config == null && this.config == undefined) {
               // this.$router.push({path: "/404"})
+              this.getCode();
+              this.getCookie();
             } else {
               this.getCode();
               this.getCookie();