Forráskód Böngészése

fix: 租户是企业版功能如果非企业版,跳转到普通登录页面

yanglzh 10 hónapja
szülő
commit
1abbbf7e5d
3 módosított fájl, 46 hozzáadás és 41 törlés
  1. 2 2
      src/router/index.ts
  2. 36 31
      src/views/login/tenant.vue
  3. 8 8
      vite.config.ts

+ 2 - 2
src/router/index.ts

@@ -223,9 +223,9 @@ router.beforeEach(async (to, from, next) => {
 			if (params) {
 				paramsStr = `&params=${JSON.stringify(Object.keys(to.query).length ? to.query : to.params)}`
 			}
-			// 如果当前是租户,则跳转到租户登录页
+			// 如果当前是租户并且是企业版,则跳转到租户登录页
 			const tenantCode = getTenantInfo()?.code
-			next(`${tenantCode ? '/' + tenantCode : ''}/login?redirect=${to.path}${paramsStr}`);
+			next(`${tenantCode && sessionStorage.isEnterprise ? '/' + tenantCode : ''}/login?redirect=${to.path}${paramsStr}`);
 			Session.clear();
 			resetRoute();
 			NProgress.done();

+ 36 - 31
src/views/login/tenant.vue

@@ -62,43 +62,48 @@ api
 	.sysinfo()
 	.then((res: any) => {
 		setSystemInfo(res);
+		// 租户是 (企业版功能) 如果非企业版,跳转到普通登录页面
+		if (!sessionStorage.isEnterprise) return window.location.href = "/"
 		sysinfo.buildVersion = res.buildVersion;
 		sysinfo.buildTime = res.buildTime;
-		const isSSOEnabled = window.atob(res.target).split("|")[4];
-		if (isSSOEnabled == "1") {
-			showSSO.value = true;
-		}
+		// const isSSOEnabled = window.atob(res.target).split("|")[4];
+		// if (isSSOEnabled == "1") {
+		// 	showSSO.value = true;
+		// }
+		getTenantInfo()
 	})
 	.finally(() => (showImg.value = true));
 
-tenantApi
-	.get(tenant)
-	.then((res: any) => {
-		if (res?.status) {
-			sysinfo.systemName = res.name;
-			sysinfo.systemLogo = res.logo;
-			sysinfo.systemLoginPIC = res.logoPic;
-
-			// 设置租户的全局名称和图标
-			setTenantInfo({
-				code: res.code,
-				systemName: res.name,
-				systemLogo: res.logo,
-				systemLogoMini: res.logoMini,
-				systemLoginPIC: res.logoPic,
-			})
-			other.useTitle()
-		} else {
+function getTenantInfo() {
+	tenantApi
+		.get(tenant)
+		.then((res: any) => {
+			if (res?.status) {
+				sysinfo.systemName = res.name;
+				sysinfo.systemLogo = res.logo;
+				sysinfo.systemLoginPIC = res.logoPic;
+
+				// 设置租户的全局名称和图标
+				setTenantInfo({
+					code: res.code,
+					systemName: res.name,
+					systemLogo: res.logo,
+					systemLogoMini: res.logoMini,
+					systemLoginPIC: res.logoPic,
+				})
+				other.useTitle()
+			} else {
+				isAllow.value = false;
+				ElMessage.error("租户不存在");
+			}
+		})
+		.catch(() => {
 			isAllow.value = false;
-			ElMessage.error("租户不存在");
-		}
-	})
-	.catch(() => {
-		isAllow.value = false;
-	})
-	.finally(() => {
-		loading.value = false;
-	});
+		})
+		.finally(() => {
+			loading.value = false;
+		});
+}
 
 // 获取布局配置信息
 const getThemeConfig = computed(() => {

+ 8 - 8
vite.config.ts

@@ -36,14 +36,14 @@ const viteConfig = defineConfig((mode: ConfigEnv) => {
 			host: true,
 			open: true,
 			hmr: true,
-			proxy: {
-				[env.VITE_NGINX_PROXY ? env.VITE_NGINX_PROXY : '/xxxxxxxxxxxxx']: {
-					target: env.VITE_SERVER_ORIGIN,
-					ws: true,
-					changeOrigin: true,
-					// rewrite: (path) => path.replace(/^\/api/, ''),
-				},
-			},
+			// proxy: {
+			// 	[env.VITE_NGINX_PROXY ? env.VITE_NGINX_PROXY : '/xxxxxxxxxxxxx']: {
+			// 		target: env.VITE_SERVER_ORIGIN,
+			// 		ws: true,
+			// 		changeOrigin: true,
+			// 		// rewrite: (path) => path.replace(/^\/api/, ''),
+			// 	},
+			// },
 		},
 		build: {
 			outDir: 'sagoo-iot',