测试环境允许泛域名访问,方便根据域名进入租户系统

This commit is contained in:
shiningrise 2025-09-18 09:22:33 +08:00
parent 1407059688
commit 8ed93030a4
4 changed files with 20 additions and 4 deletions

View File

@ -1,5 +1,7 @@
import request from '/@/utils/request';
enum Api {
GetTenantIdByHostname = '/api/sysAuth/tenantIdByHostname',
}
/**
* request.post(xxx) post params data
*
@ -25,3 +27,9 @@ export function useLoginApi() {
},
};
}
export const getTenantIdByHostname = (hostname: string) =>
request({
url: `${Api.GetTenantIdByHostname}/${hostname}`,
method: 'get',
});

View File

@ -229,7 +229,8 @@ const onSignIn = async () => {
const publicKey = window.__env__.VITE_SM_PUBLIC_KEY;
const password = sm2.doEncrypt(state.ruleForm.password, publicKey, 1);
const tenantid = route.query.tid ?? 0;
//const tenantid = route.query.tid ?? 0;
const tenantid = Local.get('tid') ?? 0;
const [err, res] = await feature(getAPI(SysAuthApi).apiSysAuthLoginPost({ ...state.ruleForm, password: password, tenantId: Number(tenantid) }));
if (err) {
getCaptcha(); //

View File

@ -102,7 +102,7 @@ import { Local } from '/@/utils/storage';
//
import { languageList, getCountryCode } from '/@/i18n';
import '/node_modules/flag-icons/css/flag-icons.min.css';
import { getTenantIdByHostname } from '/@/api/login/index';
//
const Account = defineAsyncComponent(() => import('/@/views/login/component/account.vue'));
const Mobile = defineAsyncComponent(() => import('/@/views/login/component/mobile.vue'));
@ -129,7 +129,13 @@ onMounted(async () => {
if (!route.query.tid) Local.remove('tid');
var tenantid = Number(route.query.tid);
if (isNaN(tenantid)) {
tenantid = 0;
// hostname
const hostnameWithoutPort = window.location.hostname;
const data = await getTenantIdByHostname(hostnameWithoutPort);
console.log('tenantid', data.data.result);
tenantid = data.data.result;
if (tenantid > 99999)
Local.set('tid', tenantid);
} else if (tenantid > 99999) {
Local.set('tid', tenantid);
}

View File

@ -101,6 +101,7 @@ const viteConfig = defineConfig((mode: ConfigEnv) => {
port: env.VITE_PORT as unknown as number,
open: JSON.parse(env.VITE_OPEN),
hmr: true,
allowedHosts:true,
proxy: {
'^/[Uu]pload': {
target: env.VITE_API_URL,