feat(user-guide): update NewUserGuide and UserMenu for improved onboarding experience

- Refactored the NewUserGuide component to utilize a new event for opening the guide, enhancing event handling.
- Updated UserMenu to include a button for reopening the guide, improving accessibility for users.
- Enhanced localization strings to provide clearer instructions on accessing the guide from the user menu.
- Introduced a new command in the Global Command Palette to open the product tour, streamlining user onboarding.
- Added styles for new guide-related elements to improve visual consistency and user interaction.
This commit is contained in:
wizardchen
2026-06-03 15:33:23 +08:00
committed by lyingbug
parent bd1a764a91
commit 26895aadc9
9 changed files with 74 additions and 21 deletions
@@ -1,5 +1,6 @@
import type { Router } from 'vue-router'
import type { Composer } from 'vue-i18n'
import { openNewUserGuide } from '@/config/contextualGuides'
/**
* A single command that can be searched and invoked from the palette.
@@ -82,6 +83,16 @@ export function buildCommands(ctx: CommandContext): CmdkCommand[] {
router.push('/platform/settings')
},
},
{
id: 'open-product-tour',
label: t('commandPalette.quick.productTour'),
icon: 'help-circle',
keywords: ['guide', 'tour', 'onboarding', 'help', '引导', '新手', '教程'],
run: () => {
close()
openNewUserGuide()
},
},
]
}
+3 -5
View File
@@ -6,12 +6,10 @@
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
import SpotlightGuide from '@/components/SpotlightGuide.vue'
import { GLOBAL_USER_GUIDE_KEY } from '@/config/contextualGuides'
import { GLOBAL_USER_GUIDE_KEY, OPEN_NEW_USER_GUIDE_EVENT } from '@/config/contextualGuides'
import { useUIStore } from '@/stores/ui'
import type { SpotlightGuideStep } from '@/types/spotlightGuide'
const OPEN_EVENT = 'weknora:open-new-user-guide'
const uiStore = useUIStore()
let settingsOpenedByGuide = false
@@ -84,7 +82,7 @@ const handleOpenEvent = () => {
}
onMounted(() => {
window.addEventListener(OPEN_EVENT, handleOpenEvent)
window.addEventListener(OPEN_NEW_USER_GUIDE_EVENT, handleOpenEvent)
if (localStorage.getItem(GLOBAL_USER_GUIDE_KEY) !== '1') {
window.setTimeout(() => {
if (localStorage.getItem(GLOBAL_USER_GUIDE_KEY) !== '1') {
@@ -95,7 +93,7 @@ onMounted(() => {
})
onBeforeUnmount(() => {
window.removeEventListener(OPEN_EVENT, handleOpenEvent)
window.removeEventListener(OPEN_NEW_USER_GUIDE_EVENT, handleOpenEvent)
closeGuideSettings()
})
</script>
+42 -7
View File
@@ -38,7 +38,15 @@
<span v-else class="dropdown-user-avatar-placeholder">{{ userInitial }}</span>
</div>
<div class="dropdown-user-meta">
<div class="dropdown-user-name">{{ userName }}</div>
<div class="dropdown-user-name-row">
<span class="dropdown-user-name">{{ userName }}</span>
<t-tooltip :content="$t('newUserGuide.reopen')" placement="top">
<button type="button" class="dropdown-guide-btn" :aria-label="$t('newUserGuide.reopen')"
@click.stop="reopenGuide">
<t-icon name="help-circle" size="14px" />
</button>
</t-tooltip>
</div>
</div>
</div>
@@ -144,10 +152,6 @@
</svg>
</span>
</div>
<div class="menu-item" @click="reopenGuide">
<t-icon name="help-circle" class="menu-icon" />
<span>{{ $t('newUserGuide.reopen') }}</span>
</div>
<div class="menu-item" :title="$t('common.githubStarTip')" @click="openGithub">
<t-icon name="logo-github" class="menu-icon" />
<span class="menu-text-with-icon">
@@ -258,6 +262,7 @@ import {
import type { TenantInfo } from '@/api/tenant'
import { useRoleLabel, useHomeTenant } from '@/composables/useRoleLabel'
import { getRootZoom, rectToCssPx, cssViewportSize } from '@/utils/zoom'
import { openNewUserGuide } from '@/config/contextualGuides'
const { t } = useI18n()
@@ -631,10 +636,9 @@ const openClawhubSkill = () => {
window.open(CLAWHUB_SKILL_URL, '_blank')
}
// 重新打开新手引导
const reopenGuide = () => {
menuVisible.value = false
window.dispatchEvent(new CustomEvent('weknora:open-new-user-guide'))
openNewUserGuide()
}
// 打开 GitHub
@@ -935,7 +939,16 @@ onUnmounted(() => {
justify-content: center;
}
.dropdown-user-name-row {
display: flex;
align-items: center;
gap: 2px;
min-width: 0;
}
.dropdown-user-name {
flex: 1;
min-width: 0;
font-size: 14px;
font-weight: 500;
color: var(--td-text-color-primary);
@@ -944,6 +957,28 @@ onUnmounted(() => {
overflow: hidden;
text-overflow: ellipsis;
}
.dropdown-guide-btn {
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
width: 20px;
height: 20px;
margin: 0;
padding: 0;
border: none;
border-radius: 4px;
background: transparent;
color: var(--td-text-color-placeholder);
cursor: pointer;
transition: background-color 0.2s ease, color 0.2s ease;
&:hover {
background: var(--td-bg-color-container-hover);
color: var(--td-text-color-secondary);
}
}
}
// 下拉 — 当前工作区:与下方 .menu-item 同款对齐(左 16px 图标槽 + 文案列 + 右侧操作图标)