diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index dba700d5682..bef10508bc1 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -7,6 +7,7 @@ - 新增 `JsonPreview`Json 数据查看组件 - 表格的数据列(column)和操作列(actionColumn)的字段可以根据权限和业务来控制是否显示 - 新增权限控制表格示例(AuthColumn.vue) +- 新增用户登录过期示例 ### ⚡ Performance Improvements diff --git a/mock/demo/account.ts b/mock/demo/account.ts index 33c4c1dc5e4..4ba247d190d 100644 --- a/mock/demo/account.ts +++ b/mock/demo/account.ts @@ -1,5 +1,5 @@ import { MockMethod } from 'vite-plugin-mock'; -import { resultSuccess } from '../_util'; +import { resultSuccess, resultError } from '../_util'; const userInfo = { name: 'Vben', @@ -51,4 +51,12 @@ export default [ return resultSuccess(userInfo); }, }, + { + url: '/basic-api/user/sessionTimeout', + method: 'post', + statusCode: 401, + response: () => { + return resultError(); + }, + }, ] as MockMethod[]; diff --git a/src/api/demo/account.ts b/src/api/demo/account.ts index 54bed483b59..53537d14c99 100644 --- a/src/api/demo/account.ts +++ b/src/api/demo/account.ts @@ -3,8 +3,11 @@ import { GetAccountInfoModel } from './model/accountModel'; enum Api { ACCOUNT_INFO = '/account/getAccountInfo', + SESSION_TIMEOUT = '/user/sessionTimeout', } // Get personal center-basic settings export const accountInfoApi = () => defHttp.get({ url: Api.ACCOUNT_INFO }); + +export const sessionTimeoutApi = () => defHttp.post({ url: Api.SESSION_TIMEOUT }); diff --git a/src/layouts/default/feature/index.vue b/src/layouts/default/feature/index.vue index b9ab77e42ea..a6b64b1e259 100644 --- a/src/layouts/default/feature/index.vue +++ b/src/layouts/default/feature/index.vue @@ -5,28 +5,29 @@ import { useRootSetting } from '/@/hooks/setting/useRootSetting'; import { useHeaderSetting } from '/@/hooks/setting/useHeaderSetting'; import { useDesign } from '/@/hooks/web/useDesign'; + import { useUserStoreWidthOut } from '/@/store/modules/user'; import { SettingButtonPositionEnum } from '/@/enums/appEnum'; import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; + import SessionTimeoutLogin from '/@/views/sys/login/SessionTimeoutLogin.vue'; export default defineComponent({ name: 'LayoutFeatures', components: { BackTop, LayoutLockPage: createAsyncComponent(() => import('/@/views/sys/lock/index.vue')), SettingDrawer: createAsyncComponent(() => import('/@/layouts/default/setting/index.vue')), + SessionTimeoutLogin, }, setup() { - const { - getUseOpenBackTop, - getShowSettingButton, - getSettingButtonPosition, - getFullContent, - } = useRootSetting(); - + const { getUseOpenBackTop, getShowSettingButton, getSettingButtonPosition, getFullContent } = + useRootSetting(); + const userStore = useUserStoreWidthOut(); const { prefixCls } = useDesign('setting-drawer-fearure'); const { getShowHeader } = useHeaderSetting(); + const getIsSessionTimeout = computed(() => userStore.getSessionTimeout); + const getIsFixedSettingDrawer = computed(() => { if (!unref(getShowSettingButton)) { return false; @@ -44,6 +45,7 @@ getUseOpenBackTop, getIsFixedSettingDrawer, prefixCls, + getIsSessionTimeout, }; }, }); @@ -53,6 +55,7 @@ +