diff --git a/web/src/i18n/pages/login/en.ts b/web/src/i18n/pages/login/en.ts index 28c6983..ad93b86 100644 --- a/web/src/i18n/pages/login/en.ts +++ b/web/src/i18n/pages/login/en.ts @@ -3,6 +3,7 @@ export default { label: { one1: 'User name login', two2: 'Mobile number', + changePwd: 'Change The Password', }, link: { one3: 'Third party login', diff --git a/web/src/i18n/pages/login/zh-cn.ts b/web/src/i18n/pages/login/zh-cn.ts index 07fd82e..ccd60cb 100644 --- a/web/src/i18n/pages/login/zh-cn.ts +++ b/web/src/i18n/pages/login/zh-cn.ts @@ -3,6 +3,7 @@ export default { label: { one1: '账号密码登录', two2: '手机号登录', + changePwd: '密码修改', }, link: { one3: '第三方登录', @@ -12,6 +13,8 @@ export default { accountPlaceholder1: '请输入登录账号/邮箱/手机号', accountPlaceholder2: '请输入登录密码', accountPlaceholder3: '请输入验证码', + accountPlaceholder4:'请输入新密码', + accountPlaceholder5:'请再次输入新密码', accountBtnText: '登 录', }, mobile: { diff --git a/web/src/i18n/pages/login/zh-tw.ts b/web/src/i18n/pages/login/zh-tw.ts index 13ad013..e3cd9e6 100644 --- a/web/src/i18n/pages/login/zh-tw.ts +++ b/web/src/i18n/pages/login/zh-tw.ts @@ -3,6 +3,7 @@ export default { label: { one1: '用戶名登入', two2: '手機號登入', + changePwd: '密码修改', }, link: { one3: '協力廠商登入', diff --git a/web/src/router/backEnd.ts b/web/src/router/backEnd.ts index 0839c49..a12db74 100644 --- a/web/src/router/backEnd.ts +++ b/web/src/router/backEnd.ts @@ -44,7 +44,7 @@ export async function initBackEndControlRoutes() { if (!Session.get('token')) return false; // 触发初始化用户信息 pinia // https://gitee.com/lyt-top/vue-next-admin/issues/I5F1HP - await useUserInfo().setUserInfos(); + await useUserInfo().getApiUserInfo(); // 获取路由菜单数据 const res = await getBackEndControlRoutes(); // 无登录权限时,添加判断 diff --git a/web/src/router/index.ts b/web/src/router/index.ts index f98dcf3..0815e9e 100644 --- a/web/src/router/index.ts +++ b/web/src/router/index.ts @@ -28,6 +28,8 @@ import {checkVersion} from "/@/utils/upgrade"; const storesThemeConfig = useThemeConfig(pinia); const {themeConfig} = storeToRefs(storesThemeConfig); const {isRequestRoutes} = themeConfig.value; +import {useUserInfo} from "/@/stores/userInfo"; +const { userInfos } = storeToRefs(useUserInfo()); /** * 创建一个可以被 Vue 应用程序使用的路由实例 @@ -111,7 +113,10 @@ router.beforeEach(async (to, from, next) => { next(`/login?redirect=${to.path}¶ms=${JSON.stringify(to.query ? to.query : to.params)}`); Session.clear(); NProgress.done(); - } else if (token && to.path === '/login') { + }else if (token && to.path === '/login' && userInfos.value.pwd_change_count===0 ) { + next('/login'); + NProgress.done(); + } else if (token && to.path === '/login' && userInfos.value.pwd_change_count>0) { next('/home'); NProgress.done(); }else if(token && frameOutRoutes.includes(to.path) ){ diff --git a/web/src/stores/interface/index.ts b/web/src/stores/interface/index.ts index 82dc5c6..aeb8420 100644 --- a/web/src/stores/interface/index.ts +++ b/web/src/stores/interface/index.ts @@ -12,6 +12,7 @@ export interface UserInfosState { email: string; mobile: string; gender: string; + pwd_change_count:null|number; dept_info: { dept_id: number; dept_name: string; diff --git a/web/src/stores/userInfo.ts b/web/src/stores/userInfo.ts index 9be64a8..04d296a 100644 --- a/web/src/stores/userInfo.ts +++ b/web/src/stores/userInfo.ts @@ -15,6 +15,7 @@ export const useUserInfo = defineStore('userInfo', { email: '', mobile: '', gender: '', + pwd_change_count:null, dept_info: { dept_id: 0, dept_name: '', @@ -29,16 +30,19 @@ export const useUserInfo = defineStore('userInfo', { isSocketOpen: false }), actions: { - async updateUserInfos() { - let userInfos: any = await this.getApiUserInfo(); - this.userInfos.username = userInfos.data.name; - this.userInfos.avatar = userInfos.data.avatar; - this.userInfos.name = userInfos.data.name; - this.userInfos.email = userInfos.data.email; - this.userInfos.mobile = userInfos.data.mobile; - this.userInfos.gender = userInfos.data.gender; - this.userInfos.dept_info = userInfos.data.dept_info; - this.userInfos.role_info = userInfos.data.role_info; + async setPwdChangeCount(count: number) { + this.userInfos.pwd_change_count = count; + }, + async updateUserInfos(userInfos:any) { + this.userInfos.username = userInfos.name; + this.userInfos.avatar = userInfos.avatar; + this.userInfos.name = userInfos.name; + this.userInfos.email = userInfos.email; + this.userInfos.mobile = userInfos.mobile; + this.userInfos.gender = userInfos.gender; + this.userInfos.dept_info = userInfos.dept_info; + this.userInfos.role_info = userInfos.role_info; + this.userInfos.pwd_change_count = userInfos.pwd_change_count; Session.set('userInfo', this.userInfos); }, async setUserInfos() { @@ -55,6 +59,7 @@ export const useUserInfo = defineStore('userInfo', { this.userInfos.gender = userInfos.data.gender; this.userInfos.dept_info = userInfos.data.dept_info; this.userInfos.role_info = userInfos.data.role_info; + this.userInfos.pwd_change_count = userInfos.data.pwd_change_count; Session.set('userInfo', this.userInfos); } }, @@ -65,7 +70,18 @@ export const useUserInfo = defineStore('userInfo', { return request({ url: '/api/system/user/user_info/', method: 'get', - }); + }).then((res:any)=>{ + this.userInfos.username = res.data.name; + this.userInfos.avatar = res.data.avatar; + this.userInfos.name = res.data.name; + this.userInfos.email = res.data.email; + this.userInfos.mobile = res.data.mobile; + this.userInfos.gender = res.data.gender; + this.userInfos.dept_info = res.data.dept_info; + this.userInfos.role_info = res.data.role_info; + this.userInfos.pwd_change_count = res.data.pwd_change_count; + Session.set('userInfo', this.userInfos); + }) }, }, }); diff --git a/web/src/views/system/login/api.ts b/web/src/views/system/login/api.ts index 71b0844..7f83556 100644 --- a/web/src/views/system/login/api.ts +++ b/web/src/views/system/login/api.ts @@ -13,6 +13,15 @@ export function login(params: object) { data: params }); } + +export function loginChangePwd(data: object) { + return request({ + url: '/api/system/user/login_change_password/', + method: 'post', + data: data + }); +} + export function getUserInfo() { return request({ url: '/api/system/user/user_info/',