feat(ui): 工作台界面全部替换为element plus
This commit is contained in:
1 parent
26d213c05b
commit
d5f988a16c
38 files changed
+4501
-3087
No files matched your search
@@ -1,208 +1,546 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/workspace/pages/HomePage.vue
|
||||
* 应用管理 / 最近更新:收藏应用、快捷问题、嵌入 Agent、公告与应用列表。
|
||||
* 用途:AI 工作台的应用管理和最近更新。收藏应用、快捷问题、嵌入 Agent、公告和应用列表。
|
||||
* 依赖:workspace.context、AnnouncementCardCarousel、element-plus、element-theme.css。
|
||||
* 逻辑:路由按 workspaceFocus 决定展示哪些分区。分区顺序和折叠仍由工作台状态管理。
|
||||
* 应用卡片保持原有点击进入对话。快捷问题的新增和编辑用 Element 表单。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { inject } from 'vue';
|
||||
import {
|
||||
LayoutGrid, Star, GripVertical, Plus, Trash2, Edit, ExternalLink,
|
||||
Bot, Megaphone, ChevronDown, ChevronUp,
|
||||
} from 'lucide-vue-next';
|
||||
ArrowDown,
|
||||
ArrowUp,
|
||||
Bell,
|
||||
Delete,
|
||||
Edit,
|
||||
Grid,
|
||||
Monitor,
|
||||
Plus,
|
||||
Rank,
|
||||
Star,
|
||||
StarFilled,
|
||||
TopRight,
|
||||
} from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElCard,
|
||||
ElEmpty,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElIcon,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElRadioButton,
|
||||
ElRadioGroup,
|
||||
ElSelect,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/shared/styles/element-theme.css';
|
||||
import AnnouncementCardCarousel from '@/shared/components/AnnouncementCardCarousel.vue';
|
||||
import { WORKSPACE_KEY } from '../composables/workspace.context';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
const { t } = useI18n();
|
||||
const ws = inject(WORKSPACE_KEY)! as any;
|
||||
|
||||
/**
|
||||
* 应用分类单选。「全部」在 Element 里用空字符串,写回状态时仍是 null。
|
||||
* @param value - 被选中的分类
|
||||
*/
|
||||
function onCategoryChange(value: string | number | boolean | undefined): void {
|
||||
ws.selectedCategory = value ? String(value) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 快捷问题的目标应用。未选择时下拉值为 undefined,保存仍写 null。
|
||||
* @param value - 应用主键
|
||||
*/
|
||||
function onQuestionAgentChange(value: string | number | boolean | undefined): void {
|
||||
ws.newQuestion.agent_id = value == null || value === '' ? null : Number(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分区标题图标。公告、收藏、嵌入和其余列表各用一个 Element 图标。
|
||||
* @param sectionId - 分区 id
|
||||
* @returns 图标组件
|
||||
*/
|
||||
function sectionIcon(sectionId: string) {
|
||||
if (sectionId === 'announcements') return Bell;
|
||||
if (sectionId === 'favorites') return StarFilled;
|
||||
if (sectionId === 'embedded') return Monitor;
|
||||
return Grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 公告和收藏没有内容时,把提示放在标题旁边,避免空状态插图把分区撑高。
|
||||
* @param section - 当前分区
|
||||
* @returns 提示文案;有内容或已折叠时为空
|
||||
*/
|
||||
function sectionEmptyHint(section: { id: string; collapsed?: boolean }): string {
|
||||
if (section.collapsed) return '';
|
||||
if (section.id === 'announcements' && ws.announcements.length === 0) return t('workspace.announcements.noData');
|
||||
if (section.id === 'favorites' && ws.favoriteAgents.length === 0) return t('workspace.noFavorites');
|
||||
return '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="ws.wecomEntryHint" class="rounded-2xl border border-blue-200 bg-blue-50 px-4 py-3 text-sm text-blue-700">
|
||||
<div v-if="ws.wecomEntryHint" class="workspace-hint">
|
||||
{{ ws.wecomEntryHint }}
|
||||
</div>
|
||||
|
||||
<div
|
||||
<ElCard
|
||||
v-for="(section, index) in ws.layoutSections"
|
||||
:id="`workspace-section-${section.id}`"
|
||||
:key="section.id"
|
||||
class="bg-transparent md:bg-surface md:rounded-3xl md:border md:border-subtle md:p-8 md:shadow-soft relative group transition-all scroll-mt-6"
|
||||
:class="{ 'opacity-50 border-brand-300 border-dashed': ws.draggedSectionIndex === index }"
|
||||
shadow="never"
|
||||
class="workspace-section"
|
||||
:class="{
|
||||
'workspace-section--dragging': ws.draggedSectionIndex === index,
|
||||
'workspace-section--compact': sectionEmptyHint(section),
|
||||
}"
|
||||
draggable="true"
|
||||
@dragstart="ws.onDragStart(index)"
|
||||
@dragover="ws.onDragOver"
|
||||
@drop="ws.onDrop(index)"
|
||||
>
|
||||
<div class="absolute left-2 top-8 cursor-move opacity-0 group-hover:opacity-100 p-2 text-slate-300 hover:text-muted transition-opacity hidden md:block">
|
||||
<GripVertical class="w-5 h-5" />
|
||||
<div
|
||||
class="workspace-section__head"
|
||||
:class="{ 'workspace-section__head--compact': sectionEmptyHint(section) }"
|
||||
>
|
||||
<div class="workspace-section__lead">
|
||||
<ElButton text class="workspace-section__title" @click="ws.toggleSectionCollapse(section)">
|
||||
<ElIcon class="workspace-section__icon"><component :is="sectionIcon(section.id)" /></ElIcon>
|
||||
<span class="section-title">{{ t(ws.getSectionTitleKey(section.id)) }}</span>
|
||||
<ElIcon><component :is="section.collapsed ? ArrowDown : ArrowUp" /></ElIcon>
|
||||
</ElButton>
|
||||
<span v-if="sectionEmptyHint(section)" class="workspace-empty">{{ sectionEmptyHint(section) }}</span>
|
||||
</div>
|
||||
<ElButton
|
||||
v-if="section.id === 'quick_questions' && !ws.isAddingQuestion && !section.collapsed"
|
||||
link
|
||||
type="primary"
|
||||
:icon="Plus"
|
||||
@click="ws.openAddQuestionForm"
|
||||
>
|
||||
{{ t('workspace.quickQuestions.add') }}
|
||||
</ElButton>
|
||||
<ElIcon class="workspace-section__grip">
|
||||
<Rank />
|
||||
</ElIcon>
|
||||
</div>
|
||||
|
||||
<div class="md:pl-6">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h2 class="text-lg md:text-xl font-semibold text-primary flex items-center gap-2.5 cursor-pointer select-none" @click="ws.toggleSectionCollapse(section)">
|
||||
<div class="p-2 rounded-lg" :class="{
|
||||
'bg-emerald-50 text-emerald-600': section.id === 'announcements',
|
||||
'bg-yellow-50 text-yellow-600': section.id === 'favorites',
|
||||
'bg-brand-50 text-brand-600': section.id === 'quick_questions',
|
||||
'bg-purple-50 text-purple-600': section.id === 'embedded',
|
||||
'bg-slate-100 text-secondary': section.id === 'all_agents'
|
||||
}">
|
||||
<component :is="section.id === 'announcements' ? Megaphone : (section.id === 'favorites' ? Star : (section.id === 'embedded' ? Bot : LayoutGrid))" class="w-5 h-5" />
|
||||
</div>
|
||||
{{ $t(ws.getSectionTitleKey(section.id)) }}
|
||||
<component :is="section.collapsed ? ChevronDown : ChevronUp" class="w-4 h-4 text-muted" />
|
||||
</h2>
|
||||
<button v-if="section.id === 'quick_questions' && !ws.isAddingQuestion && !section.collapsed" @click="ws.openAddQuestionForm" class="btn-ghost text-sm text-brand-600 hover:text-brand-700 hover:bg-brand-50">
|
||||
<Plus class="w-4 h-4" /> {{ $t('workspace.quickQuestions.add') }}
|
||||
</button>
|
||||
<div v-show="!section.collapsed">
|
||||
<div v-if="section.id === 'announcements' && ws.announcements.length > 0" class="workspace-announcements">
|
||||
<AnnouncementCardCarousel
|
||||
:announcements="ws.announcements"
|
||||
variant="workspace"
|
||||
:auto-play="ws.announcements.length > 1"
|
||||
:auto-play-interval="8000"
|
||||
@select="ws.openAnnouncement"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-show="!section.collapsed" class="animate-fade-in">
|
||||
<!-- Content: Announcements -->
|
||||
<div v-if="section.id === 'announcements'">
|
||||
<div v-if="ws.announcements.length === 0" class="text-muted text-sm italic py-8 text-center bg-surface-soft rounded-xl border border-dashed border-default">{{ $t('workspace.announcements.noData') }}</div>
|
||||
<div v-else class="max-w-2xl">
|
||||
<AnnouncementCardCarousel
|
||||
:announcements="ws.announcements"
|
||||
variant="workspace"
|
||||
:auto-play="ws.announcements.length > 1"
|
||||
:auto-play-interval="8000"
|
||||
@select="ws.openAnnouncement"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Content: Favorites -->
|
||||
<div v-if="section.id === 'favorites'">
|
||||
<div v-if="ws.favoriteAgents.length === 0" class="text-muted text-sm italic py-4 bg-surface-soft rounded-xl text-center border border-dashed border-default">{{ $t('workspace.noFavorites') }}</div>
|
||||
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3 sm:gap-6">
|
||||
<div v-for="agent in ws.favoriteAgents" :key="agent.id" @click="ws.navigateToChat(agent.id)"
|
||||
class="card p-4 sm:p-5 cursor-pointer relative group/card hover:-translate-y-1 hover:shadow-lg hover:border-brand-200 bg-gradient-to-br from-white to-slate-50/50">
|
||||
<div class="w-8 h-8 sm:w-12 sm:h-12 bg-brand-100 rounded-xl flex items-center justify-center text-brand-600 mb-3 sm:mb-4 shadow-sm group-hover/card:scale-110 transition-transform duration-300">
|
||||
<img v-if="agent.icon_url" :src="agent.icon_url" class="w-5 h-5 sm:w-7 sm:h-7" />
|
||||
<Bot v-else class="w-5 h-5 sm:w-7 sm:h-7" />
|
||||
</div>
|
||||
<div class="text-[15px] sm:text-base font-semibold text-primary mb-1 group-hover/card:text-brand-700 transition-colors truncate">{{ agent.name }}</div>
|
||||
<div class="text-[13px] sm:text-xs text-muted truncate">{{ agent.description }}</div>
|
||||
<button @click.stop="ws.toggleFavorite(agent.id)" class="absolute top-3 right-3 text-yellow-400 hover:text-yellow-500 hover:scale-110 transition-all opacity-0 group-hover/card:opacity-100">
|
||||
<Star class="w-5 h-5 fill-current" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Content: Quick Questions -->
|
||||
<div v-if="section.id === 'quick_questions'">
|
||||
<!-- Add Question Form -->
|
||||
<div v-if="ws.isAddingQuestion" class="mb-6 p-6 bg-surface-soft border border-default rounded-2xl space-y-4 animate-fade-in">
|
||||
<h3 class="font-bold text-primary">{{ ws.editingQuestionId ? $t('workspace.quickQuestions.edit') : $t('workspace.quickQuestions.addNew') }}</h3>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
||||
<div class="space-y-1.5">
|
||||
<label class="text-xs font-semibold text-muted uppercase">{{ $t('workspace.quickQuestions.fields.title') }}</label>
|
||||
<input v-model="ws.newQuestion.title" class="input-field" :placeholder="$t('workspace.quickQuestions.fields.titlePlaceholder')" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="text-xs font-semibold text-muted uppercase">{{ $t('workspace.quickQuestions.fields.targetAgent') }}</label>
|
||||
<select v-model="ws.newQuestion.agent_id" class="input-field" :disabled="ws.agents.length === 0">
|
||||
<option :value="null" disabled>{{ ws.agents.length === 0 ? $t('workspace.noAgents') : $t('workspace.quickQuestions.fields.selectAgent') }}</option>
|
||||
<option v-for="agent in ws.agents" :key="agent.id" :value="agent.id">{{ agent.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-span-1 md:col-span-2 space-y-1.5">
|
||||
<label class="text-xs font-semibold text-muted uppercase">{{ $t('workspace.quickQuestions.fields.content') }}</label>
|
||||
<textarea v-model="ws.newQuestion.question" rows="3" class="input-field" :placeholder="$t('workspace.quickQuestions.fields.contentPlaceholder')"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end gap-3 pt-2">
|
||||
<button @click="ws.cancelAddQuestion" class="btn-secondary">{{ $t('workspace.cancel') }}</button>
|
||||
<button @click="ws.saveQuickQuestion" class="btn-primary">{{ $t('workspace.save') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="ws.filteredQuickQuestions.length === 0 && !ws.isAddingQuestion" class="text-muted text-sm italic py-8 text-center bg-surface-soft rounded-xl border border-dashed border-default">{{ $t('workspace.quickQuestions.noDefined') }}</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
<div v-for="qq in ws.filteredQuickQuestions" :key="qq.id"
|
||||
@click="ws.navigateWithQuickQuestion(qq.agent_id, qq.question)"
|
||||
class="group/item p-4 bg-surface border border-default rounded-xl hover:border-brand-500 hover:shadow-md transition-all cursor-pointer flex flex-col gap-3 relative h-full">
|
||||
|
||||
<div class="flex justify-between items-start">
|
||||
<h4 class="font-bold text-primary group-hover/item:text-brand-600 transition-colors">{{ qq.title }}</h4>
|
||||
<span class="text-[10px] font-bold px-2 py-0.5 bg-slate-100 text-secondary rounded-full uppercase tracking-wide">
|
||||
{{ ws.getAgentName(qq.agent_id) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<p class="text-sm text-secondary line-clamp-2 leading-relaxed">{{ qq.question }}</p>
|
||||
|
||||
<div class="absolute top-2 right-2 flex gap-1 opacity-0 group-hover/item:opacity-100 transition-opacity bg-surface/90 backdrop-blur-sm p-1 rounded-lg">
|
||||
<button @click.stop="ws.editQuickQuestion(qq)" class="p-1.5 rounded-lg text-muted hover:text-brand-600 hover:bg-brand-50 transition-colors">
|
||||
<Edit class="w-4 h-4" />
|
||||
</button>
|
||||
<button @click.stop="ws.removeQuickQuestion(qq.id)" class="p-1.5 rounded-lg text-muted hover:text-red-600 hover:bg-red-50 transition-colors">
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
<div v-if="section.id === 'favorites' && ws.favoriteAgents.length > 0" class="workspace-card-grid">
|
||||
<article
|
||||
v-for="agent in ws.favoriteAgents"
|
||||
:key="agent.id"
|
||||
class="workspace-app-card"
|
||||
@click="ws.navigateToChat(agent.id)"
|
||||
>
|
||||
<div class="workspace-app-card__icon">
|
||||
<img v-if="agent.icon_url" :src="agent.icon_url" alt="" />
|
||||
<ElIcon v-else><Monitor /></ElIcon>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h3 class="workspace-app-card__name">{{ agent.name }}</h3>
|
||||
<p class="workspace-app-card__desc">{{ agent.description }}</p>
|
||||
<ElButton
|
||||
class="workspace-app-card__star"
|
||||
link
|
||||
:icon="StarFilled"
|
||||
:title="t('workspace.favorites')"
|
||||
@click.stop="ws.toggleFavorite(agent.id)"
|
||||
/>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<!-- Content: Embedded Agents -->
|
||||
<div v-if="section.id === 'embedded'">
|
||||
<div v-if="ws.embeddedAgents.length === 0" class="text-muted text-sm italic py-4 bg-surface-soft rounded-xl text-center border border-dashed border-default">{{ $t('workspace.embedded.noData') }}</div>
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<div v-for="agent in ws.embeddedAgents" :key="agent.id" class="border border-default rounded-2xl overflow-hidden bg-surface shadow-sm hover:shadow-md transition-shadow h-[500px] flex flex-col">
|
||||
<div class="bg-surface-soft px-4 py-3 text-sm font-bold text-secondary flex justify-between items-center border-b border-subtle">
|
||||
<span>{{ agent.name }}</span>
|
||||
<a :href="`/chat/${agent.id}`" target="_blank" class="text-brand-600 hover:text-brand-700 hover:bg-brand-50 p-1.5 rounded-lg transition-colors"><ExternalLink class="w-4 h-4"/></a>
|
||||
</div>
|
||||
<iframe v-if="agent.iframe_url" :src="agent.iframe_url" class="w-full flex-1 border-none bg-surface"></iframe>
|
||||
<div v-else class="flex items-center justify-center flex-1 text-muted bg-surface-soft/50">{{ $t('workspace.embedded.noUrl') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Content: All Agents -->
|
||||
<div v-if="section.id === 'all_agents'">
|
||||
<div class="mb-4 flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1.5 text-xs font-medium transition-colors"
|
||||
:class="!ws.selectedCategory ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
|
||||
@click="ws.selectedCategory = null"
|
||||
>
|
||||
{{ $t('workspace.agentCategory.all') }}
|
||||
</button>
|
||||
<button
|
||||
v-for="category in ws.agentCategories"
|
||||
:key="category"
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1.5 text-xs font-medium transition-colors"
|
||||
:class="ws.selectedCategory === category ? 'bg-brand-600 text-white' : 'bg-surface-soft text-secondary hover:bg-slate-100'"
|
||||
@click="ws.selectedCategory = category"
|
||||
>
|
||||
{{ category }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="mb-6">
|
||||
<input v-model="ws.searchQuery" type="text" :placeholder="$t('workspace.search')" class="input-field max-w-md shadow-sm" />
|
||||
</div>
|
||||
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3 sm:gap-6">
|
||||
<div v-for="agent in ws.otherAgents" :key="agent.id"
|
||||
@click="ws.navigateToChat(agent.id)"
|
||||
class="card card-mobile-compact cursor-pointer relative group/card hover:-translate-y-1 hover:border-brand-200">
|
||||
<div class="flex items-start justify-between mb-2 sm:mb-4">
|
||||
<div class="w-8 h-8 sm:w-10 sm:h-10 bg-surface-soft rounded-xl flex items-center justify-center text-muted group-hover/card:bg-brand-50 group-hover/card:text-brand-600 transition-colors">
|
||||
<img v-if="agent.icon_url" :src="agent.icon_url" class="w-4 h-4 sm:w-6 sm:h-6" />
|
||||
<Bot v-else class="w-4 h-4 sm:w-6 sm:h-6" />
|
||||
<div v-if="section.id === 'quick_questions'">
|
||||
<ElCard v-if="ws.isAddingQuestion" shadow="never" class="workspace-question-form">
|
||||
<h3 class="section-title">
|
||||
{{ ws.editingQuestionId ? t('workspace.quickQuestions.edit') : t('workspace.quickQuestions.addNew') }}
|
||||
</h3>
|
||||
<ElForm label-position="top">
|
||||
<div class="workspace-question-form__grid">
|
||||
<ElFormItem :label="t('workspace.quickQuestions.fields.title')">
|
||||
<ElInput v-model="ws.newQuestion.title" :placeholder="t('workspace.quickQuestions.fields.titlePlaceholder')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('workspace.quickQuestions.fields.targetAgent')">
|
||||
<ElSelect
|
||||
class="workspace-question-form__select"
|
||||
:model-value="ws.newQuestion.agent_id ?? undefined"
|
||||
:disabled="ws.agents.length === 0"
|
||||
:placeholder="ws.agents.length === 0 ? t('workspace.noAgents') : t('workspace.quickQuestions.fields.selectAgent')"
|
||||
@update:model-value="onQuestionAgentChange"
|
||||
>
|
||||
<ElOption v-for="agent in ws.agents" :key="agent.id" :label="agent.name" :value="agent.id" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="workspace-question-form__wide" :label="t('workspace.quickQuestions.fields.content')">
|
||||
<ElInput
|
||||
v-model="ws.newQuestion.question"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
:placeholder="t('workspace.quickQuestions.fields.contentPlaceholder')"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<button @click.stop="ws.toggleFavorite(agent.id)" class="text-slate-200 hover:text-yellow-400 transition-colors">
|
||||
<Star class="w-5 h-5" :class="{ 'fill-yellow-400 text-yellow-400': ws.favoriteAgentIds.includes(agent.id) }" />
|
||||
</button>
|
||||
</div>
|
||||
<h3 class="text-[15px] sm:text-base font-semibold text-primary mb-1 group-hover/card:text-brand-700 transition-colors line-clamp-1 sm:line-clamp-2 leading-tight">{{ agent.name }}</h3>
|
||||
<p class="text-[13px] sm:text-xs text-muted line-clamp-1 sm:line-clamp-2 h-4 sm:h-8 leading-relaxed">{{ agent.description }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="workspace-question-form__actions">
|
||||
<ElButton @click="ws.cancelAddQuestion">{{ t('workspace.cancel') }}</ElButton>
|
||||
<ElButton type="primary" @click="ws.saveQuickQuestion">{{ t('workspace.save') }}</ElButton>
|
||||
</div>
|
||||
</ElForm>
|
||||
</ElCard>
|
||||
<ElEmpty
|
||||
v-if="ws.filteredQuickQuestions.length === 0 && !ws.isAddingQuestion"
|
||||
:description="t('workspace.quickQuestions.noDefined')"
|
||||
/>
|
||||
<div v-else class="workspace-question-grid">
|
||||
<article
|
||||
v-for="qq in ws.filteredQuickQuestions"
|
||||
:key="qq.id"
|
||||
class="workspace-question-card"
|
||||
@click="ws.navigateWithQuickQuestion(qq.agent_id, qq.question)"
|
||||
>
|
||||
<div class="workspace-question-card__head">
|
||||
<h4>{{ qq.title }}</h4>
|
||||
<ElTag effect="light">{{ ws.getAgentName(qq.agent_id) }}</ElTag>
|
||||
</div>
|
||||
<p>{{ qq.question }}</p>
|
||||
<div class="workspace-question-card__actions">
|
||||
<ElButton link type="primary" :icon="Edit" :title="t('workspace.quickQuestions.edit')" @click.stop="ws.editQuickQuestion(qq)" />
|
||||
<ElButton link type="danger" :icon="Delete" :title="t('workspace.quickQuestions.deleteDialog.title')" @click.stop="ws.removeQuickQuestion(qq.id)" />
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="section.id === 'embedded'">
|
||||
<ElEmpty v-if="ws.embeddedAgents.length === 0" :description="t('workspace.embedded.noData')" />
|
||||
<div v-else class="workspace-embed-grid">
|
||||
<article v-for="agent in ws.embeddedAgents" :key="agent.id" class="workspace-embed">
|
||||
<div class="workspace-embed__bar">
|
||||
<span>{{ agent.name }}</span>
|
||||
<a class="workspace-embed__open" :href="`/chat/${agent.id}`" target="_blank" rel="noopener">
|
||||
<ElIcon><TopRight /></ElIcon>
|
||||
</a>
|
||||
</div>
|
||||
<iframe v-if="agent.iframe_url" :src="agent.iframe_url" class="workspace-embed__frame" />
|
||||
<ElEmpty v-else :description="t('workspace.embedded.noUrl')" />
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="section.id === 'all_agents'" class="workspace-agents">
|
||||
<ElRadioGroup
|
||||
class="workspace-categories"
|
||||
:model-value="ws.selectedCategory || ''"
|
||||
@update:model-value="onCategoryChange"
|
||||
>
|
||||
<ElRadioButton value="">{{ t('workspace.agentCategory.all') }}</ElRadioButton>
|
||||
<ElRadioButton v-for="category in ws.agentCategories" :key="category" :value="category">
|
||||
{{ category }}
|
||||
</ElRadioButton>
|
||||
</ElRadioGroup>
|
||||
<ElInput
|
||||
v-model="ws.searchQuery"
|
||||
class="workspace-search"
|
||||
clearable
|
||||
:placeholder="t('workspace.search')"
|
||||
/>
|
||||
<div class="workspace-card-grid">
|
||||
<article
|
||||
v-for="agent in ws.otherAgents"
|
||||
:key="agent.id"
|
||||
class="workspace-app-card"
|
||||
@click="ws.navigateToChat(agent.id)"
|
||||
>
|
||||
<div class="workspace-app-card__top">
|
||||
<div class="workspace-app-card__icon">
|
||||
<img v-if="agent.icon_url" :src="agent.icon_url" alt="" />
|
||||
<ElIcon v-else><Monitor /></ElIcon>
|
||||
</div>
|
||||
<ElButton
|
||||
link
|
||||
:icon="ws.favoriteAgentIds.includes(agent.id) ? StarFilled : Star"
|
||||
:title="t('workspace.favorites')"
|
||||
:class="{ 'workspace-app-card__star--on': ws.favoriteAgentIds.includes(agent.id) }"
|
||||
@click.stop="ws.toggleFavorite(agent.id)"
|
||||
/>
|
||||
</div>
|
||||
<h3 class="workspace-app-card__name">{{ agent.name }}</h3>
|
||||
<p class="workspace-app-card__desc">{{ agent.description }}</p>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ElCard>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.workspace-hint {
|
||||
margin-bottom: 16px;
|
||||
padding: 12px 16px;
|
||||
border: 1px solid var(--el-color-primary-light-7);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
background: var(--el-color-primary-light-9);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.workspace-section {
|
||||
width: 100%;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.workspace-section--compact :deep(.el-card__body) {
|
||||
padding-top: 8px;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.workspace-section__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.workspace-section__head--compact {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.workspace-section__lead {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.workspace-empty {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: var(--el-font-size-small);
|
||||
}
|
||||
|
||||
.workspace-section__title {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.workspace-section__icon {
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.workspace-section__grip {
|
||||
color: var(--el-text-color-secondary);
|
||||
cursor: grab;
|
||||
}
|
||||
|
||||
.workspace-card-grid,
|
||||
.workspace-question-grid,
|
||||
.workspace-embed-grid {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.workspace-card-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.workspace-question-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.workspace-embed-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.workspace-app-card,
|
||||
.workspace-question-card {
|
||||
position: relative;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
background: var(--el-bg-color);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.workspace-app-card__top,
|
||||
.workspace-question-card__head,
|
||||
.workspace-embed__bar,
|
||||
.workspace-question-form__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.workspace-app-card__icon {
|
||||
display: flex;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 8px;
|
||||
background: var(--el-color-primary-light-9);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.workspace-app-card__icon img {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.workspace-app-card__name,
|
||||
.workspace-question-card h4 {
|
||||
margin: 8px 0 4px;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: var(--el-font-size-base);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.workspace-app-card__desc,
|
||||
.workspace-question-card p {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: var(--el-font-size-small);
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
}
|
||||
|
||||
.workspace-app-card__star {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
}
|
||||
|
||||
.workspace-app-card__star--on {
|
||||
color: var(--el-color-warning);
|
||||
}
|
||||
|
||||
.workspace-question-card__actions {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.workspace-question-card:hover .workspace-question-card__actions {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.workspace-question-form {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.workspace-question-form__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0 16px;
|
||||
}
|
||||
|
||||
.workspace-question-form__select {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.workspace-question-form__actions {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.workspace-agents {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.workspace-categories {
|
||||
display: flex;
|
||||
width: fit-content;
|
||||
max-width: 100%;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.workspace-search {
|
||||
display: flex;
|
||||
width: min(100%, 24rem);
|
||||
margin-top: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.workspace-announcements {
|
||||
max-width: 42rem;
|
||||
}
|
||||
|
||||
.workspace-embed {
|
||||
display: flex;
|
||||
height: 500px;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
}
|
||||
|
||||
.workspace-embed__bar {
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
|
||||
.workspace-embed__open {
|
||||
display: inline-flex;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.workspace-embed__frame {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.workspace-card-grid {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.workspace-question-grid,
|
||||
.workspace-question-form__grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.workspace-question-form__wide {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.workspace-card-grid,
|
||||
.workspace-embed-grid {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.workspace-embed-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.workspace-question-grid {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user