feat: 优化

This commit is contained in:
2026-02-26 20:27:41 +08:00
parent 2d96e8ca4e
commit 72fa2c63a1
4 changed files with 52 additions and 53 deletions

View File

@@ -109,6 +109,16 @@
:style="{ '--i': index }" :style="{ '--i': index }"
@click="handleAgentClick(agent)" @click="handleAgentClick(agent)"
> >
<!-- 收藏图标 - 右上角 -->
<button
class="favorite-icon"
:class="{ 'favorite-icon--active': agent.isFavorite }"
@click.stop="handleFavorite(agent)"
>
<StarFilled v-if="agent.isFavorite" />
<StarOutlined v-else />
</button>
<!-- 卡片内容 --> <!-- 卡片内容 -->
<div class="card-content"> <div class="card-content">
<!-- 左侧头像 --> <!-- 左侧头像 -->
@@ -134,16 +144,6 @@
<!-- 底部操作栏 --> <!-- 底部操作栏 -->
<div class="card-footer"> <div class="card-footer">
<button
class="favorite-btn"
:class="{ 'favorite-btn--active': agent.isFavorite }"
@click.stop="handleFavorite(agent)"
>
<StarFilled v-if="agent.isFavorite" />
<StarOutlined v-else />
<span>{{ agent.isFavorite ? '已收藏' : '收藏' }}</span>
</button>
<div class="footer-spacer"></div>
<button class="chat-btn" @click.stop="handleChat(agent)"> <button class="chat-btn" @click.stop="handleChat(agent)">
<MessageOutlined class="chat-btn-icon" /> <MessageOutlined class="chat-btn-icon" />
<span>对话</span> <span>对话</span>
@@ -798,7 +798,7 @@ onMounted(() => {
.card-footer { .card-footer {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: flex-end; justify-content: center;
padding: 12px 16px; padding: 12px 16px;
border-top: 1px solid #F3F4F6; border-top: 1px solid #F3F4F6;
background: #FAFAFA; background: #FAFAFA;
@@ -807,10 +807,6 @@ onMounted(() => {
transition: all 0.25s ease; transition: all 0.25s ease;
} }
.footer-spacer {
flex: 1;
}
.chat-btn { .chat-btn {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@@ -839,37 +835,57 @@ onMounted(() => {
font-size: 13px; font-size: 13px;
} }
// 收藏按钮 // 收藏图标 - 右上角
.favorite-btn { .favorite-icon {
display: inline-flex; position: absolute;
align-items: center; top: 12px;
gap: 5px; right: 12px;
padding: 6px 12px; width: 32px;
background: transparent; height: 32px;
border: 1px solid var(--color-gray-300); border: none;
border-radius: 8px; background: rgba(255, 255, 255, 0.9);
font-size: 12px; border-radius: 50%;
font-weight: 500;
color: var(--color-gray-600);
cursor: pointer; cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
color: var(--color-gray-400);
font-size: 16px;
transition: all 0.2s ease; transition: all 0.2s ease;
z-index: 2;
opacity: 0;
transform: scale(0.8);
&:hover { &:hover {
border-color: #F59E0B; background: white;
color: #F59E0B; color: #F59E0B;
background: #FFFBEB; transform: scale(1);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
} }
&:active { &:active {
transform: scale(0.95); transform: scale(0.9);
} }
// 收藏状态 - 常显
&--active { &--active {
border-color: #F59E0B; opacity: 1;
transform: scale(1);
color: #F59E0B; color: #F59E0B;
background: #FFFBEB; background: #FEF3C7;
&:hover {
background: #FDE68A;
color: #D97706;
} }
} }
}
// 卡片hover时显示收藏图标
.agent-card:hover .favorite-icon:not(.favorite-icon--active) {
opacity: 1;
transform: scale(1);
}
// ============================================ // ============================================
// 空状态 // 空状态

View File

@@ -39,24 +39,6 @@
/> />
</div> </div>
<div class="setting-group">
<label class="setting-label">合成模型等级</label>
<div class="model-options">
<button
class="model-btn"
:class="{ 'model-btn--active': store.speechRate <= 1 }"
>
标准版 (1x积分)
</button>
<button
class="model-btn model-btn--pro"
:class="{ 'model-btn--active': store.speechRate > 1 }"
>
Pro 旗舰版 (3x积分)
<CrownFilled class="pro-icon" />
</button>
</div>
</div>
</div> </div>
</div> </div>

View File

@@ -3,10 +3,12 @@ package cn.iocoder.yudao.module.tik.muye.aiagent.dal;
import lombok.*; import lombok.*;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
/** /**
* AI智能体收藏 DO * AI智能体收藏 DO
*/ */
@TenantIgnore
@TableName("muye_ai_agent_favorite") @TableName("muye_ai_agent_favorite")
@KeySequence("muye_ai_agent_favorite_seq") @KeySequence("muye_ai_agent_favorite_seq")
@Data @Data

View File

@@ -20,7 +20,6 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
@Validated @Validated
public class AiAgentFavoriteServiceImpl implements AiAgentFavoriteService { public class AiAgentFavoriteServiceImpl implements AiAgentFavoriteService {
private static final ErrorCode FAVORITE_EXISTS = new ErrorCode(1_013_001_000, "已收藏该智能体");
private static final ErrorCode FAVORITE_NOT_EXISTS = new ErrorCode(1_013_001_001, "未收藏该智能体"); private static final ErrorCode FAVORITE_NOT_EXISTS = new ErrorCode(1_013_001_001, "未收藏该智能体");
@Resource @Resource
@@ -28,10 +27,10 @@ public class AiAgentFavoriteServiceImpl implements AiAgentFavoriteService {
@Override @Override
public Long createFavorite(Long userId, Long agentId) { public Long createFavorite(Long userId, Long agentId) {
// 检查是否已收藏 // 检查是否已收藏(幂等:已存在则直接返回)
AiAgentFavoriteDO existFavorite = aiAgentFavoriteMapper.selectByUserIdAndAgentId(userId, agentId); AiAgentFavoriteDO existFavorite = aiAgentFavoriteMapper.selectByUserIdAndAgentId(userId, agentId);
if (existFavorite != null) { if (existFavorite != null) {
throw exception(FAVORITE_EXISTS); return existFavorite.getId();
} }
// 创建收藏 // 创建收藏