vitesse-yitisheng-web/project_codebase.md

1.2 KiB

Project Codebase

Function Overview

src/utils/message.ts

  • Purpose: Provides a global interface for showing toast messages.
  • Methods: success(msg, duration), error(msg, duration), warning(msg, duration), info(msg, duration).
  • Implementation: Programmatically mounts WMessage.vue.

src/service/request/index.ts

  • Purpose: Encapsulates Axios for API requests.
  • Features:
    • Request Interceptor:
      • Adds token to headers.
      • Adds X-App-Sign (MD5(timestamp + secret)) and X-App-Timestamp headers for security.
      • Starts NProgress.
    • Response Interceptor: Unwraps data; handles global errors (401, 403, 500); stops NProgress.
    • Config: showLoading, showError.

src/service/api/auth.ts

  • Purpose: API definitions for authentication.
  • Methods: login, logout, getUserInfo.

src/stores/user.ts

  • Purpose: Manages user session state.
  • State: token, userInfo.
  • Actions: login (calls API), logout, setToken, setUserInfo.
  • Persistence: Loads/Saves state to localStorage.

src/components/TheNavigation.vue

  • Updated: Added integration with userStore for login/logout and message for notifications.