Files
NapCatQQ/.pnpm-store/v3/files/b9/4a6f88de69ad14bdc1229ce0a915c4170a94bd528564e0e0ae087488380e44aa36e2fa21c2ce70036fc1ad3275866aab69161b96a0f117ac9ac81d0abd5fcc
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

46 lines
1.5 KiB
Plaintext

import { __read, __spreadArray } from "tslib";
import { useRef } from 'react';
import useUpdateEffect from '../../../useUpdateEffect';
// support refreshDeps & ready
var useAutoRunPlugin = function (fetchInstance, _a) {
var manual = _a.manual, _b = _a.ready, ready = _b === void 0 ? true : _b, _c = _a.defaultParams, defaultParams = _c === void 0 ? [] : _c, _d = _a.refreshDeps, refreshDeps = _d === void 0 ? [] : _d, refreshDepsAction = _a.refreshDepsAction;
var hasAutoRun = useRef(false);
hasAutoRun.current = false;
useUpdateEffect(function () {
if (!manual && ready) {
hasAutoRun.current = true;
fetchInstance.run.apply(fetchInstance, __spreadArray([], __read(defaultParams), false));
}
}, [ready]);
useUpdateEffect(function () {
if (hasAutoRun.current) {
return;
}
if (!manual) {
hasAutoRun.current = true;
if (refreshDepsAction) {
refreshDepsAction();
}
else {
fetchInstance.refresh();
}
}
}, __spreadArray([], __read(refreshDeps), false));
return {
onBefore: function () {
if (!ready) {
return {
stopNow: true,
};
}
},
};
};
useAutoRunPlugin.onInit = function (_a) {
var _b = _a.ready, ready = _b === void 0 ? true : _b, manual = _a.manual;
return {
loading: !manual && ready,
};
};
export default useAutoRunPlugin;