qsh 4 weeks ago
parent a4af107652
commit 893f827643
  1. 4
      .env.base
  2. 17
      src/store/modules/user.ts
  3. 2
      src/views/Error/403.vue
  4. 2
      src/views/Error/404.vue
  5. 2
      src/views/Error/500.vue
  6. 2
      src/views/Login/components/LoginForm.vue

@ -6,9 +6,9 @@ VITE_DEV=true
# 请求路径
# VITE_BASE_URL='http://localhost:48080'
VITE_BASE_URL='http://47.98.161.246:48080'
# VITE_BASE_URL='http://47.98.161.246:48080'
# VITE_BASE_URL='http://114.55.169.15:48080'
# VITE_BASE_URL='http://114.215.207.150:48080'
VITE_BASE_URL='http://114.215.207.150:48080'
# 上传路径
VITE_UPLOAD_URL='http://47.98.161.246:48080/admin-api/system/file/upload'

@ -2,7 +2,8 @@ import { store } from '../index'
import { defineStore } from 'pinia'
import { getAccessToken, removeToken } from '@/utils/auth'
import { CACHE_KEY } from '@/hooks/web/useCache'
import { getInfo, loginOut } from '@/api/login'
import { loginOut } from '@/api/login'
import { getUser as getUserInfo } from '@/api/system/user'
import cache from '@/plugins/cache'
@ -50,11 +51,17 @@ export const useUserStore = defineStore('admin-user', {
return null
}
let userInfo = cache.local.get(CACHE_KEY.USER)
if (!userInfo || !userInfo?.menus || userInfo.menus.length == 0) {
userInfo = await getInfo({})
// if (!userInfo || !userInfo?.menus || userInfo.menus.length == 0) {
// userInfo = await getInfo({})
// }
if (!userInfo?.user) {
const userId = localStorage.getItem('userId')
userInfo = {
user: await getUserInfo(Number(userId))
}
}
this.permissions = userInfo.permissions
this.roles = userInfo.roles
// this.permissions = userInfo.permissions
// this.roles = userInfo.roles
this.user = userInfo.user
this.isSetUser = true
cache.local.set(CACHE_KEY.USER, userInfo)

@ -1,5 +1,5 @@
<template>
<Error type="403" @error-click="push('/Home/index')" />
<Error type="403" @error-click="push('/index')" />
</template>
<script lang="ts" name="Error403" setup>
const { push } = useRouter()

@ -1,5 +1,5 @@
<template>
<Error @error-click="push('/Home/index')" />
<Error @error-click="push('/index')" />
</template>
<script lang="ts" name="Error404" setup>
const { push } = useRouter()

@ -1,5 +1,5 @@
<template>
<Error type="500" @error-click="push('/Home/index')" />
<Error type="500" @error-click="push('/index')" />
</template>
<script lang="ts" name="Error500" setup>
const { push } = useRouter()

@ -200,6 +200,8 @@ const handleLogin = async (params) => {
if (res?.tenantId) {
authUtil.setTenantId(res.tenantId)
}
// userId
localStorage.setItem('userId', res.userId)
ElLoading.service({
lock: true,

Loading…
Cancel
Save