Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
corporate-culture-qd
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王立鹏
corporate-culture-qd
Commits
dc3a55b9
Commit
dc3a55b9
authored
Oct 27, 2026
by
lijiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【需求 25171】feat: 本地/测试环境新增切换用户悬浮按钮,通过选人组件带 code 重新登录
parent
02d595cd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
App.vue
src/App.vue
+2
-0
index.vue
src/components/common/DevUserSwitch/index.vue
+53
-0
No files found.
src/App.vue
View file @
dc3a55b9
...
...
@@ -10,12 +10,14 @@
<component
:is=
"Component"
/>
</router-view>
</el-config-provider>
<DevUserSwitch
/>
</
template
>
<
script
setup
lang=
"ts"
>
import
zhCn
from
'element-plus/es/locale/lang/zh-cn'
import
{
initWxConfig
}
from
'@/utils/wxUtil/initWXConfig'
import
{
Notivue
,
NotivueSwipe
,
Notification
,
pastelTheme
}
from
'notivue'
import
Progress
from
'@/components/common/Progress/index.vue'
import
DevUserSwitch
from
'@/components/common/DevUserSwitch/index.vue'
const
locale
=
ref
(
zhCn
)
...
...
src/components/common/DevUserSwitch/index.vue
0 → 100644
View file @
dc3a55b9
<
template
>
<template
v-if=
"enabled"
>
<!-- 平时只露一个头像圆点,鼠标移上去向左展开显示名字,不挡页面内容 -->
<div
class=
"group fixed right-4 bottom-40 z-3000 flex flex-row-reverse items-center h-10 pl-1 pr-1 rounded-full bg-gray-900/75 text-white shadow-lg backdrop-blur cursor-pointer select-none hover:bg-gray-900/90 transition-colors"
title=
"切换用户(仅测试环境可见)"
@
click=
"openPicker"
>
<el-avatar
:size=
"32"
:src=
"userInfo.avatar"
class=
"shrink-0"
>
<el-icon><IEpUser
/></el-icon>
</el-avatar>
<span
class=
"max-w-0 group-hover:max-w-32 overflow-hidden whitespace-nowrap text-sm opacity-0 group-hover:opacity-100 group-hover:pl-3 group-hover:pr-2 transition-all duration-300"
>
{{
userInfo
.
name
||
'切换用户'
}}
<span
class=
"text-xs text-white/60 ml-1"
>
切换用户
</span>
</span>
</div>
<DepartmentUserModal
ref=
"modalRef"
@
confirm=
"handleConfirm"
/>
</
template
>
</template>
<
script
setup
lang=
"ts"
>
/**
* 本地/测试环境切换登录用户的悬浮按钮,挂在 App.vue 上,前台后台共用。
*
* 切换方式就是在当前地址后面拼 ?code=账号@yswg.com.cn,路由守卫会用这个 code 重新登录,
* 登录完成后自动去掉 code,停留在当前页面。生产环境不显示。
* 注意不能用 import.meta.env.PROD 判断:测试环境也是 vite build 出来的,PROD 同样是 true。
*/
import
{
storeToRefs
}
from
'pinia'
import
{
useUserStore
}
from
'@/stores/user'
import
DepartmentUserModal
from
'@/components/common/DepartmentUserModal/index.vue'
import
type
{
DepartmentUserSelection
}
from
'@/components/common/DepartmentUserModal/types'
const
EMAIL_SUFFIX
=
'@yswg.com.cn'
const
enabled
=
import
.
meta
.
env
.
MODE
!==
'production'
const
{
userInfo
}
=
storeToRefs
(
useUserStore
())
const
modalRef
=
useTemplateRef
<
InstanceType
<
typeof
DepartmentUserModal
>>
(
'modalRef'
)
const
openPicker
=
()
=>
{
modalRef
.
value
?.
open
({
selectionMode
:
'user'
,
userValueField
:
'account'
,
multiple
:
false
})
}
const
handleConfirm
=
(
items
:
DepartmentUserSelection
[])
=>
{
const
account
=
items
[
0
]?.
valueId
if
(
!
account
)
return
const
url
=
new
URL
(
window
.
location
.
href
)
url
.
searchParams
.
set
(
'code'
,
`
${
account
}${
EMAIL_SUFFIX
}
`
)
window
.
location
.
href
=
url
.
toString
()
}
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment