Git推送成功后现在会自动关闭推送窗口
This commit is contained in:
@@ -108,6 +108,12 @@ interface GitCommitSucceededEventPayload {
|
||||
committed_files: number
|
||||
}
|
||||
|
||||
interface GitPushSucceededEventPayload {
|
||||
folder_id: number
|
||||
pushed_commits: number
|
||||
upstream_set: boolean
|
||||
}
|
||||
|
||||
export function BranchDropdown({
|
||||
branch,
|
||||
parentBranch,
|
||||
@@ -187,6 +193,43 @@ export function BranchDropdown({
|
||||
}
|
||||
}, [folder, onBranchChange, t])
|
||||
|
||||
useEffect(() => {
|
||||
if (!folder) return
|
||||
|
||||
let unlisten: UnlistenFn | null = null
|
||||
|
||||
listen<GitPushSucceededEventPayload>(
|
||||
"folder://git-push-succeeded",
|
||||
(event) => {
|
||||
if (event.payload.folder_id !== folder.id) return
|
||||
const { pushed_commits, upstream_set } = event.payload
|
||||
let description: string
|
||||
if (upstream_set) {
|
||||
description =
|
||||
pushed_commits === 0
|
||||
? t("toasts.upstreamSet")
|
||||
: t("toasts.upstreamSetAndPushed", { count: pushed_commits })
|
||||
} else if (pushed_commits === 0) {
|
||||
description = t("toasts.noCommitsToPush")
|
||||
} else {
|
||||
description = t("toasts.pushedCommits", { count: pushed_commits })
|
||||
}
|
||||
toast.success(t("toasts.pushCodeCompleted"), { description })
|
||||
onBranchChange()
|
||||
}
|
||||
)
|
||||
.then((fn) => {
|
||||
unlisten = fn
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("[BranchDropdown] failed to listen push event:", err)
|
||||
})
|
||||
|
||||
return () => {
|
||||
disposeTauriListener(unlisten, "BranchDropdown.gitPushSucceeded")
|
||||
}
|
||||
}, [folder, onBranchChange, t])
|
||||
|
||||
async function runGitTask<T>(
|
||||
label: string,
|
||||
action: () => Promise<T>,
|
||||
|
||||
Reference in New Issue
Block a user