feat(avatar): improve multi-avatar management
This commit is contained in:
@@ -1,73 +1,10 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<router-view />
|
||||
<!-- 底部导航栏 -->
|
||||
<nav class="bottom-nav" v-if="showNav">
|
||||
<button
|
||||
class="nav-item"
|
||||
:class="{ active: currentRoute === '/' || currentRoute === '/avatar/manage' }"
|
||||
@click="navigateTo('/avatar/manage')"
|
||||
>
|
||||
<span class="nav-icon">🤖</span>
|
||||
<span class="nav-label">我的分身</span>
|
||||
</button>
|
||||
<button
|
||||
class="nav-item"
|
||||
:class="{ active: currentRoute === '/authorization' }"
|
||||
@click="navigateTo('/authorization')"
|
||||
>
|
||||
<span class="nav-icon">🔑</span>
|
||||
<span class="nav-label">授权管理</span>
|
||||
</button>
|
||||
<button
|
||||
class="nav-item"
|
||||
:class="{ active: currentRoute === '/token/charge' }"
|
||||
@click="navigateTo('/token/charge')"
|
||||
>
|
||||
<span class="nav-icon">💰</span>
|
||||
<span class="nav-label">Token</span>
|
||||
</button>
|
||||
</nav>
|
||||
<!-- 底部菜单暂不展示,多分身能力统一从分身卡片进入。 -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const currentRoute = ref<string>(route.path)
|
||||
const showNav = ref<boolean>(shouldShowNav(route.path))
|
||||
|
||||
function shouldShowNav(path: string) {
|
||||
return path !== '/'
|
||||
&& path !== '/authorization'
|
||||
&& path !== '/avatar/create'
|
||||
&& path !== '/login/sms'
|
||||
&& !path.startsWith('/avatar/edit')
|
||||
&& !path.startsWith('/avatar/chat')
|
||||
&& !path.startsWith('/share/')
|
||||
}
|
||||
|
||||
// 监听路由变化
|
||||
watch(() => route.path, (newPath) => {
|
||||
currentRoute.value = newPath
|
||||
showNav.value = shouldShowNav(newPath)
|
||||
})
|
||||
|
||||
// 导航
|
||||
const navigateTo = (path: string) => {
|
||||
router.push(path)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
currentRoute.value = route.path
|
||||
showNav.value = shouldShowNav(route.path)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
@@ -81,48 +18,4 @@ onMounted(() => {
|
||||
background: #F8F9FA;
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
|
||||
/* 底部导航栏 */
|
||||
.bottom-nav {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
display: flex;
|
||||
background: white;
|
||||
border-top: 1px solid #EDEEF1;
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 8px 0;
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
.nav-icon {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.nav-label {
|
||||
font-size: 11px;
|
||||
color: #9398AE;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.nav-item.active .nav-label {
|
||||
color: #F97316;
|
||||
}
|
||||
|
||||
.nav-item.active .nav-icon {
|
||||
filter: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -45,6 +45,12 @@ const routes: RouteRecordRaw[] = [
|
||||
component: () => import('@/views/AuthorizationManage.vue'),
|
||||
meta: { title: '授权管理', requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/avatar/:avatarId/authorization',
|
||||
name: 'AvatarAuthorizationManage',
|
||||
component: () => import('@/views/AuthorizationManage.vue'),
|
||||
meta: { title: '授权管理', requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/token/charge',
|
||||
name: 'TokenCharge',
|
||||
@@ -81,6 +87,12 @@ const routes: RouteRecordRaw[] = [
|
||||
component: () => import('@/views/KnowledgeManage.vue'),
|
||||
meta: { title: '知识库管理', requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/avatar/:avatarId/knowledge',
|
||||
name: 'AvatarKnowledgeManage',
|
||||
component: () => import('@/views/KnowledgeManage.vue'),
|
||||
meta: { title: '知识库管理', requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/knowledge/qa/create',
|
||||
name: 'QaPairCreate',
|
||||
@@ -93,6 +105,18 @@ const routes: RouteRecordRaw[] = [
|
||||
component: () => import('@/views/QaPairEdit.vue'),
|
||||
meta: { title: '编辑问答对', requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/avatar/:avatarId/knowledge/qa/create',
|
||||
name: 'AvatarQaPairCreate',
|
||||
component: () => import('@/views/QaPairEdit.vue'),
|
||||
meta: { title: '添加问答对', requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/avatar/:avatarId/knowledge/qa/:qaId/edit',
|
||||
name: 'AvatarQaPairEdit',
|
||||
component: () => import('@/views/QaPairEdit.vue'),
|
||||
meta: { title: '编辑问答对', requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/login/sms',
|
||||
name: 'SmsLogin',
|
||||
|
||||
@@ -41,5 +41,10 @@ export function pickAvatarId(
|
||||
currentAvatarId: string | null | undefined,
|
||||
avatars?: AvatarPageRecord[]
|
||||
): string | null
|
||||
export function pickScopedAvatarId(
|
||||
routeAvatarId: string | string[] | null | undefined,
|
||||
currentAvatarId: string | null | undefined,
|
||||
avatars?: AvatarPageRecord[]
|
||||
): string | null
|
||||
export function normalizeAvatarEditForm(avatar?: AvatarPageRecord): AvatarEditForm
|
||||
export function buildAvatarUpdatePayload(form: AvatarEditForm): AvatarUpdatePayload
|
||||
|
||||
@@ -8,6 +8,11 @@ export function pickAvatarId(currentAvatarId, avatars) {
|
||||
return currentAvatarId || avatars?.[0]?.id || null
|
||||
}
|
||||
|
||||
export function pickScopedAvatarId(routeAvatarId, currentAvatarId, avatars) {
|
||||
const requested = Array.isArray(routeAvatarId) ? routeAvatarId[0] : routeAvatarId
|
||||
return requested ? String(requested) : pickAvatarId(currentAvatarId, avatars)
|
||||
}
|
||||
|
||||
export function normalizeAvatarEditForm(avatar = {}) {
|
||||
const config = avatar.config || {}
|
||||
return {
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import {
|
||||
getAvatarPermissionSettings,
|
||||
getTakeoverStatus,
|
||||
@@ -118,12 +118,14 @@ import {
|
||||
type TakeoverStatus,
|
||||
} from '@/api'
|
||||
import { useAvatarStore } from '@/store/avatar'
|
||||
import { pickAvatarId } from '@/utils/avatar-page-data.js'
|
||||
import { pickScopedAvatarId } from '@/utils/avatar-page-data.js'
|
||||
|
||||
type PermissionState = Record<AvatarPermission, boolean>
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const avatarStore = useAvatarStore()
|
||||
const avatarId = computed(() => pickScopedAvatarId(route.params.avatarId, avatarStore.currentAvatarId, avatarStore.avatars))
|
||||
|
||||
const permissionItems: Array<{
|
||||
key: AvatarPermission
|
||||
@@ -307,7 +309,8 @@ const goCreate = () => router.push('/avatar/create')
|
||||
|
||||
onMounted(async () => {
|
||||
if (!avatarStore.avatars.length) await avatarStore.loadAvatars()
|
||||
activeAvatarId.value = pickAvatarId(avatarStore.currentAvatarId, avatarStore.avatars) || ''
|
||||
activeAvatarId.value = avatarId.value || ''
|
||||
if (activeAvatarId.value) avatarStore.currentAvatarId = activeAvatarId.value
|
||||
await loadSettings()
|
||||
})
|
||||
|
||||
|
||||
@@ -44,6 +44,9 @@
|
||||
|
||||
<div v-if="avatars.length" class="avatar-list">
|
||||
<div class="avatar-card" v-for="a in avatars" :key="a.id">
|
||||
<button class="card-edit" @click="goToEdit(a.id)" :aria-label="`编辑${a.displayName || a.name}`">
|
||||
<span aria-hidden="true">✎</span> 编辑
|
||||
</button>
|
||||
<div class="avatar-card-main">
|
||||
<div class="avatar-photo">
|
||||
<img v-if="a.photoUrl" :src="a.photoUrl" alt="" referrerpolicy="no-referrer" class="avatar-img" />
|
||||
@@ -56,9 +59,9 @@
|
||||
</div>
|
||||
<div class="avatar-actions">
|
||||
<button class="chat-link" @click="goToChat(a.id)"><span>💬</span> 对话</button>
|
||||
<button class="knowledge-link" @click="goToKnowledge(a.id)"><span>📚</span> 知识库</button>
|
||||
<button class="authorization-link" @click="goToAuthorization(a.id)"><span>🔑</span> 授权</button>
|
||||
<button class="share-link" @click="shareAvatar(a)"><span>↗</span> 分享</button>
|
||||
<button class="edit-link" @click="goToEdit(a.id)">编辑</button>
|
||||
<button class="del-link" @click="askDelete(a)" aria-label="删除分身">删除</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -72,88 +75,7 @@
|
||||
|
||||
<p v-if="shareToast" class="share-toast">{{ shareToast }}</p>
|
||||
|
||||
<!-- 分身工具入口 -->
|
||||
<section class="tools-section">
|
||||
<h3 class="section-title">分身工具</h3>
|
||||
<div class="tools-grid">
|
||||
<div class="tool-card" @click="goToKnowledge">
|
||||
<div class="tool-icon">📚</div>
|
||||
<div class="tool-info">
|
||||
<span class="tool-name">知识库管理</span>
|
||||
<span class="tool-desc">上传文档与标准问答</span>
|
||||
</div>
|
||||
<span class="tool-arrow">›</span>
|
||||
</div>
|
||||
<div class="tool-card" @click="goToAvatarCard">
|
||||
<div class="tool-icon">🪪</div>
|
||||
<div class="tool-info">
|
||||
<span class="tool-name">分身名片</span>
|
||||
<span class="tool-desc">生成并分享名片</span>
|
||||
</div>
|
||||
<span class="tool-arrow">›</span>
|
||||
</div>
|
||||
<div class="tool-card" @click="goToAvatarContacts">
|
||||
<div class="tool-icon">🤝</div>
|
||||
<div class="tool-info">
|
||||
<span class="tool-name">分身人脉</span>
|
||||
<span class="tool-desc">管理社交关系</span>
|
||||
</div>
|
||||
<span class="tool-arrow">›</span>
|
||||
</div>
|
||||
<div class="tool-card" @click="goToMyProjects">
|
||||
<div class="tool-icon">📁</div>
|
||||
<div class="tool-info">
|
||||
<span class="tool-name">我的项目</span>
|
||||
<span class="tool-desc">查看参与项目</span>
|
||||
</div>
|
||||
<span class="tool-arrow">›</span>
|
||||
</div>
|
||||
<div class="tool-card" @click="goToCreateOrg">
|
||||
<div class="tool-icon">🏢</div>
|
||||
<div class="tool-info">
|
||||
<span class="tool-name">创建组织</span>
|
||||
<span class="tool-desc">新建组织团队</span>
|
||||
</div>
|
||||
<span class="tool-arrow">›</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 分身动态列表 -->
|
||||
<section class="activities-section">
|
||||
<h3 class="section-title">分身动态</h3>
|
||||
<div class="activity-list" v-if="activities.length > 0">
|
||||
<div class="activity-item" v-for="activity in activities" :key="activity.id">
|
||||
<div class="activity-icon" :class="activity.type">{{ activityIcon(activity.type) }}</div>
|
||||
<div class="activity-content">
|
||||
<p class="activity-text">{{ activity.text }}</p>
|
||||
<span class="activity-time">{{ formatTime(activity.createdAt) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="empty-state" v-else>
|
||||
<span class="empty-icon">📭</span>
|
||||
<p class="empty-text">暂无动态</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 删除确认弹窗 -->
|
||||
<div v-if="showDelete" class="modal-mask" @click.self="cancelDelete">
|
||||
<div class="modal">
|
||||
<div class="modal-icon">⚠️</div>
|
||||
<h3 class="modal-title">删除数字分身</h3>
|
||||
<p class="modal-text">
|
||||
确认删除「{{ pendingDelete?.displayName || pendingDelete?.name }}」?<br />
|
||||
其知识库、问答对、授权等关联数据将一并清除,且<b>不可恢复</b>。
|
||||
</p>
|
||||
<div class="modal-actions">
|
||||
<button class="modal-cancel" @click="cancelDelete">取消</button>
|
||||
<button class="modal-confirm" :disabled="deleting" @click="confirmDelete">
|
||||
{{ deleting ? '删除中...' : '确认删除' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 分身工具和分身动态暂不展示,入口统一收拢到每张分身卡片。 -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -175,18 +97,8 @@ const me = computed(() => userStore.user)
|
||||
const tokenBalance = computed(() => avatarStore.tokenBalance)
|
||||
const avatars = computed(() => avatarStore.avatars)
|
||||
|
||||
// 删除确认弹窗状态
|
||||
const showDelete = ref(false)
|
||||
const pendingDelete = ref<any>(null)
|
||||
const deleting = ref(false)
|
||||
const shareToast = ref('')
|
||||
|
||||
const activities = ref<Array<{ id: string; type: string; text: string; createdAt: string }>>([
|
||||
{ id: '1', type: 'create', text: '数字分身创建成功', createdAt: new Date(Date.now() - 86400000).toISOString() },
|
||||
{ id: '2', type: 'edit', text: '更新了分身描述', createdAt: new Date(Date.now() - 43200000).toISOString() },
|
||||
{ id: '3', type: 'authorize', text: '授权微信小程序访问', createdAt: new Date(Date.now() - 3600000).toISOString() }
|
||||
])
|
||||
|
||||
// 状态文本
|
||||
const statusText = (status: string) => {
|
||||
const map: Record<string, string> = {
|
||||
@@ -197,55 +109,6 @@ const statusText = (status: string) => {
|
||||
return map[status] || status
|
||||
}
|
||||
|
||||
// 活动图标
|
||||
const activityIcon = (type: string) => {
|
||||
const map: Record<string, string> = {
|
||||
'create': '✨',
|
||||
'edit': '✏️',
|
||||
'authorize': '🔑',
|
||||
'interact': '💬'
|
||||
}
|
||||
return map[type] || '📌'
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
const formatTime = (time: string) => {
|
||||
const date = new Date(time)
|
||||
const now = new Date()
|
||||
const diff = now.getTime() - date.getTime()
|
||||
const minutes = Math.floor(diff / 60000)
|
||||
const hours = Math.floor(diff / 3600000)
|
||||
const days = Math.floor(diff / 86400000)
|
||||
|
||||
if (minutes < 60) return `${minutes}分钟前`
|
||||
if (hours < 24) return `${hours}小时前`
|
||||
return `${days}天前`
|
||||
}
|
||||
|
||||
// 删除流程
|
||||
const askDelete = (a: any) => {
|
||||
pendingDelete.value = a
|
||||
showDelete.value = true
|
||||
}
|
||||
const cancelDelete = () => {
|
||||
if (deleting.value) return
|
||||
showDelete.value = false
|
||||
pendingDelete.value = null
|
||||
}
|
||||
const confirmDelete = async () => {
|
||||
if (!pendingDelete.value || deleting.value) return
|
||||
deleting.value = true
|
||||
try {
|
||||
await avatarStore.removeAvatar(pendingDelete.value.id)
|
||||
showDelete.value = false
|
||||
pendingDelete.value = null
|
||||
} catch (e: any) {
|
||||
alert(e?.message || '删除失败,请稍后重试')
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 导航
|
||||
const goBack = () => {
|
||||
router.back()
|
||||
@@ -259,8 +122,12 @@ const goCreate = () => {
|
||||
router.push('/avatar/create')
|
||||
}
|
||||
|
||||
const goToKnowledge = () => {
|
||||
router.push('/knowledge')
|
||||
const goToKnowledge = (id: string) => {
|
||||
router.push({ name: 'AvatarKnowledgeManage', params: { avatarId: id } })
|
||||
}
|
||||
|
||||
const goToAuthorization = (id: string) => {
|
||||
router.push({ name: 'AvatarAuthorizationManage', params: { avatarId: id } })
|
||||
}
|
||||
|
||||
const goToEdit = (id: string) => {
|
||||
@@ -303,22 +170,6 @@ const shareAvatar = async (avatar: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
const goToAvatarCard = () => {
|
||||
router.push('/avatar/card')
|
||||
}
|
||||
|
||||
const goToAvatarContacts = () => {
|
||||
router.push('/avatar/contacts')
|
||||
}
|
||||
|
||||
const goToMyProjects = () => {
|
||||
router.push('/avatar/projects')
|
||||
}
|
||||
|
||||
const goToCreateOrg = () => {
|
||||
router.push('/avatar/org/create')
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
userStore.loadFromStorage()
|
||||
avatarStore.loadAvatars()
|
||||
@@ -330,7 +181,7 @@ onMounted(() => {
|
||||
.avatar-manage-page {
|
||||
min-height: 100vh;
|
||||
background: #F8F9FA;
|
||||
padding-bottom: 80px;
|
||||
padding-bottom: calc(28px + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
/* 顶部导航 */
|
||||
@@ -516,13 +367,32 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.avatar-card {
|
||||
position: relative;
|
||||
padding: 16px;
|
||||
background: white;
|
||||
border: 1px solid #F4E5D9;
|
||||
border-radius: 18px;
|
||||
box-shadow: 0 8px 22px rgba(112, 62, 22, .07);
|
||||
}
|
||||
.avatar-card-main { display: flex; align-items: center; gap: 14px; }
|
||||
.avatar-card-main { display: flex; align-items: center; gap: 14px; padding: 4px 68px 2px 0; }
|
||||
|
||||
.card-edit {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 12px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 7px 10px;
|
||||
border: 1px solid #E9E2DC;
|
||||
border-radius: 999px;
|
||||
color: #6B625C;
|
||||
background: #FAF8F6;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.card-edit:active { background: #F2EDE8; }
|
||||
|
||||
.avatar-photo {
|
||||
width: 66px;
|
||||
@@ -598,56 +468,39 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.avatar-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.avatar-actions button {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
min-height: 58px;
|
||||
padding: 8px 3px;
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.avatar-actions button span { font-size: 17px; line-height: 1; }
|
||||
|
||||
.chat-link {
|
||||
flex: 1;
|
||||
padding: 10px 8px;
|
||||
background: linear-gradient(135deg, #F97316, #FB923C);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.chat-link span, .share-link span { margin-right: 3px; }
|
||||
.share-link { flex: 1; padding: 10px 8px; border: 1px solid #FFD5AF; border-radius: 10px; color: #C15F18; background: #FFF8F1; font-size: 13px; cursor: pointer; }
|
||||
.knowledge-link { border: 1px solid #F5D7B8; color: #A85418; background: #FFF8F1; }
|
||||
.authorization-link { border: 1px solid #DCE5F2; color: #47627D; background: #F6F9FC; }
|
||||
.share-link { border: 1px solid #E5E1DD; color: #675E58; background: #FAF8F6; }
|
||||
|
||||
.edit-link {
|
||||
padding: 10px 10px;
|
||||
background: #F3F4F6;
|
||||
color: #6B7280;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.edit-link:hover {
|
||||
background: #E5E7EB;
|
||||
}
|
||||
|
||||
.del-link {
|
||||
padding: 10px 2px;
|
||||
background: transparent;
|
||||
color: #B6BCC8;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.share-toast { position: fixed; left: 50%; bottom: 92px; z-index: 300; max-width: calc(100vw - 48px); transform: translateX(-50%); padding: 10px 14px; border-radius: 10px; color: white; background: rgba(39, 32, 28, .88); font-size: 13px; text-align: center; }
|
||||
|
||||
.del-link:hover {
|
||||
background: #FEE2E2;
|
||||
}
|
||||
.share-toast { position: fixed; left: 50%; bottom: 24px; z-index: 300; max-width: calc(100vw - 48px); transform: translateX(-50%); padding: 10px 14px; border-radius: 10px; color: white; background: rgba(39, 32, 28, .88); font-size: 13px; text-align: center; }
|
||||
|
||||
/* 空状态 */
|
||||
.empty-state {
|
||||
@@ -684,197 +537,4 @@ onMounted(() => {
|
||||
box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
|
||||
}
|
||||
|
||||
/* 分身工具入口 */
|
||||
.tools-section {
|
||||
padding: 8px 20px 16px;
|
||||
}
|
||||
|
||||
.tools-grid {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.tool-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 14px 16px;
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.tool-card:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.tool-icon {
|
||||
font-size: 24px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.tool-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.tool-name {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #18191C;
|
||||
}
|
||||
|
||||
.tool-desc {
|
||||
font-size: 12px;
|
||||
color: #9398AE;
|
||||
}
|
||||
|
||||
.tool-arrow {
|
||||
font-size: 18px;
|
||||
color: #C9CDD2;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* 分身动态列表 */
|
||||
.activities-section {
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.activity-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.activity-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
padding: 14px 16px;
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.activity-icon {
|
||||
font-size: 20px;
|
||||
flex-shrink: 0;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 10px;
|
||||
background: #FFF0E6;
|
||||
}
|
||||
|
||||
.activity-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.activity-text {
|
||||
font-size: 14px;
|
||||
color: #18191C;
|
||||
margin: 0 0 4px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.activity-time {
|
||||
font-size: 12px;
|
||||
color: #9398AE;
|
||||
}
|
||||
|
||||
/* 删除确认弹窗 */
|
||||
.modal-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 24px;
|
||||
z-index: 50;
|
||||
animation: fade 0.2s ease;
|
||||
}
|
||||
|
||||
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
|
||||
|
||||
.modal {
|
||||
width: 100%;
|
||||
max-width: 320px;
|
||||
background: white;
|
||||
border-radius: 18px;
|
||||
padding: 24px 22px 18px;
|
||||
text-align: center;
|
||||
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
|
||||
animation: pop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
@keyframes pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
|
||||
|
||||
.modal-icon {
|
||||
font-size: 36px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
color: #18191C;
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
.modal-text {
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
color: #6B7280;
|
||||
margin: 0 0 20px;
|
||||
}
|
||||
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.modal-cancel {
|
||||
flex: 1;
|
||||
padding: 12px;
|
||||
background: #F3F4F6;
|
||||
color: #6B7280;
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-confirm {
|
||||
flex: 1;
|
||||
padding: 12px;
|
||||
background: #EF4444;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
|
||||
.modal-confirm:hover {
|
||||
opacity: 0.92;
|
||||
}
|
||||
|
||||
.modal-confirm:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -79,9 +79,9 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useAvatarStore } from '@/store/avatar'
|
||||
import { pickAvatarId, unwrapListData } from '@/utils/avatar-page-data.js'
|
||||
import { pickScopedAvatarId, unwrapListData } from '@/utils/avatar-page-data.js'
|
||||
import {
|
||||
getKnowledgeDocs,
|
||||
uploadKnowledgeDoc,
|
||||
@@ -93,9 +93,10 @@ import {
|
||||
} from '@/api'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const store = useAvatarStore()
|
||||
|
||||
const avatarId = computed(() => pickAvatarId(store.currentAvatarId, store.avatars))
|
||||
const avatarId = computed(() => pickScopedAvatarId(route.params.avatarId, store.currentAvatarId, store.avatars))
|
||||
const activeTab = ref<'docs' | 'qa'>('docs')
|
||||
|
||||
const docs = ref<any[]>([])
|
||||
@@ -200,9 +201,21 @@ const toggleQa = async (qa: any, e: Event) => {
|
||||
}
|
||||
}
|
||||
|
||||
const goAddQa = () => router.push('/knowledge/qa/create')
|
||||
const goAddQa = () => {
|
||||
if (route.params.avatarId && avatarId.value) {
|
||||
router.push({ name: 'AvatarQaPairCreate', params: { avatarId: avatarId.value } })
|
||||
return
|
||||
}
|
||||
router.push('/knowledge/qa/create')
|
||||
}
|
||||
|
||||
const goEditQa = (qa: any) => router.push(`/knowledge/qa/${qa.id}/edit`)
|
||||
const goEditQa = (qa: any) => {
|
||||
if (route.params.avatarId && avatarId.value) {
|
||||
router.push({ name: 'AvatarQaPairEdit', params: { avatarId: avatarId.value, qaId: qa.id } })
|
||||
return
|
||||
}
|
||||
router.push(`/knowledge/qa/${qa.id}/edit`)
|
||||
}
|
||||
|
||||
const removeQa = async (id: string) => {
|
||||
if (!avatarId.value) return
|
||||
@@ -226,6 +239,7 @@ onMounted(async () => {
|
||||
if (!store.avatars.length) {
|
||||
await store.loadAvatars()
|
||||
}
|
||||
if (avatarId.value) store.currentAvatarId = avatarId.value
|
||||
await Promise.all([loadDocs(), loadQA()])
|
||||
})
|
||||
</script>
|
||||
@@ -234,7 +248,7 @@ onMounted(async () => {
|
||||
.knowledge-page {
|
||||
min-height: 100vh;
|
||||
background: #F8F9FA;
|
||||
padding-bottom: 80px;
|
||||
padding-bottom: calc(28px + env(safe-area-inset-bottom));
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,14 +49,14 @@
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { useAvatarStore } from '@/store/avatar'
|
||||
import { pickAvatarId, unwrapListData } from '@/utils/avatar-page-data.js'
|
||||
import { pickScopedAvatarId, unwrapListData } from '@/utils/avatar-page-data.js'
|
||||
import { getQAPairs, createQAPair, updateQAPair } from '@/api'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const store = useAvatarStore()
|
||||
|
||||
const avatarId = computed(() => pickAvatarId(store.currentAvatarId, store.avatars))
|
||||
const avatarId = computed(() => pickScopedAvatarId(route.params.avatarId, store.currentAvatarId, store.avatars))
|
||||
const qaId = computed(() => (route.params.qaId as string) || null)
|
||||
const isEdit = computed(() => !!qaId.value)
|
||||
|
||||
@@ -104,8 +104,11 @@ const save = async () => {
|
||||
} else {
|
||||
await createQAPair(avatarId.value, payload)
|
||||
}
|
||||
// 保存成功返回知识库管理页
|
||||
router.replace('/knowledge')
|
||||
if (route.params.avatarId) {
|
||||
router.replace({ name: 'AvatarKnowledgeManage', params: { avatarId: avatarId.value } })
|
||||
} else {
|
||||
router.replace('/knowledge')
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e?.message || '保存失败'
|
||||
} finally {
|
||||
@@ -117,6 +120,7 @@ onMounted(async () => {
|
||||
if (!store.avatars.length) {
|
||||
await store.loadAvatars()
|
||||
}
|
||||
if (avatarId.value) store.currentAvatarId = avatarId.value
|
||||
if (isEdit.value) {
|
||||
await loadForEdit()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user