完成流水线控制器重构和相关功能改进

This commit is contained in:
2025-11-21 23:30:05 +08:00
parent fd0cf782c4
commit f8697b87e1
33 changed files with 1262 additions and 538 deletions

View File

@@ -1,10 +1,18 @@
import React, { useEffect } from 'react';
import type React from 'react';
import { useEffect, useCallback } from 'react';
export function useAsyncEffect(
effect: () => Promise<void>,
effect: () => Promise<void | (() => void)>,
deps: React.DependencyList,
) {
const callback = useCallback(effect, [...deps]);
useEffect(() => {
effect();
}, [...deps]);
const cleanupPromise = callback();
return () => {
if (cleanupPromise instanceof Promise) {
cleanupPromise.then(cleanup => cleanup && cleanup());
}
};
}, [callback]);
}