From d85a1cf84ba4ae5d99b4bbd425600482e2fbc77d Mon Sep 17 00:00:00 2001 From: abearxiong Date: Fri, 20 Feb 2026 15:00:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=A9=BA=E7=99=BD?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=8A=9F=E8=83=BD=E4=BB=A5=E7=A1=AE=E4=BF=9D?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E5=9C=A8=E5=88=97=E8=A1=A8=E4=B8=AD=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E6=B4=BB=E8=B7=83=EF=BC=8C=E5=B9=B6=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/repo/components/RepoCard.tsx | 24 +++++++++++++++++++++--- src/app/repo/store/build.ts | 23 +++++++++++++++++++++-- src/app/repo/store/index.ts | 19 ++++++++++++++++++- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/src/app/repo/components/RepoCard.tsx b/src/app/repo/components/RepoCard.tsx index bd8735e..8d7a592 100644 --- a/src/app/repo/components/RepoCard.tsx +++ b/src/app/repo/components/RepoCard.tsx @@ -13,7 +13,7 @@ import { PopoverContent, PopoverTrigger, } from '@/components/ui/popover' -import { Star, GitFork, FileText, Edit, FolderGit2, MoreVertical, FileText as IssueIcon, Settings, Play, Trash2, RefreshCw, BookOpen, Copy } from 'lucide-react' +import { Star, GitFork, FileText, Edit, FolderGit2, MoreVertical, FileText as IssueIcon, Settings, Play, Trash2, RefreshCw, BookOpen, Copy, Clock, Info } from 'lucide-react' import { useRepoStore } from '../store' import { useMemo, useState } from 'react' import { myOrgs } from '../store/build' @@ -32,7 +32,7 @@ interface RepoCardProps { export function RepoCard({ repo, onStartWorkspace, onEdit, onIssue, onSettings, onDelete, onSync }: RepoCardProps) { const [deletePopoverOpen, setDeletePopoverOpen] = useState(false) - const { workspaceList, getWorkspaceDetail, getList } = useRepoStore(); + const { workspaceList, getWorkspaceDetail, getList, buildUpdate } = useRepoStore(); const workspace = useMemo(() => { return workspaceList.find(ws => ws.slug === repo.path) }, [workspaceList, repo.path]) @@ -56,6 +56,9 @@ export function RepoCard({ repo, onStartWorkspace, onEdit, onIssue, onSettings, toast.error('复制失败') }) } + const onUpdate = async () => { + await buildUpdate({ path: repo.path }); + } return ( <> @@ -136,6 +139,21 @@ export function RepoCard({ repo, onStartWorkspace, onEdit, onIssue, onSettings, 知识库创建 + { + onUpdate() + }} className="cursor-pointer"> + + + + + 更新时间 + + +

给仓库添加一个空白 commit 的提交,保证在仓库列表中顺序活跃在前面

+
+
+
+
Clone URL @@ -220,7 +238,7 @@ export function RepoCard({ repo, onStartWorkspace, onEdit, onIssue, onSettings, )} {repo.description && ( -

+

{repo.description}

)} diff --git a/src/app/repo/store/build.ts b/src/app/repo/store/build.ts index 63714a8..b3745ee 100644 --- a/src/app/repo/store/build.ts +++ b/src/app/repo/store/build.ts @@ -1,5 +1,5 @@ export const myOrgs = ['kevisual', 'kevision', 'skillpod', 'zxj.im', 'abearxiong'] - +import dayjs from 'dayjs' export const createBuildConfig = (params: { repo: string }) => { const toRepo = params.repo!; return ` @@ -30,4 +30,23 @@ main: api_trigger_sync_from_gitea: - <<: *common_sync_from_gitea ` -}; \ No newline at end of file +}; + +export const createCommitBlankConfig = (params: { repo?: string, event: 'api_trigger_event' }) => { + const now = dayjs().format('YYYY-MM-DD HH:mm') + const event = params?.event || 'api_trigger_event' + return `main: + ${event}: + - + services: + - docker + stages: + - name: 显示 git remote + script: git remote -v + - name: commit_blank + script: | + echo "这是一个空白提交 时间: ${now}" + git commit --allow-empty -m "up: ${now}" + git push +` +} \ No newline at end of file diff --git a/src/app/repo/store/index.ts b/src/app/repo/store/index.ts index e54f360..5e439a0 100644 --- a/src/app/repo/store/index.ts +++ b/src/app/repo/store/index.ts @@ -3,7 +3,7 @@ import { query } from '@/modules/query'; import { toast } from 'sonner'; import { cnb } from '@/agents/app' import { WorkspaceInfo } from '@kevisual/cnb' -import { createBuildConfig } from './build'; +import { createBuildConfig, createCommitBlankConfig } from './build'; interface DisplayModule { activity: boolean; contributors: boolean; @@ -82,6 +82,7 @@ type State = { selectedSyncRepo: Data | null; setSelectedSyncRepo: (repo: Data | null) => void; buildSync: (data: Partial, params: { toRepo?: string, fromRepo?: string }) => Promise; + buildUpdate: (data: Partial, params?: any) => Promise; } export const useRepoStore = create((set, get) => { @@ -347,6 +348,22 @@ export const useRepoStore = create((set, get) => { } else { toast.error(res.message || '同步提交失败') } + }, + buildUpdate: async (data) => { + const res = await cnb.build.startBuild(data.path!, { + branch: 'main', + env: {}, + event: 'api_trigger_event', + config: createCommitBlankConfig({ repo: data.path!, event: 'api_trigger_event' }), + }) + if (res.code === 200) { + toast.success('更新成功') + setTimeout(() => { + get().refresh({ showTips: false }) + }, 5000) + } else { + toast.error(res.message || '更新失败') + } } } })