Skip to content

Commit fd2f761

Browse files
committed
feat(agents): add gitlab repo link and fix card hover cursor jitter
1 parent 28ad3e3 commit fd2f761

4 files changed

Lines changed: 85 additions & 15 deletions

File tree

‎app/web/pages/agents/components/AgentLogo.scss‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.agent-logo-interactive {
22
transition: transform 0.2s ease, box-shadow 0.2s ease;
3-
43
&:hover {
54
transform: scale(1.05);
65
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
@@ -11,7 +10,7 @@
1110
.ant-popover-inner {
1211
border-radius: 16px;
1312
box-shadow: 0 12px 36px rgba(15, 23, 42, 0.2);
14-
background: #ffffff;
13+
background: #FFF;
1514
}
1615
.ant-popover-inner-content {
1716
padding: 14px;
@@ -29,15 +28,15 @@
2928
.agent-logo-preview-img {
3029
border-radius: 14px;
3130
object-fit: cover;
32-
background: linear-gradient(135deg, #eff4ff, #eef2ff);
31+
background: linear-gradient(135deg, #EFF4FF, #EEF2FF);
3332
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
3433
display: block;
3534
}
3635

3736
.agent-logo-preview-title {
3837
font-size: 14px;
3938
font-weight: 600;
40-
color: #1e293b;
39+
color: #1E293B;
4140
max-width: 100%;
4241
text-align: center;
4342
overflow: hidden;

‎app/web/pages/agents/detail/AgentDetailContent.tsx‎

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import {
33
CodeOutlined,
44
CopyOutlined,
55
DownloadOutlined,
6+
GitlabOutlined,
67
QuestionCircleOutlined,
78
SettingOutlined,
89
SyncOutlined,
910
} from '@ant-design/icons';
10-
import { Button, Card, Empty, message, Spin, Tag, Tooltip, Typography } from 'antd';
11+
import { Button, Card, Empty, message, Space, Spin, Tag, Tooltip, Typography } from 'antd';
1112
import moment from 'moment';
1213

1314
import { API } from '@/api';
@@ -23,6 +24,23 @@ const { Paragraph, Text, Title } = Typography;
2324
const { normalizeAgentCapabilities } = require('./capability-utils');
2425
const { buildAgentIntroBlocks } = require('./intro-utils');
2526

27+
// 将 gitUrl 转换为可在浏览器中直接打开的 HTTP(S) 仓库页面地址
28+
const getRepoWebUrl = (gitUrl?: string): string => {
29+
if (!gitUrl) return '';
30+
const trimmed = gitUrl.trim();
31+
if (!trimmed) return '';
32+
// 兼容 SSH 格式:git@gitlab.xxx:group/project.git
33+
const sshMatch = trimmed.match(/^git@([^:]+):(.+?)(\.git)?$/i);
34+
if (sshMatch) {
35+
return `http://${sshMatch[1]}/${sshMatch[2]}`;
36+
}
37+
// 兼容 HTTP(S) 格式,去除末尾 .git 后缀方便直接访问网页
38+
if (/^https?:\/\//i.test(trimmed)) {
39+
return trimmed.replace(/\.git$/i, '');
40+
}
41+
return trimmed;
42+
};
43+
2644
const RelatedAgentCard: React.FC<{
2745
item: AgentItem;
2846
history: { push: (path: string) => void };
@@ -77,6 +95,20 @@ const AgentDetailContent: React.FC<AgentDetailContentProps> = ({ name, history }
7795
return m.isValid() ? m.format('YYYY-MM-DD HH:mm:ss') : '-';
7896
}, [detail?.lastGitSyncAt, detail?.updatedAt]);
7997

98+
// 打开 GitLab 远端仓库网页地址
99+
const handleOpenGitLab = () => {
100+
if (!detail?.gitUrl) {
101+
message.info('尚未配置 Git 仓库地址');
102+
return;
103+
}
104+
const webUrl = getRepoWebUrl(detail.gitUrl);
105+
if (webUrl) {
106+
safeOpenUrl(webUrl);
107+
} else {
108+
message.warning('无效的 Git 仓库地址');
109+
}
110+
};
111+
80112
const handleOpenSetting = () => {
81113
if (!detail) return;
82114
setSettingVisible(true);
@@ -474,15 +506,29 @@ const AgentDetailContent: React.FC<AgentDetailContentProps> = ({ name, history }
474506
className="agent-side-sync"
475507
title="Git 仓库设置"
476508
extra={
477-
<Tooltip title="Git 仓库设置">
478-
<Button
479-
type="text"
480-
size="small"
481-
className="agent-side-sync-setting-btn"
482-
icon={<SettingOutlined />}
483-
onClick={handleOpenSetting}
484-
/>
485-
</Tooltip>
509+
<Space size={4}>
510+
<Tooltip title={detail?.gitUrl ? '打开仓库地址' : '未配置仓库地址'}>
511+
<span>
512+
<Button
513+
type="text"
514+
size="small"
515+
disabled={!detail?.gitUrl}
516+
className="agent-side-sync-gitlab-btn"
517+
icon={<GitlabOutlined />}
518+
onClick={handleOpenGitLab}
519+
/>
520+
</span>
521+
</Tooltip>
522+
<Tooltip title="Git 仓库设置">
523+
<Button
524+
type="text"
525+
size="small"
526+
className="agent-side-sync-setting-btn"
527+
icon={<SettingOutlined />}
528+
onClick={handleOpenSetting}
529+
/>
530+
</Tooltip>
531+
</Space>
486532
}
487533
>
488534
{detail.gitUrl ? (

‎app/web/pages/agents/detail/style.scss‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
.agent-side-sync {
4444
.ant-card-extra {
4545
padding: 12px 0;
46-
.ant-btn.agent-side-sync-setting-btn {
46+
.ant-btn.agent-side-sync-setting-btn,
47+
.ant-btn.agent-side-sync-gitlab-btn {
4748
width: 28px;
4849
height: 28px;
4950
min-width: 28px;
@@ -66,6 +67,11 @@
6667
color: #1E293B;
6768
background: #F1F5F9 !important;
6869
}
70+
&[disabled] {
71+
color: #CBD5E1 !important;
72+
background: transparent !important;
73+
cursor: not-allowed;
74+
}
6975
}
7076
}
7177
.agent-sync-meta-list {

‎app/web/pages/agents/style.scss‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,25 @@
7474
border-radius: 16px;
7575
border: 1px solid #EDF0F5;
7676
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
77+
cursor: pointer;
78+
user-select: none;
79+
.ant-card-body,
80+
.ant-typography,
81+
.ant-tag,
82+
.agent-card-head,
83+
.agent-card-brand,
84+
.agent-card-meta,
85+
.agent-card-description,
86+
.agent-card-tags,
87+
.agent-card-footer {
88+
cursor: pointer;
89+
}
90+
.agent-card-head > div:last-child {
91+
cursor: default;
92+
.ant-btn {
93+
cursor: pointer;
94+
}
95+
}
7796
.ant-card-body {
7897
display: flex;
7998
flex-direction: column;

0 commit comments

Comments
 (0)