| 123456789101112131415161718192021222324252627282930313233343536373839 |
- import { useUserStore } from '@/store/modules/user';
- import { computed, watch } from 'vue';
- export const SYS_TENANT_ID = 0;
- /** 设置targetTenantId */
- export function useTargetTenantIdSetting() {
- let fullKey = '';
- const userStore = useUserStore();
- watch(
- () => [userStore.info.username, userStore.info.tenantCode],
- ([username, tenantCode]) => {
- fullKey = `${tenantCode || ''}_${username}_targetTenantId`;
- },
- { immediate: true },
- );
- function setValue(tenantId: string | string) {
- if (!fullKey) {
-
- return;
- }
- localStorage.setItem(fullKey, String(tenantId));
- }
- function getValue() {
- if (!fullKey) {
-
- return;
- }
- return localStorage.getItem(fullKey);
- }
- const isSysTenant = computed(() => getValue() !== SYS_TENANT_ID.toString())
- return { setValue, getValue, isSysTenant };
- }
|