From d378ed3b57525ff4a34b4b26d00f671a730d3b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Fri, 26 Aug 2022 21:44:58 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=96=B0=E5=A2=9E=E5=A4=8D?= =?UTF-8?q?=E5=88=B6token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/Navbar.vue | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 3c23b25..aea5fc5 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -29,6 +29,9 @@ {{ $t('layout.layoutSetting') }} + + 复制token + {{ $t('layout.logOut') }} @@ -53,7 +56,7 @@ import LangSelect from '@/components/LangSelect/index' import useAppStore from '@/store/modules/app' import useUserStore from '@/store/modules/user' import useSettingsStore from '@/store/modules/settings' - +import { useClipboard } from '@vueuse/core' const { proxy } = getCurrentInstance() const appStore = useAppStore() const userStore = useUserStore() @@ -72,21 +75,34 @@ function handleCommand(command) { case 'logout': logout() break + case 'copyToken': + copyText(userStore.token) + break default: break } } +const { copy, isSupported } = useClipboard() +const copyText = async (val) => { + if (isSupported) { + copy(val) + proxy.$modal.msgSuccess('复制成功!') + } else { + alert(val) + proxy.$modal.msgError('当前浏览器不支持') + } +} function logout() { proxy .$confirm(proxy.$t('layout.logOutConfirm'), proxy.$t('common.tips'), { confirmButtonText: '确定', cancelButtonText: '取消', - type: 'warning', + type: 'warning' }) .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(() => {})