refactor: 优化 useTenantStore 使用

This commit is contained in:
2025-07-21 22:23:58 +08:00
parent 3e49bce38e
commit a72d12227e
4 changed files with 7 additions and 13 deletions

View File

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

View File

@@ -44,11 +44,8 @@
import { type FormInstance, Message } from '@arco-design/web-vue' import { type FormInstance, Message } from '@arco-design/web-vue'
import { useStorage } from '@vueuse/core' import { useStorage } from '@vueuse/core'
import { getImageCaptcha } from '@/apis/common' import { getImageCaptcha } from '@/apis/common'
import { useTabsStore, useUserStore } from '@/stores' import { useTabsStore, useTenantStore, useUserStore } from '@/stores'
import { encryptByRsa } from '@/utils/encrypt' import { encryptByRsa } from '@/utils/encrypt'
import { useTenantStore } from '@/stores/modules/tenant'
const tenantStore = useTenantStore()
const loginConfig = useStorage('login-config', { const loginConfig = useStorage('login-config', {
rememberMe: true, rememberMe: true,
@@ -61,7 +58,6 @@ const loginConfig = useStorage('login-config', {
const isCaptchaEnabled = ref(true) const isCaptchaEnabled = ref(true)
// 验证码图片 // 验证码图片
const captchaImgBase64 = ref() const captchaImgBase64 = ref()
// 租户编号
const tenantCode = ref() const tenantCode = ref()
const formRef = ref<FormInstance>() const formRef = ref<FormInstance>()
const form = reactive({ const form = reactive({
@@ -112,6 +108,7 @@ const getCaptcha = () => {
}) })
} }
const tenantStore = useTenantStore()
const userStore = useUserStore() const userStore = useUserStore()
const tabsStore = useTabsStore() const tabsStore = useTabsStore()
const router = useRouter() const router = useRouter()

View File

@@ -45,11 +45,8 @@
import { type FormInstance, Message } from '@arco-design/web-vue' import { type FormInstance, Message } from '@arco-design/web-vue'
import type { BehaviorCaptchaReq } from '@/apis' import type { BehaviorCaptchaReq } from '@/apis'
// import { type BehaviorCaptchaReq, getEmailCaptcha } from '@/apis' // import { type BehaviorCaptchaReq, getEmailCaptcha } from '@/apis'
import { useTabsStore, useUserStore } from '@/stores' import { useTabsStore, useTenantStore, useUserStore } from '@/stores'
import * as Regexp from '@/utils/regexp' import * as Regexp from '@/utils/regexp'
import { useTenantStore } from '@/stores/modules/tenant'
const tenantStore = useTenantStore()
const formRef = ref<FormInstance>() const formRef = ref<FormInstance>()
const form = reactive({ const form = reactive({
@@ -66,6 +63,7 @@ const rules: FormInstance['rules'] = {
captcha: [{ required: true, message: '请输入验证码' }], captcha: [{ required: true, message: '请输入验证码' }],
} }
const tenantStore = useTenantStore()
const userStore = useUserStore() const userStore = useUserStore()
const tabsStore = useTabsStore() const tabsStore = useTabsStore()
const router = useRouter() const router = useRouter()

View File

@@ -45,11 +45,8 @@
import { type FormInstance, Message } from '@arco-design/web-vue' import { type FormInstance, Message } from '@arco-design/web-vue'
// import type { BehaviorCaptchaReq } from '@/apis' // import type { BehaviorCaptchaReq } from '@/apis'
import { type BehaviorCaptchaReq, getSmsCaptcha } from '@/apis' import { type BehaviorCaptchaReq, getSmsCaptcha } from '@/apis'
import { useTabsStore, useUserStore } from '@/stores' import { useTabsStore, useTenantStore, useUserStore } from '@/stores'
import * as Regexp from '@/utils/regexp' import * as Regexp from '@/utils/regexp'
import { useTenantStore } from '@/stores/modules/tenant'
const tenantStore = useTenantStore()
const formRef = ref<FormInstance>() const formRef = ref<FormInstance>()
const form = reactive({ const form = reactive({
@@ -66,6 +63,7 @@ const rules: FormInstance['rules'] = {
captcha: [{ required: true, message: '请输入验证码' }], captcha: [{ required: true, message: '请输入验证码' }],
} }
const tenantStore = useTenantStore()
const userStore = useUserStore() const userStore = useUserStore()
const tabsStore = useTabsStore() const tabsStore = useTabsStore()
const router = useRouter() const router = useRouter()