feat: 초기 프로젝트 설정 및 룰.md 파일 추가

This commit is contained in:
2025-07-28 09:53:31 +09:00
commit 09a4d38512
8165 changed files with 1021855 additions and 0 deletions

46
web-ui/js/load-sidebar.js Normal file
View File

@@ -0,0 +1,46 @@
// ✅ /js/load-sidebar.js (access_level 기반 메뉴 필터링)
document.addEventListener('DOMContentLoaded', async () => {
try {
// 1) 사이드바 HTML 로딩
const res = await fetch('/components/sidebar.html');
const html = await res.text();
document.getElementById('sidebar-container').innerHTML = html;
// 2) 토큰 존재 확인
const token = localStorage.getItem('token');
if (!token) return;
// 3) JWT 파싱해서 access_level 추출
let access;
try {
const payload = JSON.parse(atob(token.split('.')[1]));
access = payload.access_level;
} catch (err) {
console.warn('JWT 파싱 실패:', err);
return;
}
// 4) 시스템 계정은 전부 유지
if (access === 'system') return;
// 5) 클래스 이름 목록
const classMap = [
'worker-only',
'group-leader-only',
'support-only',
'admin-only',
'system-only'
];
// 6) 본인 권한에 해당하지 않는 요소 제거
classMap.forEach(cls => {
const required = cls.replace('-only', '').replace('-', '_'); // 'group-leader-only' → 'group_leader'
if (access !== required) {
document.querySelectorAll(`.${cls}`).forEach(el => el.remove());
}
});
} catch (err) {
console.error('🔴 사이드바 로딩 실패:', err);
}
});