diff --git a/docs/登录功能与页面渲染框架-移植清单.md b/docs/登录功能与页面渲染框架-移植清单.md index 6ef9b099..2b845526 100644 --- a/docs/登录功能与页面渲染框架-移植清单.md +++ b/docs/登录功能与页面渲染框架-移植清单.md @@ -34,7 +34,7 @@ |---|---|---|---| | 1 | `src/views/login/index.vue` | 登录页:账号密码登录、注册、微信扫码登录 | 登录成功 → `router.push(redirect \|\| '/')`;扫码成功后 `setToken` + `userStore.$patch({token})` | | 2 | `src/stores/modules/user.ts` | **登录核心 store** | `login / register / getInfo / changeRole / logout / resetToken / updateToken / checkPermission` | -| 3 | `src/api/user/user.ts` | 登录相关接口 | `user.login`、`user.loginByCode`、`user.register`、`user.info`、`user.changeRole`、`user.logout`、`user.getLoginWechatCode`(扫码)、`user.getBindWechatCode` / `user.unbindWechat`(绑定) | +| 3 | `src/api/user/user.ts` | 登录相关接口 | `user.login`、`user.loginByCode`、`user.register`、`user.info`、`user.getAccountInfo`(个人中心)、`user.updateUsername`(改账号)、`user.changePassword`(设置/修改密码)、`user.changeRole`、`user.logout`、`user.getLoginWechatCode`(扫码)、`user.getBindWechatCode` / `user.unbindWechat`(绑定) | | 4 | `src/utils/auth.ts` | token 存取(Cookie,key=`token`) | `getToken / setToken / removeToken` | | 5 | `src/utils/request.ts` | axios 封装 | 请求头 `platform/project`、注入 `Authorization: Bearer `、**响应头新 token 自动回写**、`401/50008/50012/50014` → 弹窗重登 | | 6 | `src/permission.ts` | 路由守卫(登录准入 + 动态路由) | 白名单、getToken 判定、`getInfo()` 拉菜单、失败 `resetToken()` | diff --git a/docs/进度条弹窗-使用清单.md b/docs/进度条弹窗-使用清单.md index b29f50b1..62622542 100644 --- a/docs/进度条弹窗-使用清单.md +++ b/docs/进度条弹窗-使用清单.md @@ -129,7 +129,6 @@ | `views/warehouse/AreaRacksList.vue` | 库位容量占用条 | | `views/dashboard/components/StatsCardsWarehouse.vue` | 仪表盘统计卡片进度 | | `views/dashboard/components/StatsCardsStore.vue` | 仪表盘统计卡片进度 | -| `views/profile/components/AccountSecurity.vue` | 账号安全强度条 | | `views/test/index.vue` | 独立测试页的豹子进度条演示 | --- diff --git a/src/api/user/user.ts b/src/api/user/user.ts index 0632d8b2..5d252d7d 100644 --- a/src/api/user/user.ts +++ b/src/api/user/user.ts @@ -80,6 +80,82 @@ export function getInfo(data: UserInfoParams = {}) { } as SystemApiRequestConfig>); } +/** + * user.getAccountInfo 入参 + * 与 user.info 保持一致:后端按登录态取当前账户,参数可留空。 + */ +export interface AccountInfoParams { + /** 小程序 AppID(可选) */ + wechat_appId?: string + /** 其它业务参数(以后端为准) */ + [key: string]: unknown +} + +/** + * 获取账户信息(个人中心) + * 返回当前登录账户的资料、账户安全等信息 + */ +export function getAccountInfo(data: AccountInfoParams = {}) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'user.getAccountInfo', + v: '1.0', + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as SystemApiRequestConfig); +} + +export interface UpdateUsernameParams { + /** 新的登录账号 */ + username: string +} + +/** + * 修改登录账号(user.updateUsername) + */ +export function updateUsername(data: UpdateUsernameParams) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'user.updateUsername', + v: '1.0', + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as SystemApiRequestConfig); +} + +export interface ChangePasswordParams { + /** 新密码 */ + new_password: string + /** 旧密码:已设置过密码时必传,首次设置密码时无需传 */ + old_password?: string +} + +/** + * 修改/设置登录密码(user.changePassword) + * is_custom_password=0 表示从未设置过密码,此时不传 old_password + */ +export function changePassword(data: ChangePasswordParams) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'user.changePassword', + v: '1.0', + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as SystemApiRequestConfig); +} + export function changeRole(data: Record) { return request({ url: '/system', diff --git a/src/views/profile/components/AccountSecurity.vue b/src/views/profile/components/AccountSecurity.vue index 60898e7e..36d6ccb6 100644 --- a/src/views/profile/components/AccountSecurity.vue +++ b/src/views/profile/components/AccountSecurity.vue @@ -1,22 +1,22 @@