Compare commits

...
13 changed files with 4498 additions and 3353 deletions

No files matched your search

+1 -1
View File
@@ -1 +1 @@
v2026.07.19.10 v2026.07.20.1
+6
View File
@@ -894,6 +894,12 @@ export const adminAPI = {
// Phase 3.3: 多 Agent 编排图 (orchestration) // Phase 3.3: 多 Agent 编排图 (orchestration)
getAgentOrchestration: (id: string) => get<any>(`/admin/agents/${id}/orchestration`), getAgentOrchestration: (id: string) => get<any>(`/admin/agents/${id}/orchestration`),
setAgentOrchestration: (id: string, orchestration: any) => put<any>(`/admin/agents/${id}/orchestration`, { orchestration }), setAgentOrchestration: (id: string, orchestration: any) => put<any>(`/admin/agents/${id}/orchestration`, { orchestration }),
importYamlOrch: (id: string, yaml: string) => post<any>(`/admin/agents/${id}/orchestration/yaml/import`, { yaml_text: yaml }),
exportYamlOrch: (id: string) => post<any>(`/admin/agents/${id}/orchestration/yaml/export`),
getYamlTemplates: () => get<any>('/admin/agents/orchestration/yaml/templates'),
getAcaProtocols: () => get<any>("/admin/agents/aca/protocols"),
getAcaProtocolTools: (name: string) => get<any>(`/admin/agents/aca/protocols/${name}/tools`),
checkAcaHealth: (name: string) => post<any>(`/admin/agents/aca/protocols/${name}/health`, {}),
getAdminAvailableSkills: (params?: any) => { getAdminAvailableSkills: (params?: any) => {
+1 -1
View File
@@ -1121,7 +1121,7 @@ const Achievement: React.FC = () => {
<td style={{ color: 'rgba(0,0,0,0.4)' }}> <td style={{ color: 'rgba(0,0,0,0.4)' }}>
{entry.last_completed ? new Date(entry.last_completed).toLocaleDateString('zh-CN') : '-'} {entry.last_completed ? formatBjDate(entry.last_completed) : '-'}
</td> </td>
+2 -1
View File
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { adminAPI, marketAPI } from '@/api'; import { adminAPI, marketAPI } from '@/api';
import type { AdBanner, MarketApp } from '@/types'; import type { AdBanner, MarketApp } from '@/types';
import { formatBjDate } from '@/utils/datetime';
import './Ads.css'; import './Ads.css';
const SVGIcon: React.FC<{ children: React.ReactNode; size?: number }> = ({ children, size = 16 }) => ( const SVGIcon: React.FC<{ children: React.ReactNode; size?: number }> = ({ children, size = 16 }) => (
@@ -281,7 +282,7 @@ const Ads: React.FC = () => {
</span> </span>
</td> </td>
<td style={{ fontSize: 'var(--text-xs)', color: 'var(--color-text-tertiary)' }}> <td style={{ fontSize: 'var(--text-xs)', color: 'var(--color-text-tertiary)' }}>
{new Date(banner.createdAt).toLocaleDateString()} {formatBjDate(banner.createdAt)}
</td> </td>
<td> <td>
<div style={{ display: 'flex', gap: 'var(--space-xs)' }}> <div style={{ display: 'flex', gap: 'var(--space-xs)' }}>
File diff suppressed because it is too large. Load diff
+3 -7
View File
@@ -1,7 +1,7 @@
import { useState, useEffect, useCallback } from 'react'; import { useState, useEffect, useCallback } from 'react';
import { adminAPI } from '@/api'; import { adminAPI } from '@/api';
import './Apps.css'; import './Apps.css';
import { formatBjTime } from '@/utils/datetime'; import { formatBjTime, formatBjDate } from '@/utils/datetime';
interface AIApp { interface AIApp {
id: string; id: string;
@@ -224,11 +224,7 @@ export default function AdminApps() {
}; };
const formatDate = (dt: string | null) => { const formatDate = (dt: string | null) => {
if (!dt) return '-'; return formatBjTime(dt);
try {
const d = new Date(dt);
return d.toLocaleDateString('zh-CN') + ' ' + d.toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' });
} catch { return dt; }
}; };
return ( return (
@@ -738,7 +734,7 @@ function AppDetailDrawer({ app, analytics, onClose, onAction }: {
<div key={v.id} className="version-item"> <div key={v.id} className="version-item">
<span className="version-num">v{v.version}</span> <span className="version-num">v{v.version}</span>
<span className="version-log">{v.changelog}</span> <span className="version-log">{v.changelog}</span>
<span className="version-date">{v.created_at ? new Date(v.created_at).toLocaleDateString('zh-CN') : '-'}</span> <span className="version-date">{v.created_at ? formatBjDate(v.created_at) : '-'}</span>
</div> </div>
))} ))}
</div> </div>
+141
View File
@@ -34,6 +34,29 @@ const styles: Record<string, React.CSSProperties> = {
detailsGrid: { display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 12, marginTop: 16 }, detailsGrid: { display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 12, marginTop: 16 },
detailsItem: { fontSize: 13 }, detailsItem: { fontSize: 13 },
detailsLabel: { color: '#6b7280', marginBottom: 4 }, detailsLabel: { color: '#6b7280', marginBottom: 4 },
// ACA 协议抽象层 (Phase 4.3)
acaSection: { marginTop: 32, backgroundColor: '#fff', borderRadius: 12, padding: 24, boxShadow: '0 1px 3px rgba(0,0,0,0.08)' },
acaHead: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 },
acaTitle: { fontSize: 18, fontWeight: 700, color: '#1A1F36' },
acaSub: { fontSize: 13, color: '#6b7280', marginTop: 4 },
acaRefresh: { padding: '8px 16px', border: '1px solid #e5e7eb', borderRadius: 8, cursor: 'pointer', backgroundColor: '#fff', fontSize: 13 },
acaGrid: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(280px, 1fr))', gap: 16 },
acaCard: { border: '1px solid #e5e7eb', borderRadius: 12, padding: 16 },
acaCardTop: { display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' },
acaProtoName: { fontSize: 16, fontWeight: 700, color: '#1A1F36', textTransform: 'uppercase' },
acaVer: { fontSize: 12, color: '#9ca3af', marginLeft: 8 },
acaCaps: { display: 'flex', gap: 6, flexWrap: 'wrap', marginTop: 10 },
acaCap: { fontSize: 12, padding: '2px 8px', borderRadius: 12, backgroundColor: '#eef2ff', color: '#4338ca' },
acaActions: { display: 'flex', gap: 8, marginTop: 14 },
acaBtn: { padding: '6px 14px', border: '1px solid #e5e7eb', borderRadius: 6, cursor: 'pointer', backgroundColor: '#fff', fontSize: 13 },
acaBtnPrimary: { padding: '6px 14px', border: 'none', borderRadius: 6, cursor: 'pointer', backgroundColor: '#4f46e5', color: '#fff', fontSize: 13 },
acaHealth: { fontSize: 12, fontWeight: 600, marginTop: 10 },
acaTools: { marginTop: 12, borderTop: '1px solid #f3f4f6', paddingTop: 12 },
acaTool: { padding: '8px 0', borderBottom: '1px solid #f9fafb' },
acaToolName: { fontSize: 13, fontWeight: 600, color: '#374151' },
acaToolServer: { fontSize: 11, color: '#4f46e5', marginLeft: 8 },
acaToolDesc: { fontSize: 12, color: '#9ca3af', marginTop: 2 },
acaEmpty: { fontSize: 13, color: '#9ca3af', padding: '12px 0' },
}; };
const TRANSPORT_TYPES = [ const TRANSPORT_TYPES = [
@@ -83,6 +106,13 @@ export default function AdminMcp() {
const [editingServer, setEditingServer] = useState<MCPServer | null>(null); const [editingServer, setEditingServer] = useState<MCPServer | null>(null);
const [toast, setToast] = useState<{ message: string; type: string } | null>(null); const [toast, setToast] = useState<{ message: string; type: string } | null>(null);
const pageSize = 20; const pageSize = 20;
// ACA 协议抽象层 (Phase 4.3)
const [acaProtocols, setAcaProtocols] = useState<any[]>([]);
const [acaLoading, setAcaLoading] = useState(true);
const [acaTools, setAcaTools] = useState<Record<string, any[]>>({});
const [acaExpanded, setAcaExpanded] = useState<Record<string, boolean>>({});
const [acaHealth, setAcaHealth] = useState<Record<string, boolean>>({});
const [acaChecking, setAcaChecking] = useState<Record<string, boolean>>({});
const showToast = (message: string, type: string = 'success') => { const showToast = (message: string, type: string = 'success') => {
setToast({ message, type }); setToast({ message, type });
@@ -119,6 +149,52 @@ export default function AdminMcp() {
fetchStats(); fetchStats();
fetchServers(); fetchServers();
}, [fetchStats, fetchServers]); }, [fetchStats, fetchServers]);
// ACA 协议抽象层 (Phase 4.3)
const fetchAcaProtocols = useCallback(async () => {
setAcaLoading(true);
try {
const result = await adminAPI.getAcaProtocols() as any;
const list = Array.isArray(result) ? result : (result && result.data ? result.data : []);
setAcaProtocols(list);
} catch (e) {
setAcaProtocols([]);
} finally {
setAcaLoading(false);
}
}, []);
const fetchAcaTools = useCallback(async (name: string) => {
try {
const result = await adminAPI.getAcaProtocolTools(name) as any;
const tools = result && result.tools ? result.tools : (result && result.data ? (result.data.tools || []) : []);
setAcaTools(prev => ({ ...prev, [name]: tools }));
} catch (e) {
setAcaTools(prev => ({ ...prev, [name]: [] }));
}
}, []);
const toggleAcaTools = (name: string) => {
setAcaExpanded(prev => {
const next = !prev[name];
if (next && !acaTools[name]) fetchAcaTools(name);
return { ...prev, [name]: next };
});
};
const checkAcaHealth = async (name: string) => {
setAcaChecking(prev => ({ ...prev, [name]: true }));
try {
const result = await adminAPI.checkAcaHealth(name) as any;
const healthy = result ? (result.healthy !== undefined ? result.healthy : (result.data ? result.data.healthy : false)) : false;
setAcaHealth(prev => ({ ...prev, [name]: healthy }));
} catch (e) {
setAcaHealth(prev => ({ ...prev, [name]: false }));
} finally {
setAcaChecking(prev => ({ ...prev, [name]: false }));
}
};
useEffect(() => { fetchAcaProtocols(); }, [fetchAcaProtocols]);
const handleCreate = () => { const handleCreate = () => {
setEditingServer(null); setEditingServer(null);
@@ -238,6 +314,71 @@ export default function AdminMcp() {
</div> </div>
</div> </div>
{/* Phase 4.3: ACA 协议抽象层 */}
<div style={styles.acaSection}>
<div style={styles.acaHead}>
<div>
<div style={styles.acaTitle}>ACA 协议抽象层</div>
<div style={styles.acaSub}>统一协议接入(MCP / A2A / 自定义),隔离底层实现,防止协议绑架</div>
</div>
<button style={styles.acaRefresh} onClick={() => fetchAcaProtocols()}>刷新</button>
</div>
{acaLoading ? (
<div style={styles.acaEmpty}>加载中...</div>
) : acaProtocols.length === 0 ? (
<div style={styles.acaEmpty}>未注册任何 ACA 协议</div>
) : (
<div style={styles.acaGrid}>
{acaProtocols.map((p: any) => (
<div key={p.name} style={styles.acaCard}>
<div style={styles.acaCardTop}>
<div>
<span style={styles.acaProtoName}>{p.name}</span>
<span style={styles.acaVer}>v{p.version}</span>
</div>
<span style={{ ...styles.badge, backgroundColor: '#dcfce7', color: '#166534' }}>已注册</span>
</div>
<div style={styles.acaCaps}>
{(p.capabilities || []).map((c: string) => (
<span key={c} style={styles.acaCap}>{c}</span>
))}
</div>
{acaHealth[p.name] !== undefined && (
<div style={{ ...styles.acaHealth, color: acaHealth[p.name] ? '#166534' : '#991b1b' }}>
健康:{acaHealth[p.name] ? '正常' : '异常'}
</div>
)}
<div style={styles.acaActions}>
<button style={styles.acaBtnPrimary} onClick={() => toggleAcaTools(p.name)}>
{acaExpanded[p.name] ? '隐藏工具' : `查看工具${acaTools[p.name] ? ' (' + acaTools[p.name].length + ')' : ''}`}
</button>
<button style={styles.acaBtn} disabled={acaChecking[p.name]} onClick={() => checkAcaHealth(p.name)}>
{acaChecking[p.name] ? '检测中...' : '健康检查'}
</button>
</div>
{acaExpanded[p.name] && (
<div style={styles.acaTools}>
{(acaTools[p.name] || []).length === 0 ? (
<div style={styles.acaEmpty}>暂无工具</div>
) : (
(acaTools[p.name] || []).map((t: any, idx: number) => (
<div key={(t.name || '') + idx} style={styles.acaTool}>
<div>
<span style={styles.acaToolName}>{t.name}</span>
{t._mcp_server_name && <span style={styles.acaToolServer}>@{t._mcp_server_name}</span>}
</div>
{t.description && <div style={styles.acaToolDesc}>{String(t.description).substring(0, 120)}</div>}
</div>
))
)}
</div>
)}
</div>
))}
</div>
)}
</div>
<div style={styles.toolbar}> <div style={styles.toolbar}>
<input <input
style={styles.searchInput} style={styles.searchInput}
+2 -1
View File
@@ -1,6 +1,7 @@
// @ts-nocheck // @ts-nocheck
import React, { useState, useEffect, useCallback } from 'react'; import React, { useState, useEffect, useCallback } from 'react';
import { imUserAPI } from '@/api'; import { imUserAPI } from '@/api';
import { formatBjDate } from '@/utils/datetime';
const PRIMARY = '#5B5FED'; const PRIMARY = '#5B5FED';
@@ -106,7 +107,7 @@ const AppServices: React.FC = () => {
</div> </div>
<p style={{ fontSize: '13px', color: '#6B7280', lineHeight: 1.7, flex: 1, margin: '0 0 14px 0' }}>{app.description || '暂无描述'}</p> <p style={{ fontSize: '13px', color: '#6B7280', lineHeight: 1.7, flex: 1, margin: '0 0 14px 0' }}>{app.description || '暂无描述'}</p>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}> <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<span style={{ fontSize: '12px', color: '#9CA3AF' }}>{app.published_at ? '上架于 ' + new Date(app.published_at).toLocaleDateString('zh-CN') : ''}</span> <span style={{ fontSize: '12px', color: '#9CA3AF' }}>{app.published_at ? '上架于 ' + formatBjDate(app.published_at) : ''}</span>
<button onClick={() => showToast('已加入「我的应用」,可在 AI 聊天中调用')} style={{ padding: '7px 16px', background: PRIMARY, border: 'none', borderRadius: '8px', color: '#fff', fontSize: '13px', fontWeight: 500, cursor: 'pointer' }}>使用</button> <button onClick={() => showToast('已加入「我的应用」,可在 AI 聊天中调用')} style={{ padding: '7px 16px', background: PRIMARY, border: 'none', borderRadius: '8px', color: '#fff', fontSize: '13px', fontWeight: 500, cursor: 'pointer' }}>使用</button>
</div> </div>
</div> </div>
+2 -1
View File
@@ -2,6 +2,7 @@ import React, { useState, useEffect, useCallback } from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import type { Asset, AssetCategory, AssetCategoryDef, AssetFileType } from '@/types'; import type { Asset, AssetCategory, AssetCategoryDef, AssetFileType } from '@/types';
import { assetsAPI } from '@/api'; import { assetsAPI } from '@/api';
import { formatBjTime } from '@/utils/datetime';
import './AssetsPage.css'; import './AssetsPage.css';
const fileTypeLabels: Record<string, { label: string; bg: string; color: string }> = { const fileTypeLabels: Record<string, { label: string; bg: string; color: string }> = {
@@ -46,7 +47,7 @@ function formatSize(bytes?: number): string {
} }
function formatDate(dateStr: string): string { function formatDate(dateStr: string): string {
return new Date(dateStr).toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }); return formatBjTime(dateStr);
} }
// 将文件扩展名或API返回的file_type映射到前端fileType标签 // 将文件扩展名或API返回的file_type映射到前端fileType标签
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+2 -1
View File
@@ -1596,6 +1596,7 @@ const MarketPage: React.FC = () => {
const [localApps, setLocalApps] = useState<MarketApp[]>([]); const [localApps, setLocalApps] = useState<MarketApp[]>([]);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [searchQuery, setSearchQuery] = useState(''); const [searchQuery, setSearchQuery] = useState('');
const searchTimerRef = useRef<number | null>(null);
const [capabilityFilter, setCapabilityFilter] = useState<string | null>(null); const [capabilityFilter, setCapabilityFilter] = useState<string | null>(null);
const [installToast, setInstallToast] = useState<string | null>(null); const [installToast, setInstallToast] = useState<string | null>(null);
@@ -1893,7 +1894,7 @@ const MarketPage: React.FC = () => {
className="form-input" className="form-input"
placeholder="搜索应用名称或描述..." placeholder="搜索应用名称或描述..."
value={searchQuery} value={searchQuery}
onChange={e => { setSearchQuery(e.target.value); loadApps(e.target.value); }} onChange={e => { const v = e.target.value; setSearchQuery(v); if (searchTimerRef.current) clearTimeout(searchTimerRef.current); searchTimerRef.current = window.setTimeout(() => loadApps(v), 350); }}
style={{ paddingLeft: 32, flex: 1, maxWidth: 400 }} style={{ paddingLeft: 32, flex: 1, maxWidth: 400 }}
/> />
{searchQuery && ( {searchQuery && (
+31
View File
@@ -7,3 +7,34 @@ export function formatBjTime(t?: string | null): string {
if (isNaN(d.getTime())) return t; if (isNaN(d.getTime())) return t;
return d.toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai', hour12: false }); return d.toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai', hour12: false });
} }
// 仅日期(北京时间)
export function formatBjDate(t?: string | null): string {
if (!t) return '-';
const iso = /[Z+]/.test(t) ? t : t + '+08:00';
const d = new Date(iso);
if (isNaN(d.getTime())) return t;
return d.toLocaleDateString('zh-CN', { timeZone: 'Asia/Shanghai' });
}
// 将任意 Date 换算为「北京墙钟」对应的 UTC 视图,便于按北京日历日比较
function toBjView(d: Date): Date {
return new Date(d.getTime() + (d.getTimezoneOffset() + 480) * 60000);
}
// 聊天消息时间:今天 HH:MM / 昨天 HH:MM / MM-DD HH:MM / YYYY-MM-DD HH:MM(北京时间)
export function formatChatTime(iso?: string | null): string {
if (!iso) return '';
const s = /[Z+]/.test(iso) ? iso : iso + '+08:00';
const d = new Date(s);
if (isNaN(d.getTime())) return '';
const bj = toBjView(d);
const nowBj = toBjView(new Date());
const dayDiff = Math.floor(nowBj.getTime() / 86400000) - Math.floor(bj.getTime() / 86400000);
const hhmm = d.toLocaleTimeString('zh-CN', { timeZone: 'Asia/Shanghai', hour: '2-digit', minute: '2-digit' });
if (dayDiff <= 0) return hhmm;
if (dayDiff === 1) return '昨天 ' + hhmm;
const md = d.toLocaleDateString('zh-CN', { timeZone: 'Asia/Shanghai', month: '2-digit', day: '2-digit' });
if (bj.getUTCFullYear() === nowBj.getUTCFullYear()) return md + ' ' + hhmm;
return d.toLocaleDateString('zh-CN', { timeZone: 'Asia/Shanghai', year: 'numeric', month: '2-digit', day: '2-digit' }) + ' ' + hhmm;
}