1.7 KiB
1.7 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
Authorization: Bearer <token>. - Adds
X-App-SignandX-App-Timestampheaders. - Starts
NProgress.
- Adds
- Response Interceptor: Unwraps
data; handles global errors (401, 403, 500); prioritizes backend error messages; stopsNProgress. - Config:
showLoading,showError.
- Request Interceptor:
src/service/api/auth.ts
- Purpose: API definitions for authentication.
- Methods:
login,logout,getUserInfo.
src/service/api/score.ts
- Purpose: API definitions for score management.
- Methods:
getScore,saveScore. - Types:
SaveScoreRequest,ScoreInfo.
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/stores/score.ts
- Purpose: Manages user score state.
- State:
scoreInfo. - Actions:
fetchScore,saveScore,clearScore.
src/components/TheNavigation.vue
- Updated: Added integration with
userStoreandscoreStore. Displays user info and score info. Handles login/logout logic.
src/components/ScoreForm.vue
- Updated: Integrated with
scoreStoreto load and save score data. Maps form state to backend API structure.