feat(tenant):增加通过域名查询租户编码和查询租户开关状态的功能

This commit is contained in:
MoChou
2025-07-19 21:58:21 +08:00
parent 60c6df2574
commit c7a1c1deba
8 changed files with 81 additions and 20 deletions

View File

@@ -6,6 +6,7 @@ export * from './modules/route'
export * from './modules/tabs'
export * from './modules/dict'
export * from './modules/user'
export * from './modules/tenant'
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)

View File

@@ -68,7 +68,6 @@ 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"]')
@@ -123,10 +122,6 @@ const storeSetup = () => {
const getForRecord = () => {
return siteConfig.SITE_BEIAN
}
const getTenantEnabled = () => {
return siteConfig.TENANT_ENABLED
}
return {
...toRefs(settingConfig),
...toRefs(siteConfig),
@@ -143,7 +138,6 @@ const storeSetup = () => {
getTitle,
getCopyright,
getForRecord,
getTenantEnabled,
}
}

View File

@@ -0,0 +1,31 @@
import { defineStore } from 'pinia'
import { computed, reactive } from 'vue'
const storeSetup = () => {
interface TenantInfo {
tenantEnabled: boolean
tenantCode: string
}
const tenantInfo = reactive<TenantInfo>({
tenantEnabled: false,
tenantCode: '',
})
const tenantEnabled = computed(() => tenantInfo.tenantEnabled)
const tenantCode = computed(() => tenantInfo.tenantCode)
const setTenantEnable = (tenantStatus: boolean) => {
tenantInfo.tenantEnabled = tenantStatus
}
const setTenantCode = (tenantCode: string) => {
tenantInfo.tenantCode = tenantCode
}
return {
tenantCode,
tenantEnabled,
setTenantCode,
setTenantEnable,
}
}
export const useTenantStore = defineStore('tenant', storeSetup, {
persist: { paths: ['tenantInfo'], storage: localStorage },
})