Files
TK-FB-Project/web-ui/js/navigation.js
Hyungi Ahn b4037c9395 feat(web-ui): Refactor web-ui for improved maintainability and modularity
This commit introduces a series of refactoring changes to the web-ui
to remove hardcoded values and improve page integration.

- **Centralized Configuration:** Created  to
  centralize API ports, paths, and navigation URLs, replacing
  hardcoded values across multiple files.
- **Modular Component Loading:** Introduced
  to handle dynamic loading of common HTML components (e.g., sidebar, navbar),
  using paths from .
- **Modular Navigation:** Created  to centralize
  page redirection logic, improving maintainability and reducing direct
   manipulations.
- **Refactored Existing Modules:** Updated ,
  , , and
   to utilize the new , ,
  and  modules.
- **ES6 Module Compatibility:** Ensured  loads scripts
  as ES6 modules () to support  statements.
2026-01-06 15:54:49 +09:00

56 lines
1.8 KiB
JavaScript

// /js/navigation.js
import { config } from './config.js';
/**
* 지정된 URL로 페이지를 리디렉션합니다.
* @param {string} url - 이동할 URL
*/
function redirect(url) {
window.location.href = url;
}
/**
* 로그인 페이지로 리디렉션합니다.
*/
export function redirectToLogin() {
console.log(`🔄 로그인 페이지로 이동합니다: ${config.paths.loginPage}`);
redirect(config.paths.loginPage);
}
/**
* 사용자의 기본 대시보드 페이지로 리디렉션합니다.
* 백엔드가 지정한 URL이 있으면 그곳으로, 없으면 기본 URL로 이동합니다.
* @param {string} [backendRedirectUrl=null] - 백엔드에서 전달받은 리디렉션 URL
*/
export function redirectToDefaultDashboard(backendRedirectUrl = null) {
const destination = backendRedirectUrl || config.paths.defaultDashboard;
console.log(`🔄 대시보드로 이동합니다: ${destination}`);
// 부드러운 화면 전환 효과
document.body.style.transition = 'opacity 0.3s ease-out';
document.body.style.opacity = '0';
setTimeout(() => {
redirect(destination);
}, 300);
}
/**
* 시스템 대시보드 페이지로 리디렉션합니다.
*/
export function redirectToSystemDashboard() {
console.log(`🔄 시스템 대시보드로 이동합니다: ${config.paths.systemDashboard}`);
redirect(config.paths.systemDashboard);
}
/**
* 그룹 리더 대시보드 페이지로 리디렉션합니다.
*/
export function redirectToGroupLeaderDashboard() {
console.log(`🔄 그룹 리더 대시보드로 이동합니다: ${config.paths.groupLeaderDashboard}`);
redirect(config.paths.groupLeaderDashboard);
}
// 필요에 따라 더 많은 리디렉션 함수를 추가할 수 있습니다.
// export function redirectToUserProfile() { ... }