feat(tour): implement new user guide component and integrate into user menu

- Added a NewUserGuide component to provide a guided tour for new users.
- Integrated the guide into the UserMenu for easy access, allowing users to reopen the guide at any time.
- Updated localization files to include new strings for the user guide steps and actions.
- Enhanced the menu item for the user button to include a data attribute for better accessibility.

This feature aims to improve user onboarding and enhance the overall user experience by providing contextual help throughout the application.
This commit is contained in:
wizardchen
2026-06-03 00:31:39 +08:00
committed by lyingbug
parent 09a8607cd4
commit baef12e682
9 changed files with 731 additions and 48 deletions
+544
View File
@@ -0,0 +1,544 @@
<template>
<Teleport to="body">
<Transition name="guide-fade">
<div v-if="active" class="guide" role="dialog" aria-modal="true"
:aria-label="t('newUserGuide.steps.welcome.title')" @keydown.esc.prevent="dismiss" @keydown.left.prevent="prev"
@keydown.right.prevent="next" tabindex="-1" ref="rootRef">
<!-- 四块暗色挡板围住高亮区:中间留出真实空洞(DOM 上无任何元素),
点击直接穿透到下层控件;四周挡板拦截点击,避免引导期间误触。 -->
<template v-if="hole">
<div v-for="(piece, i) in backdropPieces" :key="i" class="guide__backdrop" :style="piece" />
</template>
<div v-else class="guide__backdrop guide__backdrop--full" />
<!-- 高亮描边 -->
<div v-if="hole" class="guide__ring" :style="ringStyle" aria-hidden="true" />
<!-- 说明卡片 -->
<div ref="cardRef" class="guide__card" :class="{ 'guide__card--center': !hole }" :style="cardStyle">
<button type="button" class="guide__close" :aria-label="t('newUserGuide.skip')" @click="dismiss">
<t-icon name="close" size="18px" />
</button>
<div class="guide__progress">
<span v-for="(s, i) in steps" :key="s.key" class="guide__dot"
:class="{ 'is-active': i === index, 'is-done': i < index }" />
</div>
<p class="guide__step-label">{{ t('newUserGuide.stepOf', { current: index + 1, total: steps.length }) }}</p>
<h3 class="guide__title">{{ stepTitle }}</h3>
<p class="guide__desc">{{ stepDesc }}</p>
<div class="guide__actions">
<button type="button" class="guide__skip" @click="dismiss">{{ t('newUserGuide.skip') }}</button>
<div class="guide__actions-main">
<t-button v-if="index > 0" size="small" variant="outline" @click="prev">
{{ t('newUserGuide.prev') }}
</t-button>
<t-button v-if="!isLast" size="small" theme="primary" @click="next">
{{ t('newUserGuide.next') }}
</t-button>
<t-button v-else size="small" theme="primary" @click="finish">
{{ t('newUserGuide.done') }}
</t-button>
</div>
</div>
</div>
</div>
</Transition>
</Teleport>
</template>
<script setup lang="ts">
import { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { useUIStore } from '@/stores/ui'
const STORAGE_KEY = 'weknora:new-user-guide-done:v1'
const OPEN_EVENT = 'weknora:open-new-user-guide'
const CARD_WIDTH = 340
const GAP = 16
const EDGE = 16
const PAD = 8
const holeRadius = 10
type Placement = 'right' | 'left' | 'bottom' | 'top'
interface GuideStep {
key: string
/** 高亮目标的 CSS 选择器;缺省表示居中卡片(欢迎 / 结束) */
target?: string
/** 优先放置方位 */
placement?: Placement
/** 进入该步骤前的准备动作(如展开侧栏、切换路由) */
before?: () => void | Promise<void>
/** 目标不存在时是否跳过该步骤(角色/版本可能隐藏入口) */
optional?: boolean
}
const { t } = useI18n()
const uiStore = useUIStore()
let settingsOpenedByGuide = false
// 顺序按真实使用依赖编排:先配模型(硬前置)→ 建知识库 → 对话 → 智能体
// → 设置入口 → 完成。
const steps = computed<GuideStep[]>(() => [
{ key: 'welcome' },
{
key: 'knowledge',
target: '[data-guide="nav-knowledge-bases"]',
placement: 'right',
before: () => uiStore.expandSidebar(),
},
{
key: 'agents',
target: '[data-guide="nav-agents"]',
placement: 'right',
optional: true,
before: () => uiStore.expandSidebar(),
},
{
key: 'chat',
target: '[data-guide="nav-creatChat"]',
placement: 'right',
before: () => uiStore.expandSidebar(),
},
{
key: 'settings',
target: '[data-guide="user-menu"]',
placement: 'right',
before: () => uiStore.expandSidebar(),
},
{
// 模型配置在「设置」弹窗内:引导自动打开弹窗并高亮「添加模型」。
key: 'models',
target: '[data-guide="settings-add-model"], [data-guide="settings-models"]',
placement: 'left',
before: () => {
uiStore.openSettings('models')
settingsOpenedByGuide = true
},
},
{ key: 'done' },
])
const active = ref(false)
const index = ref(0)
const vw = ref(window.innerWidth)
const vh = ref(window.innerHeight)
const targetRect = ref<DOMRect | null>(null)
const cardSize = ref({ width: CARD_WIDTH, height: 220 })
const rootRef = ref<HTMLElement | null>(null)
const cardRef = ref<HTMLElement | null>(null)
let retryTimer: ReturnType<typeof setTimeout> | null = null
const step = computed(() => steps.value[index.value] ?? steps.value[0])
const isLast = computed(() => index.value === steps.value.length - 1)
const stepTitle = computed(() => t(`newUserGuide.steps.${step.value.key}.title`))
const stepDesc = computed(() => t(`newUserGuide.steps.${step.value.key}.desc`))
const hole = computed(() => {
const r = targetRect.value
if (!r) return null
return {
x: Math.max(0, r.left - PAD),
y: Math.max(0, r.top - PAD),
width: r.width + PAD * 2,
height: r.height + PAD * 2,
}
})
const backdropPieces = computed(() => {
const h = hole.value
if (!h) return []
const w = vw.value
const v = vh.value
return [
// 上
{ top: '0px', left: '0px', width: `${w}px`, height: `${h.y}px` },
// 下
{ top: `${h.y + h.height}px`, left: '0px', width: `${w}px`, height: `${Math.max(0, v - h.y - h.height)}px` },
// 左
{ top: `${h.y}px`, left: '0px', width: `${h.x}px`, height: `${h.height}px` },
// 右
{ top: `${h.y}px`, left: `${h.x + h.width}px`, width: `${Math.max(0, w - h.x - h.width)}px`, height: `${h.height}px` },
]
})
const ringStyle = computed(() => {
if (!hole.value) return {}
return {
left: `${hole.value.x}px`,
top: `${hole.value.y}px`,
width: `${hole.value.width}px`,
height: `${hole.value.height}px`,
borderRadius: `${holeRadius}px`,
}
})
const overlaps = (
a: { left: number; top: number; right: number; bottom: number },
b: { left: number; top: number; right: number; bottom: number },
) => !(a.right <= b.left || a.left >= b.right || a.bottom <= b.top || a.top >= b.bottom)
const cardStyle = computed(() => {
const w = Math.min(CARD_WIDTH, vw.value - EDGE * 2)
const h = cardSize.value.height
const h0 = hole.value
if (!h0) {
return {
width: `${w}px`,
left: `${(vw.value - w) / 2}px`,
top: `${Math.max(EDGE, vh.value * 0.32 - h / 2)}px`,
}
}
const holeBox = { left: h0.x, top: h0.y, right: h0.x + h0.width, bottom: h0.y + h0.height }
const order: Placement[] = (() => {
const pref = step.value.placement ?? 'right'
const all: Placement[] = ['right', 'left', 'bottom', 'top']
return [pref, ...all.filter((p) => p !== pref)]
})()
const candidates: Record<Placement, { left: number; top: number }> = {
right: { left: holeBox.right + GAP, top: h0.y + h0.height / 2 - h / 2 },
left: { left: holeBox.left - w - GAP, top: h0.y + h0.height / 2 - h / 2 },
bottom: { left: h0.x + h0.width / 2 - w / 2, top: holeBox.bottom + GAP },
top: { left: h0.x + h0.width / 2 - w / 2, top: holeBox.top - h - GAP },
}
for (const place of order) {
const c = candidates[place]
const left = Math.min(Math.max(EDGE, c.left), vw.value - w - EDGE)
const top = Math.min(Math.max(EDGE, c.top), vh.value - h - EDGE)
const cardBox = { left, top, right: left + w, bottom: top + h }
if (!overlaps(cardBox, holeBox)) {
return { width: `${w}px`, left: `${left}px`, top: `${top}px` }
}
}
// 兜底:底部居中
const left = Math.min(Math.max(EDGE, (vw.value - w) / 2), vw.value - w - EDGE)
const top = Math.min(Math.max(EDGE, holeBox.bottom + GAP), vh.value - h - EDGE)
return { width: `${w}px`, left: `${left}px`, top: `${top}px` }
})
// 支持以逗号分隔的多个候选选择器,按书写顺序优先匹配(用于「优先高亮按钮、
// 否则退化为标题」这类带降级的目标)。
const queryTarget = (selector?: string): HTMLElement | null => {
if (!selector) return null
for (const part of selector.split(',').map((s) => s.trim()).filter(Boolean)) {
const el = document.querySelector<HTMLElement>(part)
if (!el) continue
const r = el.getBoundingClientRect()
if (r.width > 2 && r.height > 2) return el
}
return null
}
const measureCard = async () => {
await nextTick()
if (cardRef.value) {
cardSize.value = {
width: cardRef.value.offsetWidth,
height: cardRef.value.offsetHeight,
}
}
}
const locate = async (retry = 0) => {
vw.value = window.innerWidth
vh.value = window.innerHeight
const cur = step.value
if (!cur.target) {
targetRect.value = null
await measureCard()
return
}
const el = queryTarget(cur.target)
if (!el) {
if (retry < 12) {
if (retryTimer) clearTimeout(retryTimer)
retryTimer = setTimeout(() => locate(retry + 1), 120)
return
}
// 找不到目标:可选步骤跳过,否则退化为居中卡片
if (cur.optional) {
goTo(index.value + 1)
return
}
targetRect.value = null
await measureCard()
return
}
el.scrollIntoView({ block: 'nearest', inline: 'nearest', behavior: 'smooth' })
targetRect.value = el.getBoundingClientRect()
await measureCard()
}
const closeGuideSettings = () => {
if (settingsOpenedByGuide) {
uiStore.closeSettings()
settingsOpenedByGuide = false
}
}
const goTo = async (i: number) => {
if (i < 0 || i >= steps.value.length) return
if (retryTimer) {
clearTimeout(retryTimer)
retryTimer = null
}
index.value = i
// 离开模型步骤时,关闭由引导自己打开的设置弹窗
if (step.value.key !== 'models') {
closeGuideSettings()
}
await step.value.before?.()
// 等路由/侧栏/弹窗过渡稳定
await new Promise((r) => setTimeout(r, step.value.before ? 280 : 0))
await locate()
await nextTick()
rootRef.value?.focus()
}
const next = () => goTo(index.value + 1)
const prev = () => goTo(index.value - 1)
const open = async () => {
active.value = true
index.value = 0
await nextTick()
await goTo(0)
}
const close = () => {
if (retryTimer) {
clearTimeout(retryTimer)
retryTimer = null
}
closeGuideSettings()
active.value = false
targetRect.value = null
}
const finish = () => {
localStorage.setItem(STORAGE_KEY, '1')
close()
}
const dismiss = () => finish()
const onViewportChange = () => {
if (!active.value) return
locate()
}
const handleOpenEvent = () => {
if (active.value) return
open()
}
onMounted(() => {
window.addEventListener('resize', onViewportChange)
window.addEventListener('scroll', onViewportChange, true)
window.addEventListener(OPEN_EVENT, handleOpenEvent)
if (localStorage.getItem(STORAGE_KEY) !== '1') {
window.setTimeout(() => {
if (localStorage.getItem(STORAGE_KEY) !== '1') open()
}, 700)
}
})
onBeforeUnmount(() => {
window.removeEventListener('resize', onViewportChange)
window.removeEventListener('scroll', onViewportChange, true)
window.removeEventListener(OPEN_EVENT, handleOpenEvent)
closeGuideSettings()
if (retryTimer) clearTimeout(retryTimer)
})
</script>
<style lang="less" scoped>
.guide {
position: fixed;
inset: 0;
z-index: 5000;
outline: none;
pointer-events: none;
}
// 四块挡板拦截点击;中间的空洞没有任何元素,因此点击会穿透到下层真实控件。
.guide__backdrop {
position: fixed;
pointer-events: auto;
background: rgba(15, 18, 22, 0.58);
transition:
top 0.28s cubic-bezier(0.4, 0, 0.2, 1),
left 0.28s cubic-bezier(0.4, 0, 0.2, 1),
width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
height 0.28s cubic-bezier(0.4, 0, 0.2, 1);
&--full {
inset: 0;
}
}
.guide__ring {
position: fixed;
pointer-events: none;
border: 2px solid var(--td-brand-color);
box-shadow: 0 0 0 4px rgba(7, 192, 95, 0.18);
transition:
top 0.28s cubic-bezier(0.4, 0, 0.2, 1),
left 0.28s cubic-bezier(0.4, 0, 0.2, 1),
width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
height 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.guide__card {
position: fixed;
z-index: 1;
pointer-events: auto;
display: flex;
flex-direction: column;
gap: 8px;
padding: 18px 18px 14px;
border-radius: 14px;
background: var(--td-bg-color-container);
border: 1px solid var(--td-component-stroke);
box-shadow: 0 20px 48px rgba(0, 0, 0, 0.18);
color: var(--td-text-color-primary);
max-height: calc(100vh - 32px);
overflow-y: auto;
transition:
top 0.28s cubic-bezier(0.4, 0, 0.2, 1),
left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
&--center {
max-width: calc(100vw - 32px);
}
}
.guide__close {
position: absolute;
top: 10px;
right: 10px;
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
padding: 0;
border: none;
border-radius: 8px;
background: transparent;
color: var(--td-text-color-secondary);
cursor: pointer;
&:hover {
background: var(--td-bg-color-container-hover);
color: var(--td-text-color-primary);
}
}
.guide__progress {
display: flex;
gap: 5px;
}
.guide__dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--td-bg-color-component);
transition: width 0.2s ease, background 0.2s ease;
&.is-active {
width: 16px;
border-radius: 999px;
background: var(--td-brand-color);
}
&.is-done {
background: rgba(7, 192, 95, 0.4);
}
}
.guide__step-label {
margin: 6px 0 0;
font-size: 12px;
color: var(--td-text-color-placeholder);
}
.guide__title {
margin: 0;
padding-right: 24px;
font-size: 18px;
font-weight: 600;
line-height: 26px;
}
.guide__desc {
margin: 0;
font-size: 14px;
line-height: 22px;
color: var(--td-text-color-secondary);
}
.guide__actions {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-top: 4px;
padding-top: 10px;
border-top: 1px solid var(--td-component-stroke);
}
.guide__skip {
border: none;
background: transparent;
padding: 0;
font-size: 13px;
color: var(--td-text-color-placeholder);
cursor: pointer;
&:hover {
color: var(--td-text-color-secondary);
}
}
.guide__actions-main {
display: flex;
gap: 8px;
}
.guide-fade-enter-active,
.guide-fade-leave-active {
transition: opacity 0.2s ease;
}
.guide-fade-enter-from,
.guide-fade-leave-to {
opacity: 0;
}
@media (max-width: 720px) {
.guide__card {
left: 16px !important;
right: 16px;
width: auto !important;
top: auto !important;
bottom: 16px;
max-height: 56vh;
}
}
</style>
+11 -1
View File
@@ -1,7 +1,7 @@
<template>
<div class="user-menu" :class="{ 'user-menu--collapsed': uiStore.sidebarCollapsed }" ref="menuRef">
<!-- 用户按钮 -->
<div class="user-button" @click="toggleMenu">
<div class="user-button" data-guide="user-menu" @click="toggleMenu">
<div class="user-avatar">
<img v-if="userAvatar" :src="userAvatar" :alt="$t('common.avatar')" />
<span v-else class="avatar-placeholder">{{ userInitial }}</span>
@@ -144,6 +144,10 @@
</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">
@@ -627,6 +631,12 @@ const openClawhubSkill = () => {
window.open(CLAWHUB_SKILL_URL, '_blank')
}
// 重新打开新手引导
const reopenGuide = () => {
menuVisible.value = false
window.dispatchEvent(new CustomEvent('weknora:open-new-user-guide'))
}
// 打开 GitHub
const openGithub = () => {
menuVisible.value = false
+1 -1
View File
@@ -66,7 +66,7 @@
:key="index">
<t-tooltip :content="item.title" placement="right" :disabled="!uiStore.sidebarCollapsed">
<div @click="handleMenuClick(item.path)" @mouseenter="mouseenteMenu(item.path)"
@mouseleave="mouseleaveMenu(item.path)"
@mouseleave="mouseleaveMenu(item.path)" :data-guide="`nav-${item.path}`"
:class="['menu_item', item.childrenPath && item.childrenPath == currentpath ? 'menu_item_c_active' : isMenuItemActive(item.path) ? 'menu_item_active' : '']">
<div class="menu_item-box">
<div class="menu_icon">
+38
View File
@@ -27,6 +27,44 @@ export default {
expandSidebar: 'Expand Sidebar',
logoutSuccess: 'Logged out successfully',
},
newUserGuide: {
stepOf: '{current} / {total}',
skip: 'Skip',
prev: 'Back',
next: 'Next',
done: 'Done',
reopen: 'Product tour',
steps: {
welcome: {
title: 'Welcome to WeKnora',
desc: 'A few quick steps to get you familiar with knowledge bases, chat and agents. Click "Next" to begin.',
},
knowledge: {
title: 'Create your knowledge base',
desc: 'Everything starts here: upload documents, web pages or FAQs and WeKnora parses and indexes them automatically. Click here to open knowledge bases.',
},
chat: {
title: 'Start an AI chat',
desc: 'Ask questions grounded in your knowledge base and get accurate answers with cited sources. Click here to start a new chat.',
},
agents: {
title: 'Build dedicated agents',
desc: 'Combine knowledge bases, prompts and tools into reusable agents that capture your expertise.',
},
settings: {
title: 'Account & settings',
desc: 'Open this to manage your account, members and system settings. You can also reopen this tour from here anytime.',
},
models: {
title: 'Configure your models',
desc: 'A key step: add chat, embedding and other models in Model Management so knowledge bases and chat can work. Click "Add model" to get started.',
},
done: {
title: 'You are all set',
desc: 'You now know the essentials — start building your knowledge assistant! You can revisit this tour from the user menu anytime.',
},
},
},
batchManage: {
title: 'Manage Conversations',
selectAll: 'Select All',
+38
View File
@@ -27,6 +27,44 @@ export default {
expandSidebar: "사이드바 펼치기",
logoutSuccess: "로그아웃되었습니다",
},
newUserGuide: {
stepOf: "{current} / {total}",
skip: "건너뛰기",
prev: "이전",
next: "다음",
done: "완료",
reopen: "사용 가이드",
steps: {
welcome: {
title: "WeKnora에 오신 것을 환영합니다",
desc: "몇 단계만으로 지식 베이스, 대화, 에이전트의 핵심 사용법을 안내합니다. '다음'을 눌러 시작하세요.",
},
knowledge: {
title: "지식 베이스 만들기",
desc: "모든 것의 시작점입니다. 문서, 웹페이지, FAQ를 업로드하면 WeKnora가 자동으로 분석하고 색인합니다. 여기를 클릭해 지식 베이스로 이동하세요.",
},
chat: {
title: "AI 대화 시작하기",
desc: "지식 베이스 내용을 기반으로 질문하고 출처가 포함된 정확한 답변을 받아보세요. 여기를 클릭해 새 대화를 시작하세요.",
},
agents: {
title: "전용 에이전트 구축",
desc: "지식 베이스, 프롬프트, 도구를 결합해 재사용 가능한 에이전트로 전문성을 축적하세요.",
},
settings: {
title: "계정 및 설정 입구",
desc: "여기를 열면 계정, 멤버, 시스템 설정을 관리할 수 있습니다. 이 가이드도 이 메뉴에서 언제든 다시 열 수 있습니다.",
},
models: {
title: "모델 구성하기",
desc: "핵심 단계입니다. 모델 관리에서 대화·임베딩 등 모델을 추가해야 지식 베이스와 대화 기능이 정상 작동합니다. '모델 추가'를 클릭해 시작하세요.",
},
done: {
title: "준비 완료",
desc: "핵심 기능을 모두 익혔습니다. 이제 나만의 지식 어시스턴트를 만들어 보세요! 사용자 메뉴에서 언제든 가이드를 다시 볼 수 있습니다.",
},
},
},
batchManage: {
title: "대화 관리",
selectAll: "전체 선택",
+38
View File
@@ -27,6 +27,44 @@ export default {
agents: 'Агенты',
organizations: 'Общие пространства'
},
newUserGuide: {
stepOf: '{current} / {total}',
skip: 'Пропустить',
prev: 'Назад',
next: 'Далее',
done: 'Готово',
reopen: 'Обучение',
steps: {
welcome: {
title: 'Добро пожаловать в WeKnora',
desc: 'Несколько простых шагов познакомят вас с базами знаний, чатом и агентами. Нажмите «Далее», чтобы начать.',
},
knowledge: {
title: 'Создайте базу знаний',
desc: 'С этого всё начинается: загружайте документы, веб-страницы или FAQ, и WeKnora автоматически разберёт и проиндексирует их. Нажмите здесь, чтобы открыть базы знаний.',
},
chat: {
title: 'Начните чат с ИИ',
desc: 'Задавайте вопросы на основе вашей базы знаний и получайте точные ответы со ссылками на источники. Нажмите здесь, чтобы начать новый чат.',
},
agents: {
title: 'Создавайте собственных агентов',
desc: 'Объединяйте базы знаний, промпты и инструменты в переиспользуемых агентов, закрепляя свою экспертизу.',
},
settings: {
title: 'Аккаунт и настройки',
desc: 'Откройте это меню, чтобы управлять аккаунтом, участниками и системными настройками. Здесь же можно в любой момент снова открыть это обучение.',
},
models: {
title: 'Настройте модели',
desc: 'Ключевой шаг: добавьте модели чата, эмбеддингов и другие в управлении моделями, чтобы базы знаний и чат работали. Нажмите «Добавить модель», чтобы начать.',
},
done: {
title: 'Всё готово',
desc: 'Теперь вы знаете основы — начните создавать своего помощника на основе знаний! Вернуться к обучению можно в любой момент из меню пользователя.',
},
},
},
batchManage: {
title: 'Управление диалогами',
selectAll: 'Выбрать все',
+38
View File
@@ -27,6 +27,44 @@ export default {
expandSidebar: "展开侧边栏",
logoutSuccess: "已退出登录",
},
newUserGuide: {
stepOf: "{current} / {total}",
skip: "跳过引导",
prev: "上一步",
next: "下一步",
done: "完成",
reopen: "新手引导",
steps: {
welcome: {
title: "欢迎使用 WeKnora",
desc: "只需几步,带你快速了解知识库、对话与智能体的核心用法。点击「下一步」开始。",
},
knowledge: {
title: "创建你的知识库",
desc: "知识库是一切的起点:上传文档、网页或 FAQ,WeKnora 会自动解析并建立索引。点击这里进入知识库。",
},
chat: {
title: "发起智能对话",
desc: "基于知识库内容向 AI 提问,获得带引用来源的精准回答。点击这里开始新对话。",
},
agents: {
title: "打造专属智能体",
desc: "把知识库、提示词与工具组合成可复用的智能体,沉淀你的专业能力。",
},
settings: {
title: "账户与设置入口",
desc: "点开这里可以管理账户、成员与系统设置。需要再次查看本引导时,也可从该菜单重新打开。",
},
models: {
title: "配置你的模型",
desc: "这是关键一步:在模型管理中添加对话、向量等模型,知识库与对话功能才能正常工作。点击「添加模型」即可开始配置。",
},
done: {
title: "一切就绪",
desc: "你已经了解了核心功能,现在就开始构建你的知识助手吧!随时可从用户菜单重新查看引导。",
},
},
},
batchManage: {
title: "管理对话记录",
selectAll: "全选",
+3
View File
@@ -15,6 +15,8 @@
<!-- 全局右上角"待处理邀请"铃铛。固定定位,z-index 低于抽屉,业务页面
右侧抽屉弹出时会自然覆盖;仅在有待处理邀请时渲染。 -->
<GlobalInvitationBell />
<!-- 带遮罩层的新手引导:首次进入自动开启,可从用户菜单重新打开 -->
<NewUserGuide />
</div>
</template>
<script setup lang="ts">
@@ -26,6 +28,7 @@ import UploadMask from '@/components/upload-mask.vue'
import Settings from '@/views/settings/Settings.vue'
import GlobalCommandPalette from '@/components/GlobalCommandPalette.vue'
import GlobalInvitationBell from '@/components/GlobalInvitationBell.vue'
import NewUserGuide from '@/components/NewUserGuide.vue'
import { useCommandPaletteStore } from '@/stores/commandPalette'
import { getKnowledgeBaseById } from '@/api/knowledge-base/index'
import { MessagePlugin } from 'tdesign-vue-next'
+20 -46
View File
@@ -1,18 +1,14 @@
<template>
<div class="model-settings">
<div class="section-header">
<div class="section-header__top">
<div class="section-header__top" data-guide="settings-models">
<div class="section-header__text">
<h2>{{ $t('modelSettings.title') }}</h2>
<p class="section-description">{{ $t('modelSettings.description') }}</p>
</div>
<t-dropdown
v-if="authStore.hasRole('admin')"
:options="addModelOptions"
placement="bottom-right"
@click="(data: any) => openAddDialog(data.value)"
>
<t-button theme="primary" variant="outline" size="small">
<t-dropdown v-if="authStore.hasRole('admin')" :options="addModelOptions" placement="bottom-right"
@click="(data: any) => openAddDialog(data.value)">
<t-button theme="primary" variant="outline" size="small" data-guide="settings-add-model">
<template #icon><add-icon /></template>
{{ $t('modelSettings.actions.addModel') }}
</t-button>
@@ -42,44 +38,30 @@
<t-loading :loading="loading" size="small" class="model-list-loading">
<div v-if="filteredModels.length > 0" class="model-grid">
<div
v-for="model in filteredModels"
:key="`${model._modelType}-${model.id}`"
class="model-card"
:class="[
`model-card--${model._modelType}`,
{
'model-card--builtin': model.isBuiltin,
'model-card--clickable': isModelCardClickable(model),
},
]"
:role="isModelCardClickable(model) ? 'button' : undefined"
<div v-for="model in filteredModels" :key="`${model._modelType}-${model.id}`" class="model-card" :class="[
`model-card--${model._modelType}`,
{
'model-card--builtin': model.isBuiltin,
'model-card--clickable': isModelCardClickable(model),
},
]" :role="isModelCardClickable(model) ? 'button' : undefined"
:tabindex="isModelCardClickable(model) ? 0 : undefined"
@click="onModelCardClick($event, model._modelType, model)"
@keydown.enter="onModelCardClick($event, model._modelType, model)"
>
@keydown.enter="onModelCardClick($event, model._modelType, model)">
<div class="model-card__badge" :aria-label="typeLabel(model._modelType)">
<t-icon :name="typeIcon(model._modelType)" size="18px" />
</div>
<div class="model-card__body">
<div class="model-card__header">
<h3 class="model-card__title">{{ modelDisplayName(model) }}</h3>
<span
v-if="model.isBuiltin"
class="model-card__lock"
:title="$t('modelSettings.builtinTag')"
:aria-label="$t('modelSettings.builtinTag')"
>
<span v-if="model.isBuiltin" class="model-card__lock" :title="$t('modelSettings.builtinTag')"
:aria-label="$t('modelSettings.builtinTag')">
<t-icon name="lock-on" />
</span>
<div v-if="getModelOptions(model._modelType, model).length > 0" class="model-card__actions" @click.stop>
<t-dropdown
:options="getModelOptions(model._modelType, model)"
placement="bottom-right"
attach="body"
<t-dropdown :options="getModelOptions(model._modelType, model)" placement="bottom-right" attach="body"
trigger="click"
@click="(data: any) => handleMenuAction({ value: data.value }, model._modelType, model)"
>
@click="(data: any) => handleMenuAction({ value: data.value }, model._modelType, model)">
<t-button variant="text" shape="square" size="small" class="model-card__more">
<t-icon name="ellipsis" />
</t-button>
@@ -94,11 +76,8 @@
</template>
<template v-if="model._modelType === 'chat' && model.supportsVision">
<span class="model-card__sep">·</span>
<span
class="model-card__vision"
:title="$t('model.editor.supportsVisionLabel')"
:aria-label="$t('model.editor.supportsVisionLabel')"
>
<span class="model-card__vision" :title="$t('model.editor.supportsVisionLabel')"
:aria-label="$t('model.editor.supportsVisionLabel')">
<t-icon name="image" size="12px" />
</span>
</template>
@@ -108,12 +87,8 @@
</div>
<div v-else-if="!loading" class="empty-state">
<t-empty :description="emptyHint">
<t-dropdown
v-if="authStore.hasRole('admin')"
:options="addModelOptions"
placement="bottom"
@click="(data: any) => openAddDialog(data.value)"
>
<t-dropdown v-if="authStore.hasRole('admin')" :options="addModelOptions" placement="bottom"
@click="(data: any) => openAddDialog(data.value)">
<t-button theme="primary" variant="outline" size="small">
<template #icon><add-icon /></template>
{{ $t('modelSettings.actions.addModel') }}
@@ -870,5 +845,4 @@ onMounted(() => {
margin-bottom: 16px;
}
}
</style>