Compare commits
5 Commits
1a1fc0fbf9
...
1039122a2b
| Author | SHA1 | Date | |
|---|---|---|---|
| 1039122a2b | |||
|
|
893f827643 | ||
|
|
a4af107652 | ||
|
|
d60fd3eb4c | ||
|
|
95e923841d |
@@ -75,7 +75,7 @@ export const useDictStore = defineStore('dict', {
|
|||||||
},
|
},
|
||||||
async resetDict() {
|
async resetDict() {
|
||||||
cache.session.delete(CACHE_KEY.DICT_CACHE)
|
cache.session.delete(CACHE_KEY.DICT_CACHE)
|
||||||
const res = await listSimpleDictData()
|
const res = (await listSimpleDictData()) || []
|
||||||
// 设置数据
|
// 设置数据
|
||||||
const dictDataMap = new Map<string, any>()
|
const dictDataMap = new Map<string, any>()
|
||||||
res.forEach((dictData: DictDataVO) => {
|
res.forEach((dictData: DictDataVO) => {
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import { store } from '../index'
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { getAccessToken, removeToken } from '@/utils/auth'
|
import { getAccessToken, removeToken } from '@/utils/auth'
|
||||||
import { CACHE_KEY } from '@/hooks/web/useCache'
|
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'
|
import cache from '@/plugins/cache'
|
||||||
|
|
||||||
@@ -50,11 +51,17 @@ export const useUserStore = defineStore('admin-user', {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
let userInfo = cache.local.get(CACHE_KEY.USER)
|
let userInfo = cache.local.get(CACHE_KEY.USER)
|
||||||
if (!userInfo || !userInfo?.menus || userInfo.menus.length == 0) {
|
// if (!userInfo || !userInfo?.menus || userInfo.menus.length == 0) {
|
||||||
userInfo = await getInfo({})
|
// 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.user = userInfo.user
|
||||||
this.isSetUser = true
|
this.isSetUser = true
|
||||||
cache.local.set(CACHE_KEY.USER, userInfo)
|
cache.local.set(CACHE_KEY.USER, userInfo)
|
||||||
@@ -63,7 +70,7 @@ export const useUserStore = defineStore('admin-user', {
|
|||||||
async loginOut() {
|
async loginOut() {
|
||||||
await loginOut()
|
await loginOut()
|
||||||
removeToken()
|
removeToken()
|
||||||
cache.local.clear()
|
// cache.local.clear()
|
||||||
this.resetState()
|
this.resetState()
|
||||||
},
|
},
|
||||||
resetState() {
|
resetState() {
|
||||||
|
|||||||
@@ -9,26 +9,34 @@ const RefreshTokenKey = 'REFRESH_TOKEN'
|
|||||||
// 获取token
|
// 获取token
|
||||||
export const getAccessToken = () => {
|
export const getAccessToken = () => {
|
||||||
// 此处与TokenKey相同,此写法解决初始化时Cookies中不存在TokenKey报错
|
// 此处与TokenKey相同,此写法解决初始化时Cookies中不存在TokenKey报错
|
||||||
return cache.local.get(AccessTokenKey)
|
return localStorage.getItem(AccessTokenKey)
|
||||||
? cache.local.get(AccessTokenKey)
|
? localStorage.getItem(AccessTokenKey)
|
||||||
: cache.local.get('ACCESS_TOKEN')
|
: localStorage.getItem('ACCESS_TOKEN')
|
||||||
|
// return cache.local.get(AccessTokenKey)
|
||||||
|
// ? cache.local.get(AccessTokenKey)
|
||||||
|
// : cache.local.get('ACCESS_TOKEN')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新token
|
// 刷新token
|
||||||
export const getRefreshToken = () => {
|
export const getRefreshToken = () => {
|
||||||
return cache.local.get(RefreshTokenKey)
|
return localStorage.getItem(RefreshTokenKey)
|
||||||
|
// return cache.local.get(RefreshTokenKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置token
|
// 设置token
|
||||||
export const setToken = (token: TokenType) => {
|
export const setToken = (token: TokenType) => {
|
||||||
cache.local.set(RefreshTokenKey, token.refreshToken)
|
localStorage.setItem(AccessTokenKey, token.accessToken)
|
||||||
cache.local.set(AccessTokenKey, token.accessToken)
|
localStorage.setItem(RefreshTokenKey, token.refreshToken)
|
||||||
|
// cache.local.set(RefreshTokenKey, token.refreshToken)
|
||||||
|
// cache.local.set(AccessTokenKey, token.accessToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除token
|
// 删除token
|
||||||
export const removeToken = () => {
|
export const removeToken = () => {
|
||||||
cache.local.delete(AccessTokenKey)
|
localStorage.removeItem(AccessTokenKey)
|
||||||
cache.local.delete(RefreshTokenKey)
|
localStorage.removeItem(RefreshTokenKey)
|
||||||
|
// cache.local.delete(AccessTokenKey)
|
||||||
|
// cache.local.delete(RefreshTokenKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 格式化token(jwt格式) */
|
/** 格式化token(jwt格式) */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<Error type="403" @error-click="push('/Home/index')" />
|
<Error type="403" @error-click="push('/index')" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" name="Error403" setup>
|
<script lang="ts" name="Error403" setup>
|
||||||
const { push } = useRouter()
|
const { push } = useRouter()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<Error @error-click="push('/Home/index')" />
|
<Error @error-click="push('/index')" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" name="Error404" setup>
|
<script lang="ts" name="Error404" setup>
|
||||||
const { push } = useRouter()
|
const { push } = useRouter()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<Error type="500" @error-click="push('/Home/index')" />
|
<Error type="500" @error-click="push('/index')" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" name="Error500" setup>
|
<script lang="ts" name="Error500" setup>
|
||||||
const { push } = useRouter()
|
const { push } = useRouter()
|
||||||
|
|||||||
@@ -6,11 +6,16 @@
|
|||||||
v-for="item in appList"
|
v-for="item in appList"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
shadow="hover"
|
shadow="hover"
|
||||||
class="width-200px"
|
class="app-card"
|
||||||
@click="handleAppClick(item)"
|
@click="handleAppClick(item)"
|
||||||
>
|
>
|
||||||
<!-- card body -->
|
<!-- card body -->
|
||||||
<el-image :src="item.clientLogo" fit="fill" :lazy="true" style="width: 180px" />
|
<el-image
|
||||||
|
:src="item.clientLogo"
|
||||||
|
fit="fill"
|
||||||
|
:lazy="true"
|
||||||
|
style="width: 180px; height: 180px; border-radius: 10px; background-color: #fff"
|
||||||
|
/>
|
||||||
<div class="cutout-text">{{ item.clientName }}</div>
|
<div class="cutout-text">{{ item.clientName }}</div>
|
||||||
|
|
||||||
<template #footer v-if="item.clientDescription">
|
<template #footer v-if="item.clientDescription">
|
||||||
@@ -42,10 +47,14 @@ function handleAppClick(item) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
::v-deep(.app-card) {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
::v-deep(.el-card__body) {
|
::v-deep(.el-card__body) {
|
||||||
background-color: #001529;
|
background-color: #000;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
min-width: 260px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cutout-text {
|
.cutout-text {
|
||||||
@@ -53,7 +62,7 @@ function handleAppClick(item) {
|
|||||||
font-size: 40px;
|
font-size: 40px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
-webkit-text-stroke: 1px #9a9acc;
|
-webkit-text-stroke: 1px #9a9acc;
|
||||||
color: #001529;
|
color: #000;
|
||||||
&::before {
|
&::before {
|
||||||
content: ' ';
|
content: ' ';
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -72,7 +81,7 @@ function handleAppClick(item) {
|
|||||||
width: 200%;
|
width: 200%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: radial-gradient(circle, #fff, #000 50%);
|
background: radial-gradient(circle, #fff, #000 50%);
|
||||||
background-size: 25% 30%;
|
background-size: 25% 1%;
|
||||||
mix-blend-mode: color-dodge;
|
mix-blend-mode: color-dodge;
|
||||||
animation: mix 4s linear infinite;
|
animation: mix 4s linear infinite;
|
||||||
background-repeat: repeat;
|
background-repeat: repeat;
|
||||||
|
|||||||
@@ -200,6 +200,8 @@ const handleLogin = async (params) => {
|
|||||||
if (res?.tenantId) {
|
if (res?.tenantId) {
|
||||||
authUtil.setTenantId(res.tenantId)
|
authUtil.setTenantId(res.tenantId)
|
||||||
}
|
}
|
||||||
|
// 设置userId
|
||||||
|
localStorage.setItem('userId', res.userId)
|
||||||
|
|
||||||
ElLoading.service({
|
ElLoading.service({
|
||||||
lock: true,
|
lock: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user