feat:新增复制token
This commit is contained in:
parent
34e03832a6
commit
d378ed3b57
@ -29,6 +29,9 @@
|
|||||||
<el-dropdown-item command="setLayout">
|
<el-dropdown-item command="setLayout">
|
||||||
<span>{{ $t('layout.layoutSetting') }}</span>
|
<span>{{ $t('layout.layoutSetting') }}</span>
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="copyToken">
|
||||||
|
<span>复制token</span>
|
||||||
|
</el-dropdown-item>
|
||||||
<el-dropdown-item divided command="logout">
|
<el-dropdown-item divided command="logout">
|
||||||
<span>{{ $t('layout.logOut') }}</span>
|
<span>{{ $t('layout.logOut') }}</span>
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
@ -53,7 +56,7 @@ import LangSelect from '@/components/LangSelect/index'
|
|||||||
import useAppStore from '@/store/modules/app'
|
import useAppStore from '@/store/modules/app'
|
||||||
import useUserStore from '@/store/modules/user'
|
import useUserStore from '@/store/modules/user'
|
||||||
import useSettingsStore from '@/store/modules/settings'
|
import useSettingsStore from '@/store/modules/settings'
|
||||||
|
import { useClipboard } from '@vueuse/core'
|
||||||
const { proxy } = getCurrentInstance()
|
const { proxy } = getCurrentInstance()
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
@ -72,21 +75,34 @@ function handleCommand(command) {
|
|||||||
case 'logout':
|
case 'logout':
|
||||||
logout()
|
logout()
|
||||||
break
|
break
|
||||||
|
case 'copyToken':
|
||||||
|
copyText(userStore.token)
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { copy, isSupported } = useClipboard()
|
||||||
|
const copyText = async (val) => {
|
||||||
|
if (isSupported) {
|
||||||
|
copy(val)
|
||||||
|
proxy.$modal.msgSuccess('复制成功!')
|
||||||
|
} else {
|
||||||
|
alert(val)
|
||||||
|
proxy.$modal.msgError('当前浏览器不支持')
|
||||||
|
}
|
||||||
|
}
|
||||||
function logout() {
|
function logout() {
|
||||||
proxy
|
proxy
|
||||||
.$confirm(proxy.$t('layout.logOutConfirm'), proxy.$t('common.tips'), {
|
.$confirm(proxy.$t('layout.logOutConfirm'), proxy.$t('common.tips'), {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning',
|
type: 'warning'
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
userStore.logOut().then(() => {
|
userStore.logOut().then(() => {
|
||||||
location.href = import.meta.env.VITE_APP_ROUTER_PREFIX + 'index';
|
location.href = import.meta.env.VITE_APP_ROUTER_PREFIX + 'index'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(() => {})
|
.catch(() => {})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user