383e20a3
杨鑫
拉取
|
1
2
|
import type { UsAppMyProfileOutputDto } from '../services/usAppAuth'
|
f64eecbf
杨鑫
前端更新
|
3
4
5
6
7
8
9
10
11
12
13
|
function isCompanyAdminProfile(profile: UsAppMyProfileOutputDto): boolean {
const code = (profile.primaryRoleCode ?? '').trim().toLowerCase()
if (code === 'companyadmin' || code.includes('partner')) return true
const display = (profile.roleDisplay ?? '').trim().toLowerCase()
if (!display) return false
if (display === 'company admin') return true
if (display.includes('partner admin')) return true
return false
}
/** 平台管理员或 Company Admin(App 级联选店) */
|
383e20a3
杨鑫
拉取
|
14
15
16
17
18
19
20
|
export function isAppAdminUser(profile: UsAppMyProfileOutputDto | null | undefined): boolean {
if (!profile) return false
const code = (profile.primaryRoleCode ?? '').trim().toLowerCase()
const compactCode = code.replace(/[\s_-]+/g, '')
if (code === 'admin') return true
if (compactCode === 'companyadmin') return true
const display = (profile.roleDisplay ?? '').trim().toLowerCase()
|
f64eecbf
杨鑫
前端更新
|
21
|
if (!display) return isCompanyAdminProfile(profile)
|
383e20a3
杨鑫
拉取
|
22
23
24
|
if (display.includes('administrator')) return true
if (display.includes('super admin')) return true
if (display.includes('company admin')) return true
|
f64eecbf
杨鑫
前端更新
|
25
|
return isCompanyAdminProfile(profile)
|
383e20a3
杨鑫
拉取
|
26
27
28
29
30
31
32
33
34
35
|
}
export function isCompanyAdminUser(profile: UsAppMyProfileOutputDto | null | undefined): boolean {
if (!profile) return false
const code = (profile.primaryRoleCode ?? '').trim().toLowerCase()
const compactCode = code.replace(/[\s_-]+/g, '')
if (compactCode === 'companyadmin') return true
const display = (profile.roleDisplay ?? '').trim().toLowerCase()
return display.includes('company admin')
}
|