feat: 优化
This commit is contained in:
@@ -109,6 +109,16 @@
|
||||
:style="{ '--i': index }"
|
||||
@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">
|
||||
<!-- 左侧头像 -->
|
||||
@@ -134,16 +144,6 @@
|
||||
|
||||
<!-- 底部操作栏 -->
|
||||
<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)">
|
||||
<MessageOutlined class="chat-btn-icon" />
|
||||
<span>对话</span>
|
||||
@@ -798,7 +798,7 @@ onMounted(() => {
|
||||
.card-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
justify-content: center;
|
||||
padding: 12px 16px;
|
||||
border-top: 1px solid #F3F4F6;
|
||||
background: #FAFAFA;
|
||||
@@ -807,10 +807,6 @@ onMounted(() => {
|
||||
transition: all 0.25s ease;
|
||||
}
|
||||
|
||||
.footer-spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.chat-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -839,38 +835,58 @@ onMounted(() => {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
// 收藏按钮
|
||||
.favorite-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 6px 12px;
|
||||
background: transparent;
|
||||
border: 1px solid var(--color-gray-300);
|
||||
border-radius: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: var(--color-gray-600);
|
||||
// 收藏图标 - 右上角
|
||||
.favorite-icon {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 12px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: none;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--color-gray-400);
|
||||
font-size: 16px;
|
||||
transition: all 0.2s ease;
|
||||
z-index: 2;
|
||||
opacity: 0;
|
||||
transform: scale(0.8);
|
||||
|
||||
&:hover {
|
||||
border-color: #F59E0B;
|
||||
background: white;
|
||||
color: #F59E0B;
|
||||
background: #FFFBEB;
|
||||
transform: scale(1);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: scale(0.95);
|
||||
transform: scale(0.9);
|
||||
}
|
||||
|
||||
// 收藏状态 - 常显
|
||||
&--active {
|
||||
border-color: #F59E0B;
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
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);
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// 空状态
|
||||
// ============================================
|
||||
|
||||
@@ -39,24 +39,6 @@
|
||||
/>
|
||||
</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>
|
||||
|
||||
|
||||
@@ -3,10 +3,12 @@ package cn.iocoder.yudao.module.tik.muye.aiagent.dal;
|
||||
import lombok.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||
|
||||
/**
|
||||
* AI智能体收藏 DO
|
||||
*/
|
||||
@TenantIgnore
|
||||
@TableName("muye_ai_agent_favorite")
|
||||
@KeySequence("muye_ai_agent_favorite_seq")
|
||||
@Data
|
||||
|
||||
@@ -20,7 +20,6 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
|
||||
@Validated
|
||||
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, "未收藏该智能体");
|
||||
|
||||
@Resource
|
||||
@@ -28,10 +27,10 @@ public class AiAgentFavoriteServiceImpl implements AiAgentFavoriteService {
|
||||
|
||||
@Override
|
||||
public Long createFavorite(Long userId, Long agentId) {
|
||||
// 检查是否已收藏
|
||||
// 检查是否已收藏(幂等:已存在则直接返回)
|
||||
AiAgentFavoriteDO existFavorite = aiAgentFavoriteMapper.selectByUserIdAndAgentId(userId, agentId);
|
||||
if (existFavorite != null) {
|
||||
throw exception(FAVORITE_EXISTS);
|
||||
return existFavorite.getId();
|
||||
}
|
||||
|
||||
// 创建收藏
|
||||
|
||||
Reference in New Issue
Block a user