更新Ai Agent标题字段

This commit is contained in:
jingrow 2026-07-01 00:59:02 +08:00
parent e1ca5feef1
commit 919a6d284d
3 changed files with 81 additions and 64 deletions

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref, computed, h, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { NSpin, NButton } from 'naive-ui'
import { NSpin, NDropdown } from 'naive-ui'
import { Icon } from '@iconify/vue'
import { getAgentList, createChat, type AiAgentRecord } from '@/shared/api/chat'
import { pageTypeToSlug } from '@/shared/utils/slug'
@ -41,6 +41,17 @@ async function loadAgents() {
onMounted(() => {
loadAgents()
})
// ===== =====
const cardMenuOptions = computed(() => [
{ label: t('View details'), key: 'view_detail', icon: () => h(Icon, { icon: 'tabler:eye', size: 14 }) },
])
function handleCardMenuSelect(key: string, agent: AiAgentRecord) {
if (key === 'view_detail') {
emit('viewDetail', agent)
}
}
</script>
<template>
@ -116,22 +127,23 @@ onMounted(() => {
class="al-card"
@click="emit('startChat', agent)"
>
<div class="card-menu-area">
<n-dropdown
trigger="click"
:options="cardMenuOptions"
@select="(key: string) => handleCardMenuSelect(key, agent)"
>
<button class="card-menu-btn" @click.stop>
<Icon icon="tabler:dots-vertical" :size="16" />
</button>
</n-dropdown>
</div>
<div class="card-avatar">
<img v-if="agent.avatar" :src="agent.avatar" class="avatar-img" />
<Icon v-else icon="tabler:robot" :size="32" class="avatar-placeholder" />
<Icon v-else icon="tabler:robot" :size="36" class="avatar-placeholder" />
</div>
<div class="card-name">{{ agent.agent_name }}</div>
<div class="card-desc">{{ (agent.description || '').slice(0, 80) }}</div>
<div class="card-footer">
<button
class="card-view-btn"
@click.stop="emit('viewDetail', agent)"
:title="t('View details')"
>
<Icon icon="tabler:eye" :size="13" />
<span>{{ t('View') }}</span>
</button>
</div>
</div>
</div>
@ -366,13 +378,15 @@ onMounted(() => {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 6px;
padding: 20px 12px 14px;
padding: 16px 12px;
border: 1px solid #f0f0f0;
border-radius: 10px;
cursor: pointer;
transition: all 0.12s;
background: #fff;
position: relative;
}
.al-card:hover {
@ -380,6 +394,41 @@ onMounted(() => {
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
/* ===== 卡片三点菜单 ===== */
.card-menu-area {
position: absolute;
top: 8px;
right: 8px;
opacity: 0;
transition: opacity 0.15s;
z-index: 2;
}
.al-card:hover .card-menu-area {
opacity: 1;
}
.card-menu-btn {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
border: none;
border-radius: 6px;
background: rgba(255,255,255,0.9);
color: #6b7280;
cursor: pointer;
transition: all 0.12s;
box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card-menu-btn:hover {
background: #fff;
color: #374151;
box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.card-avatar {
width: 64px;
height: 64px;
@ -416,32 +465,6 @@ onMounted(() => {
min-height: 2.8em;
}
.card-footer {
margin-top: auto;
display: flex;
gap: 6px;
}
.card-view-btn {
display: flex;
align-items: center;
gap: 4px;
padding: 4px 10px;
border: 1px solid #e5e7eb;
border-radius: 6px;
background: transparent;
color: #6b7280;
font-size: 11px;
cursor: pointer;
transition: all 0.12s;
}
.card-view-btn:hover {
background: #f3f4f6;
color: #3b82f6;
border-color: #bfdbfe;
}
/* ===== Empty ===== */
.al-empty {
display: flex;

View File

@ -7,17 +7,16 @@
"field_order": [
"info_tab",
"agent_name",
"section_break_basic",
"description",
"column_break_basic",
"enabled",
"personality_tab",
"avatar",
"system_prompt",
"section_break_c95s",
"welcome_message",
"column_break_personality",
"exclude_prompts",
"personality_tab",
"model",
"temperature",
"system_prompt",
"skills_tab",
"skills",
"triggers_tab",
@ -27,7 +26,6 @@
"target_module",
"condition",
"trigger_time",
"exclude_prompts",
"repeat_count",
"memory_tab",
"memory_policy",
@ -54,19 +52,11 @@
"label": "Agent Name",
"reqd": 1
},
{
"fieldname": "section_break_basic",
"fieldtype": "Section Break"
},
{
"fieldname": "description",
"fieldtype": "Small Text",
"label": "Description"
},
{
"fieldname": "column_break_basic",
"fieldtype": "Column Break"
},
{
"default": "1",
"fieldname": "enabled",
@ -92,13 +82,9 @@
},
{
"fieldname": "welcome_message",
"fieldtype": "Text",
"fieldtype": "Small Text",
"label": "Welcome Message"
},
{
"fieldname": "column_break_personality",
"fieldtype": "Column Break"
},
{
"default": "Jingrow",
"fieldname": "model",
@ -237,12 +223,16 @@
"in_list_view": 1,
"label": "Last Active At",
"read_only": 1
},
{
"fieldname": "section_break_c95s",
"fieldtype": "Section Break"
}
],
"index_web_pages_for_search": 1,
"links": [],
"make_attachments_public": 1,
"modified": "2026-06-24 10:00:00.000000",
"modified": "2026-07-01 01:12:51.164971",
"modified_by": "Administrator",
"module": "Ai",
"name": "Ai Agent",
@ -263,8 +253,11 @@
}
],
"row_format": "Dynamic",
"show_title_field_in_link": 1,
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
"title_field": "agent_name",
"track_changes": 1,
"translated_pagetype": 1
}

View File

@ -14,10 +14,10 @@ class AiAgent(Page):
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from jingrow.ai.pagetype.ai_agent_skill.ai_agent_skill import AiAgentSkill
from jingrow.types import DF
agent_name: DF.Data
repeat_count: DF.Int
avatar: DF.AttachImage | None
condition: DF.SmallText | None
description: DF.SmallText | None
@ -29,7 +29,8 @@ class AiAgent(Page):
memory_policy: DF.Literal["auto", "manual", "hybrid"]
model: DF.Literal["Jingrow", "DeepSeek", "Doubao", "ChatGPT"]
preferences: DF.Text | None
skills: DF.Table["Ai Agent Skill"]
repeat_count: DF.Int
skills: DF.Table[AiAgentSkill]
system_prompt: DF.LongText | None
target_module: DF.Link | None
target_pagetype: DF.Link | None
@ -37,7 +38,7 @@ class AiAgent(Page):
total_conversations: DF.Int
total_tokens: DF.Int
trigger_mode: DF.Literal["Manual Trigger", "Event Trigger", "Scheduled Trigger"]
welcome_message: DF.Text | None
welcome_message: DF.SmallText | None
# end: auto-generated types
# Document hook methods