Skip to content

Commit 34de24d

Browse files
committed
feat: 根据用户角色条件渲染控制面板链接
1 parent aa5e03b commit 34de24d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

frontend/components/Header.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const getTabClass = (isActive: boolean) => {
3939
interface UserData {
4040
username?: string;
4141
avatar_url?: string;
42+
role?: string;
4243
}
4344

4445
export default function Header() {
@@ -163,9 +164,11 @@ export default function Header() {
163164
<span className="badge">个人资料</span>
164165
</a>
165166
</li>
166-
<li>
167-
<Link href="/dashboard">控制面板</Link>
168-
</li>
167+
{userData?.role === 'admin' && (
168+
<li>
169+
<Link href="/dashboard">控制面板</Link>
170+
</li>
171+
)}
169172
<li>
170173
<button onClick={handleLogout}>退出登录</button>
171174
</li>

0 commit comments

Comments
 (0)