fix: 移除套餐徽章兜底与兼容逻辑
套餐标签仅使用后端返回的 packageName 字段,不再本地缓存、默认值回填或多字段兼容。
This commit is contained in:
@@ -3,7 +3,6 @@ import type { UserInfo } from '@vben/types';
|
|||||||
import { requestClient } from '#/api/request';
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
const TENANT_STORAGE_KEY = 'sys-tenant-id';
|
const TENANT_STORAGE_KEY = 'sys-tenant-id';
|
||||||
const PACKAGE_NAME_STORAGE_KEY = 'sys-package-name';
|
|
||||||
|
|
||||||
interface TenantUserProfile {
|
interface TenantUserProfile {
|
||||||
account?: string;
|
account?: string;
|
||||||
@@ -13,23 +12,10 @@ interface TenantUserProfile {
|
|||||||
packageName?: string;
|
packageName?: string;
|
||||||
permissions?: string[];
|
permissions?: string[];
|
||||||
roles?: string[];
|
roles?: string[];
|
||||||
subscriptionPackageName?: string;
|
|
||||||
tenantId?: number | string;
|
tenantId?: number | string;
|
||||||
planName?: string;
|
|
||||||
userId?: number | string;
|
userId?: number | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolvePackageName(profile: TenantUserProfile) {
|
|
||||||
const packageName =
|
|
||||||
profile.packageName ??
|
|
||||||
profile.subscriptionPackageName ??
|
|
||||||
profile.planName ??
|
|
||||||
localStorage.getItem(PACKAGE_NAME_STORAGE_KEY) ??
|
|
||||||
'标准版';
|
|
||||||
|
|
||||||
return packageName.trim() || '标准版';
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizeId(value: null | number | string | undefined) {
|
function normalizeId(value: null | number | string | undefined) {
|
||||||
if (value === null || value === undefined) {
|
if (value === null || value === undefined) {
|
||||||
return '';
|
return '';
|
||||||
@@ -40,7 +26,7 @@ function normalizeId(value: null | number | string | undefined) {
|
|||||||
function mapProfileToUserInfo(profile: TenantUserProfile): UserInfo {
|
function mapProfileToUserInfo(profile: TenantUserProfile): UserInfo {
|
||||||
return {
|
return {
|
||||||
avatar: profile.avatar ?? '',
|
avatar: profile.avatar ?? '',
|
||||||
desc: resolvePackageName(profile),
|
desc: profile.packageName ?? '',
|
||||||
homePath: '',
|
homePath: '',
|
||||||
realName: profile.displayName ?? profile.account ?? '',
|
realName: profile.displayName ?? profile.account ?? '',
|
||||||
roles: profile.roles ?? [],
|
roles: profile.roles ?? [],
|
||||||
@@ -55,7 +41,6 @@ function mapProfileToUserInfo(profile: TenantUserProfile): UserInfo {
|
|||||||
*/
|
*/
|
||||||
export async function getUserInfoApi() {
|
export async function getUserInfoApi() {
|
||||||
const profile = await requestClient.get<TenantUserProfile>('/auth/profile');
|
const profile = await requestClient.get<TenantUserProfile>('/auth/profile');
|
||||||
localStorage.setItem(PACKAGE_NAME_STORAGE_KEY, resolvePackageName(profile));
|
|
||||||
if (profile.tenantId !== null && profile.tenantId !== undefined) {
|
if (profile.tenantId !== null && profile.tenantId !== undefined) {
|
||||||
localStorage.setItem(TENANT_STORAGE_KEY, String(profile.tenantId));
|
localStorage.setItem(TENANT_STORAGE_KEY, String(profile.tenantId));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ const avatar = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const packageTagText = computed(() => {
|
const packageTagText = computed(() => {
|
||||||
return userStore.userInfo?.desc?.trim() || '标准版';
|
return userStore.userInfo?.desc?.trim() ?? '';
|
||||||
});
|
});
|
||||||
|
|
||||||
async function handleLogout() {
|
async function handleLogout() {
|
||||||
|
|||||||
Reference in New Issue
Block a user