65 lines
2.9 KiB
Markdown
65 lines
2.9 KiB
Markdown
# Project Codebase
|
|
|
|
## Function Overview
|
|
|
|
### `src/utils/message.ts`
|
|
- **Purpose**: Provides a global interface for showing toast messages.
|
|
- **Methods**: `success(msg, duration, position)`, `error(msg, duration, position)`, `warning(msg, duration, position)`, `info(msg, duration, position)`.
|
|
- **Implementation**: Programmatically mounts `WMessage.vue`.
|
|
- **New Feature**: Supports `position` argument: `'top-center' | 'top-left' | 'top-right' | 'bottom-center' | 'bottom-left' | 'bottom-right'`.
|
|
|
|
### `src/utils/loading.ts`
|
|
- **Purpose**: Provides a global interface for showing a full-screen blocking loading overlay.
|
|
- **Methods**: `show()`, `hide()`.
|
|
- **Implementation**: Programmatically mounts `WLoading.vue` with a reference counter to handle concurrent requests.
|
|
|
|
### `src/service/request/index.ts`
|
|
- **Purpose**: Encapsulates Axios for API requests.
|
|
- **Features**:
|
|
- Request Interceptor:
|
|
- Adds `Authorization: Bearer <token>`.
|
|
- Adds `X-App-Sign` and `X-App-Timestamp` headers.
|
|
- Starts `NProgress`.
|
|
- **New**: Shows blocking loading overlay if `config.showLoading` is true.
|
|
- Response Interceptor: Unwraps `data`; handles global errors (401, 403, 500); prioritizes backend error messages; stops `NProgress`.
|
|
- **New**: Hides blocking loading overlay if `config.showLoading` is true.
|
|
- Config: `showLoading`, `showError`.
|
|
|
|
### `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 `userStore` and `scoreStore`. Displays user info and score info. Handles login/logout logic.
|
|
|
|
### `src/components/ScoreForm.vue`
|
|
- **Updated**: Integrated with `scoreStore` to load and save score data. Maps form state to backend API structure.
|
|
|
|
### `src/pages/index.vue`
|
|
- **Purpose**: Home page / Dashboard.
|
|
- **Features**: Displays user sidebar with score form (if logged in) or welcome/feature info (if not logged in).
|
|
|
|
### `src/pages/agreement.vue`
|
|
- **Purpose**: Displays the User Service Agreement.
|
|
- **Features**: Static content with company information and service terms. Responsive layout.
|
|
|
|
### `src/pages/privacy-policy.vue`
|
|
- **Purpose**: Displays the Privacy Policy.
|
|
- **Features**: Static content detailing data collection, usage, and protection. Includes contact information. Responsive layout.
|