refactor(tenant): 优化租户相关代码

This commit is contained in:
2025-07-16 22:41:56 +08:00
parent 112c27e49c
commit 87bcf33940
10 changed files with 69 additions and 200 deletions

View File

@@ -68,6 +68,7 @@ const storeSetup = () => {
siteConfig.SITE_TITLE = resMap.get('SITE_TITLE')
siteConfig.SITE_COPYRIGHT = resMap.get('SITE_COPYRIGHT')
siteConfig.SITE_BEIAN = resMap.get('SITE_BEIAN')
siteConfig.TENANT_ENABLED = resMap.get('TENANT_ENABLED') === 'true'
document.title = resMap.get('SITE_TITLE')
document
.querySelector('link[rel="shortcut icon"]')
@@ -122,6 +123,10 @@ const storeSetup = () => {
const getForRecord = () => {
return siteConfig.SITE_BEIAN
}
const getTenantEnabled = () => {
return siteConfig.TENANT_ENABLED
}
return {
...toRefs(settingConfig),
...toRefs(siteConfig),
@@ -138,6 +143,7 @@ const storeSetup = () => {
getTitle,
getCopyright,
getForRecord,
getTenantEnabled,
}
}

View File

@@ -50,22 +50,22 @@ const storeSetup = () => {
}
// 登录
const accountLogin = async (req: AccountLoginReq) => {
const res = await accountLoginApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.ACCOUNT })
const accountLogin = async (req: AccountLoginReq, tenantCode?: string) => {
const res = await accountLoginApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.ACCOUNT }, tenantCode)
setToken(res.data.token)
token.value = res.data.token
}
// 邮箱登录
const emailLogin = async (req: EmailLoginReq) => {
const res = await emailLoginApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.EMAIL })
const emailLogin = async (req: EmailLoginReq, tenantCode?: string) => {
const res = await emailLoginApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.EMAIL }, tenantCode)
setToken(res.data.token)
token.value = res.data.token
}
// 手机号登录
const phoneLogin = async (req: PhoneLoginReq) => {
const res = await phoneLoginApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.PHONE })
const phoneLogin = async (req: PhoneLoginReq, tenantCode?: string) => {
const res = await phoneLoginApi({ ...req, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeConstants.PHONE }, tenantCode)
setToken(res.data.token)
token.value = res.data.token
}