Browse Source

新增部门名称字段,优化用户信息展示

master
parent
commit
1a70eebcbf
  1. 7
      src/layout/components/UserInfo/src/UserInfo.vue
  2. 8
      src/store/modules/user.ts
  3. 1
      src/views/Home/Index.vue
  4. 144
      src/views/Login/components/QrCodeForm.vue

7
src/layout/components/UserInfo/src/UserInfo.vue

@ -24,7 +24,8 @@ const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('user-info') const prefixCls = getPrefixCls('user-info')
const avatar = computed(() => userStore.user.avatar || avatarImg) const avatar = computed(() => userStore.user.avatar || avatarImg)
const realName=computed(()=>userStore.user.realName ?? '管理员') const realName = computed(() => userStore.user.realName ?? '管理员')
const deptName = computed(() => userStore.user.deptName ?? '管理员')
// //
const lockStore = useLockStore() const lockStore = useLockStore()
const getIsLock = computed(() => lockStore.getLockInfo?.isLock ?? false) const getIsLock = computed(() => lockStore.getLockInfo?.isLock ?? false)
@ -56,9 +57,9 @@ const toDocument = () => {
<template> <template>
<ElDropdown class="custom-hover" :class="prefixCls" trigger="click"> <ElDropdown class="custom-hover" :class="prefixCls" trigger="click">
<div class="flex items-center gap-4px"> <div class="flex items-center gap-4px">
<ElAvatar :src="avatar" alt="" :size="32" class=" rounded-[50%]" /> <ElAvatar :src="avatar" alt="" :size="32" class="rounded-[50%]" />
<span class="text-14px color-#303133 font-500 line-height-22px"> <span class="text-14px color-#303133 font-500 line-height-22px">
{{ realName }}|{{}} {{ realName }} | {{ deptName }}
</span> </span>
</div> </div>
<template #dropdown> <template #dropdown>

8
src/store/modules/user.ts

@ -11,7 +11,8 @@ interface UserVO {
avatar: string avatar: string
nickname: string nickname: string
deptId: number, deptId: number,
realName:string realName:string,
deptName:string,
} }
interface UserInfoVO { interface UserInfoVO {
@ -33,6 +34,7 @@ export const useUserStore = defineStore('admin-user', {
nickname: '', nickname: '',
deptId: 0, deptId: 0,
realName: '', realName: '',
deptName:''
} }
}), }),
getters: { getters: {
@ -58,7 +60,6 @@ export const useUserStore = defineStore('admin-user', {
let userInfo = wsCache.get(CACHE_KEY.USER) let userInfo = wsCache.get(CACHE_KEY.USER)
if (!userInfo) { if (!userInfo) {
userInfo = await getInfo() userInfo = await getInfo()
console.log(userInfo)
} }
this.permissions = userInfo.permissions this.permissions = userInfo.permissions
this.roles = userInfo.roles this.roles = userInfo.roles
@ -96,7 +97,8 @@ export const useUserStore = defineStore('admin-user', {
avatar: '', avatar: '',
nickname: '', nickname: '',
deptId: 0, deptId: 0,
realName:'' realName:'',
deptName:''
} }
} }
} }

1
src/views/Home/Index.vue

@ -491,7 +491,6 @@ const getPieData = async () => {
// 6 // 6
const getS3Data = async () => { const getS3Data = async () => {
const res = await HomeApi.getTaskNumDoing(queryParams) const res = await HomeApi.getTaskNumDoing(queryParams)
console.log(res)
let data1 = [] as any let data1 = [] as any
let data2 = [] as any let data2 = [] as any
res.forEach((item: any) => { res.forEach((item: any) => {

144
src/views/Login/components/QrCodeForm.vue

@ -3,15 +3,30 @@
<el-col :span="24" style="padding-right: 10px; padding-left: 10px"> <el-col :span="24" style="padding-right: 10px; padding-left: 10px">
<img class="topImg" src="@/assets/imgs/screen/login-top.png" alt="logo" /> <img class="topImg" src="@/assets/imgs/screen/login-top.png" alt="logo" />
</el-col> </el-col>
<el-col :span="24" style="padding-right: 10px; padding-left: 10px; margin-bottom:20px; text-align: center"> <el-col
:span="24"
<img width="320px" height="320px" :src="imageUrl" alt="Converted Image" v-if="imageUrl" /> style="padding-right: 10px; padding-left: 10px; margin-bottom: 20px; text-align: center"
>
<img width="320px" height="320px" :src="imageUrl" alt="Converted Image" v-if="imageUrl" />
</el-col> </el-col>
<el-col v-if="!refreshQR" :span="24" style="padding-right: 10px; padding-left: 10px; text-align: center"> <el-col
<img class="bottomImg" src="@/assets/imgs/screen/login-bottom.png" alt="logo" /> v-if="!refreshQR"
:span="24"
style="padding-right: 10px; padding-left: 10px; text-align: center"
>
<img class="bottomImg" src="@/assets/imgs/screen/login-bottom.png" alt="logo" />
</el-col> </el-col>
<el-col v-if="refreshQR" :span="24" style="padding-right: 10px; padding-left: 10px; text-align: center"> <el-col
<img class="bottomImg" src="@/assets/imgs/screen/qrsx.png" alt="logo" @click="handleRefresh" /> v-if="refreshQR"
:span="24"
style="padding-right: 10px; padding-left: 10px; text-align: center"
>
<img
class="bottomImg"
src="@/assets/imgs/screen/qrsx.png"
alt="logo"
@click="handleRefresh"
/>
</el-col> </el-col>
</el-row> </el-row>
</template> </template>
@ -24,104 +39,103 @@ import { LoginStateEnum, useLoginState } from './useLogin'
import router from '@/router' import router from '@/router'
defineOptions({ name: 'QrCodeForm' }) defineOptions({ name: 'QrCodeForm' })
const imageUrl = ref(''); const imageUrl = ref('')
const uuuid =ref('') const uuuid = ref('')
const refreshQR = ref(false) const refreshQR = ref(false)
const { t } = useI18n() const { t } = useI18n()
const { handleBackLogin, getLoginState } = useLoginState() const { handleBackLogin, getLoginState } = useLoginState()
const getShow = computed(() => true) const getShow = computed(() => true)
// ID // ID
let intervalId = ref(); let intervalId = ref()
const handleRefresh = () => { const handleRefresh = () => {
window.location.reload() window.location.reload()
} }
const getimg =async ()=>{ const getimg = async () => {
const array = new Uint32Array(4)
const array = new Uint32Array(4); crypto.getRandomValues(array)
crypto.getRandomValues(array); let result = ''
let result = '';
array.forEach((value) => { array.forEach((value) => {
result += value.toString(16).padStart(8, '0'); result += value.toString(16).padStart(8, '0')
}); })
uuuid.value = result; uuuid.value = result
var mockBinaryData = await LoginApi.getCodeWebPic({ var mockBinaryData = await LoginApi.getCodeWebPic({
scene:uuuid.value, scene: uuuid.value,
path: 'sub/common/waiting', path: 'sub/common/waiting',
checkPath: false checkPath: false
}); })
// Base64 // Base64
const binaryString = atob(mockBinaryData); const binaryString = atob(mockBinaryData)
const len = binaryString.length; const len = binaryString.length
const bytes = new Uint8Array(len); const bytes = new Uint8Array(len)
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
bytes[i] = binaryString.charCodeAt(i); bytes[i] = binaryString.charCodeAt(i)
} }
// Blob // Blob
const blob = new Blob([bytes], { type: 'image/png' }); const blob = new Blob([bytes], { type: 'image/png' })
// URL // URL
imageUrl.value = URL.createObjectURL(blob); imageUrl.value = URL.createObjectURL(blob)
// //
refaulst(); refaulst()
} }
// //
const startTime = Date.now(); const startTime = Date.now()
// 10 // 10
const tenMinutes = 10 *60 * 10000 ; const tenMinutes = 10 * 60 * 10000
// //
const refaulst = ()=>{ const refaulst = () => {
refreshQR.value = false; refreshQR.value = false
// //
if (intervalId) { if (intervalId) {
clearInterval(intervalId.value); clearInterval(intervalId.value)
} }
// 5 // 5
intervalId.value = setInterval(async () => { intervalId.value = setInterval(async () => {
try { try {
// 10 // 10
if (Date.now() - startTime >= tenMinutes) { if (Date.now() - startTime >= tenMinutes) {
clearInterval(intervalId.value); clearInterval(intervalId.value)
console.log('定时器已停止,已过去 10 分钟。'); console.log('定时器已停止,已过去 10 分钟。')
refreshQR.value = true; refreshQR.value = true
return; return
} }
const res = await LoginApi.qrLoginCode({code:uuuid.value}) const res = await LoginApi.qrLoginCode({ code: uuuid.value })
if(res){ if (res) {
clearInterval(intervalId.value); clearInterval(intervalId.value)
authUtil.setToken(res) authUtil.setToken(res)
router.push({ path: '/' }) router.push({ path: '/' })
} }
} catch (error) { } catch (error) {
console.error('获取扫码状态失败:', error); console.error('获取扫码状态失败:', error)
} }
}, 5000); }, 5000)
} }
onMounted(() => { onMounted(() => {
// getCookie() // getCookie()
getimg() getimg()
}) })
onUnmounted(() => {
//
clearInterval(intervalId.value)
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.expired-text{ .expired-text {
color: #ff0000; color: #ff0000;
margin-top: 40px; margin-top: 40px;
margin-right: 10px; margin-right: 10px;
} }
.bottomImg{ .bottomImg {
width:320px; width: 320px;
}
.topImg {
} height: 200px;
.topImg{ }
height: 200px;
}
</style> </style>
Loading…
Cancel
Save