feat: 集成 Redux 状态管理和用户目标管理功能
- 添加 Redux 状态管理,支持用户登录和个人信息的持久化 - 新增目标管理页面,允许用户设置每日卡路里和步数目标 - 更新首页,移除旧的活动展示,改为固定的热点功能卡片 - 修改布局以适应新功能的展示和交互 - 更新依赖,添加 @reduxjs/toolkit 和 react-redux 库以支持状态管理 - 新增 API 服务模块,处理与后端的交互
This commit is contained in:
13
constants/Api.ts
Normal file
13
constants/Api.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export const API_ORIGIN = 'https://plate.richarjiang.com';
|
||||
export const API_BASE_PATH = '/api';
|
||||
|
||||
export function buildApiUrl(path: string): string {
|
||||
const normalizedPath = path.startsWith('/') ? path : `/${path}`;
|
||||
// 如果传入的路径已包含 /api 前缀,则直接拼接域名;否则自动补上 /api
|
||||
const finalPath = normalizedPath.startsWith(`${API_BASE_PATH}/`)
|
||||
? normalizedPath
|
||||
: `${API_BASE_PATH}${normalizedPath}`;
|
||||
return `${API_ORIGIN}${finalPath}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user