fix: 三个必修 bug——Dashboard 颜色判反+legend 错+SideNav zhipianren 用户管理漏显
This commit is contained in:
@@ -26,13 +26,17 @@ function SideNav() {
|
||||
]
|
||||
|
||||
// 按角色过滤菜单项
|
||||
// user.role 值来自后端 /api/auth/me,应为字符串 'zhipianren' / 'zebian' / 'biandao'
|
||||
const visibleItems = allMenuItems.filter(item => {
|
||||
// /dashboard 三角色都可见
|
||||
if (item.key === '/dashboard') return true
|
||||
// /users 仅 zhipianren
|
||||
if (item.key === '/users') return user?.role === 'zhipianren'
|
||||
if (item.key === '/users') return String(user?.role) === 'zhipianren'
|
||||
// /editor-desk 仅 zhipianren + zebian
|
||||
if (item.key === '/editor-desk') return user?.role === 'zhipianren' || user?.role === 'zebian'
|
||||
if (item.key === '/editor-desk') {
|
||||
const role = String(user?.role)
|
||||
return role === 'zhipianren' || role === 'zebian'
|
||||
}
|
||||
// 其余三角色都可见(保留后期 Phase 入口)
|
||||
return true
|
||||
})
|
||||
|
||||
@@ -20,11 +20,16 @@ import './Dashboard.css'
|
||||
* 判色取该期 air_date 所属年份的 yearly_targets 行(不是当前年)。
|
||||
*/
|
||||
function getShareColor(share, targets, airYear) {
|
||||
const target = targets.find(t => t.year === airYear)
|
||||
// 强制转数值,避免后端返回字符串导致数值比较失败
|
||||
const n = Number(share)
|
||||
const target = targets.find(t => Number(t.year) === Number(airYear))
|
||||
if (!target) return '#999'
|
||||
if (share > target.stretch_target) return '#cf1322' // 红=优秀
|
||||
if (share >= target.base_target) return '#6b8e6b' // 蓝=达标
|
||||
return '#d4a017' // 绿=待提升
|
||||
if (isNaN(n)) return '#999'
|
||||
const stretch = Number(target.stretch_target)
|
||||
const base = Number(target.base_target)
|
||||
if (n > stretch) return '#cf1322' // 红=超过摸高目标(优秀)
|
||||
if (n >= base) return '#6b8e6b' // 蓝=未达摸高目标(达标)
|
||||
return '#d4a017' // 绿=未达基础目标(待提升)
|
||||
}
|
||||
|
||||
function getBarHeight(share) {
|
||||
@@ -181,9 +186,9 @@ function Dashboard() {
|
||||
})}
|
||||
</div>
|
||||
<div className="chart-legend">
|
||||
<span className="legend-item"><span className="dot" style={{ background: '#cf1322' }}></span>红=优秀</span>
|
||||
<span className="legend-item"><span className="dot" style={{ background: '#6b8e6b' }}></span>蓝=达标</span>
|
||||
<span className="legend-item"><span className="dot" style={{ background: '#d4a017' }}></span>绿=待提升</span>
|
||||
<span className="legend-item"><span className="dot" style={{ background: '#d4a017' }}></span>绿=未达基础目标(待提升)</span>
|
||||
<span className="legend-item"><span className="dot" style={{ background: '#6b8e6b' }}></span>蓝=未达摸高目标(达标)</span>
|
||||
<span className="legend-item"><span className="dot" style={{ background: '#cf1322' }}></span>红=超过摸高目标(优秀)</span>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user