From c7a1c1deba13baa0718aba4f6f3eca7c0cd3e3de Mon Sep 17 00:00:00 2001 From: MoChou <1373639299@qq.com> Date: Sat, 19 Jul 2025 21:58:21 +0800 Subject: [PATCH] =?UTF-8?q?feat(tenant):=E5=A2=9E=E5=8A=A0=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E5=9F=9F=E5=90=8D=E6=9F=A5=E8=AF=A2=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E5=92=8C=E6=9F=A5=E8=AF=A2=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E5=BC=80=E5=85=B3=E7=8A=B6=E6=80=81=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/system/common.ts | 5 ++++ src/apis/system/type.ts | 1 - src/apis/tenant/common.ts | 5 ++++ src/stores/index.ts | 1 + src/stores/modules/app.ts | 6 ---- src/stores/modules/tenant.ts | 31 ++++++++++++++++++++ src/views/login/components/account/index.vue | 31 +++++++++++++------- src/views/login/index.vue | 21 +++++++++++-- 8 files changed, 81 insertions(+), 20 deletions(-) create mode 100644 src/stores/modules/tenant.ts diff --git a/src/apis/system/common.ts b/src/apis/system/common.ts index 345b7a3..0fcc629 100644 --- a/src/apis/system/common.ts +++ b/src/apis/system/common.ts @@ -38,3 +38,8 @@ export function listSiteOptionDict() { export function upload(data: FormData) { return http.post(`${BASE_URL}/file`, data) } + +/** @desc 查询租户开启状态 */ +export function getTenantStatus() { + return http.get(`${BASE_URL}/dict/option/tenant`) +} diff --git a/src/apis/system/type.ts b/src/apis/system/type.ts index dc4472c..3528a2b 100644 --- a/src/apis/system/type.ts +++ b/src/apis/system/type.ts @@ -335,7 +335,6 @@ export interface BasicConfig { SITE_TITLE: string SITE_COPYRIGHT: string SITE_BEIAN: string - TENANT_ENABLED: boolean } /** 基础配置类型 */ diff --git a/src/apis/tenant/common.ts b/src/apis/tenant/common.ts index 61571ac..0871075 100644 --- a/src/apis/tenant/common.ts +++ b/src/apis/tenant/common.ts @@ -7,3 +7,8 @@ const BASE_URL = '/tenant/common' export function listTenantPackageDict(query?: { description: string, status: number }) { return http.get(`${BASE_URL}/dict/package`, query) } + +/** @desc 根据域名查询租户编码 */ +export function getTenantCodeByDomain(domain: string) { + return http.get(`${BASE_URL}/code/domain`, { domain }) +} diff --git a/src/stores/index.ts b/src/stores/index.ts index 875abe8..2ec60fa 100644 --- a/src/stores/index.ts +++ b/src/stores/index.ts @@ -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) diff --git a/src/stores/modules/app.ts b/src/stores/modules/app.ts index 4a71c8d..321656d 100644 --- a/src/stores/modules/app.ts +++ b/src/stores/modules/app.ts @@ -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, } } diff --git a/src/stores/modules/tenant.ts b/src/stores/modules/tenant.ts new file mode 100644 index 0000000..732f66e --- /dev/null +++ b/src/stores/modules/tenant.ts @@ -0,0 +1,31 @@ +import { defineStore } from 'pinia' +import { computed, reactive } from 'vue' + +const storeSetup = () => { + interface TenantInfo { + tenantEnabled: boolean + tenantCode: string + } + const tenantInfo = reactive({ + 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 }, +}) diff --git a/src/views/login/components/account/index.vue b/src/views/login/components/account/index.vue index 5ee0ede..da3eaab 100644 --- a/src/views/login/components/account/index.vue +++ b/src/views/login/components/account/index.vue @@ -8,8 +8,8 @@ size="large" @submit="handleLogin" > - - + + @@ -43,17 +43,15 @@