Browse Source

登录添加获取部门信息存入缓存

master
陈薪名 9 months ago
parent
commit
3269feca40
  1. 3
      src/hooks/web/useCache.ts
  2. 6
      src/views/Login/components/LoginForm.vue

3
src/hooks/web/useCache.ts

@ -13,7 +13,8 @@ export const CACHE_KEY = {
THEME: 'theme',
LAYOUT: 'layout',
ROLE_ROUTERS: 'roleRouters',
DICT_CACHE: 'dictCache'
DICT_CACHE: 'dictCache',
DEPT: 'dept'
}
export const useCache = (type: CacheType = 'localStorage') => {

6
src/views/Login/components/LoginForm.vue

@ -87,6 +87,9 @@ import * as LoginApi from '@/api/login'
import { LoginStateEnum, useFormValid, useLoginState } from './useLogin'
import { getCodeImg } from "@/api/login";
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import * as DeptApi from '@/api/system/dept'
defineOptions({ name: 'LoginForm' })
const { t } = useI18n()
@ -212,6 +215,9 @@ const handleLogin = async (params) => {
console.log(redirect.value)
push({ path: redirect.value || permissionStore.addRouters[0].path })
}
//
const { wsCache } = useCache()
wsCache.set(CACHE_KEY.DEPT, await DeptApi.getSimpleDeptList())
} finally {
getCode()
loginLoading.value = false

Loading…
Cancel
Save