mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-23 15:35:06 +08:00
* 【新增】后端 yudao.tenant.enable
配置项,前端 VUE_APP_TENANT_ENABLE
配置项,用于开关租户功能
* 【优化】调整默认所有表开启多租户的特性,可通过 `yudao.tenant.ignore-tables` 配置项进行忽略,替代原本默认不开启的策略 * 【新增】通过 `yudao.tenant.ignore-urls` 配置忽略多租户的请求,例如说 ,例如说短信回调、支付回调等 Open API
This commit is contained in:
@ -4,6 +4,7 @@ import store from '@/store'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import errorCode from '@/utils/errorCode'
|
||||
import Cookies from "js-cookie";
|
||||
import {getTenantEnable} from "@/utils/ruoyi";
|
||||
|
||||
// 是否显示重新登录
|
||||
let isReloginShow;
|
||||
@ -24,9 +25,11 @@ service.interceptors.request.use(config => {
|
||||
config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||
}
|
||||
// 设置租户
|
||||
const tenantId = Cookies.get('tenantId');
|
||||
if (tenantId) {
|
||||
config.headers['tenant-id'] = tenantId;
|
||||
if (getTenantEnable()) {
|
||||
const tenantId = Cookies.get('tenantId');
|
||||
if (tenantId) {
|
||||
config.headers['tenant-id'] = tenantId;
|
||||
}
|
||||
}
|
||||
// get请求映射params参数
|
||||
if (config.method === 'get' && config.params) {
|
||||
|
@ -170,3 +170,17 @@ export function getNowDateTime(timeStr) {
|
||||
let seconds = now.getSeconds().toString().padStart(2, "0") // 得到秒;
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得租户功能是否开启
|
||||
*/
|
||||
export function getTenantEnable() {
|
||||
console.log("enable: " + process.env.VUE_APP_TENANT_ENABLE)
|
||||
if (process.env.VUE_APP_TENANT_ENABLE === "true") {
|
||||
return true;
|
||||
}
|
||||
if (process.env.VUE_APP_TENANT_ENABLE === "false") {
|
||||
return false;
|
||||
}
|
||||
return process.env.VUE_APP_TENANT_ENABLE || true;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div class="login">
|
||||
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
|
||||
<h3 class="title">芋道后台管理系统</h3>
|
||||
<el-form-item prop="tenantName">
|
||||
<el-form-item prop="tenantName" v-if="tenantEnable">
|
||||
<el-input v-model="loginForm.tenantName" type="text" auto-complete="off" placeholder='租户'>
|
||||
<svg-icon slot="prefix" icon-class="tree" class="el-input__icon input-icon" />
|
||||
</el-input>
|
||||
@ -54,7 +54,8 @@ import { getCodeImg,socialAuthRedirect } from "@/api/login";
|
||||
import { getTenantIdByName } from "@/api/system/tenant";
|
||||
import Cookies from "js-cookie";
|
||||
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||
import {InfraApiErrorLogProcessStatusEnum, SystemUserSocialTypeEnum} from "@/utils/constants";
|
||||
import {SystemUserSocialTypeEnum} from "@/utils/constants";
|
||||
import { getTenantEnable } from "@/utils/ruoyi";
|
||||
|
||||
export default {
|
||||
name: "Login",
|
||||
@ -62,6 +63,7 @@ export default {
|
||||
return {
|
||||
codeUrl: "",
|
||||
captchaEnable: true,
|
||||
tenantEnable: true,
|
||||
loginForm: {
|
||||
username: "admin",
|
||||
password: "admin123",
|
||||
@ -71,6 +73,13 @@ export default {
|
||||
tenantName: "芋道源码",
|
||||
},
|
||||
loginRules: {
|
||||
username: [
|
||||
{ required: true, trigger: "blur", message: "用户名不能为空" }
|
||||
],
|
||||
password: [
|
||||
{ required: true, trigger: "blur", message: "密码不能为空" }
|
||||
],
|
||||
code: [{ required: true, trigger: "change", message: "验证码不能为空" }],
|
||||
tenantName: [
|
||||
{ required: true, trigger: "blur", message: "租户不能为空" },
|
||||
{
|
||||
@ -90,13 +99,6 @@ export default {
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
username: [
|
||||
{ required: true, trigger: "blur", message: "用户名不能为空" }
|
||||
],
|
||||
password: [
|
||||
{ required: true, trigger: "blur", message: "密码不能为空" }
|
||||
],
|
||||
code: [{ required: true, trigger: "change", message: "验证码不能为空" }]
|
||||
},
|
||||
loading: false,
|
||||
redirect: undefined,
|
||||
@ -113,6 +115,8 @@ export default {
|
||||
// }
|
||||
// },
|
||||
created() {
|
||||
// 租户开关
|
||||
this.tenantEnable = getTenantEnable();
|
||||
// 重定向地址
|
||||
this.redirect = this.$route.query.redirect;
|
||||
this.getCode();
|
||||
|
Reference in New Issue
Block a user