fix: TS errors
This commit is contained in:
@@ -176,7 +176,7 @@ export const ProfileItem = (props: Props) => {
|
||||
|
||||
// 订阅定时器更新事件
|
||||
useEffect(() => {
|
||||
let refreshTimeout: ReturnType<typeof setTimeout> | undefined;
|
||||
let refreshTimeout: number | undefined;
|
||||
// 处理定时器更新事件 - 这个事件专门用于通知定时器变更
|
||||
const handleTimerUpdate = (event: Event) => {
|
||||
const source = event as CustomEvent<string> & { payload?: string };
|
||||
@@ -185,7 +185,7 @@ export const ProfileItem = (props: Props) => {
|
||||
// 只有当更新的是当前配置时才刷新显示
|
||||
if (updatedUid === itemData.uid && showNextUpdate) {
|
||||
console.log(`收到定时器更新事件: uid=${updatedUid}`);
|
||||
if (refreshTimeout) {
|
||||
if (refreshTimeout !== undefined) {
|
||||
clearTimeout(refreshTimeout);
|
||||
}
|
||||
refreshTimeout = window.setTimeout(() => {
|
||||
@@ -198,7 +198,7 @@ export const ProfileItem = (props: Props) => {
|
||||
window.addEventListener("verge://timer-updated", handleTimerUpdate);
|
||||
|
||||
return () => {
|
||||
if (refreshTimeout) {
|
||||
if (refreshTimeout !== undefined) {
|
||||
clearTimeout(refreshTimeout);
|
||||
}
|
||||
// 清理事件监听
|
||||
|
||||
@@ -151,7 +151,7 @@ export const ProxiesEditorViewer = (props: Props) => {
|
||||
const lines = uris.trim().split("\n");
|
||||
let idx = 0;
|
||||
const batchSize = 50;
|
||||
let parseTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
let parseTimer: number | undefined;
|
||||
|
||||
const parseBatch = () => {
|
||||
const end = Math.min(idx + batchSize, lines.length);
|
||||
@@ -175,7 +175,7 @@ export const ProxiesEditorViewer = (props: Props) => {
|
||||
if (idx < lines.length) {
|
||||
parseTimer = window.setTimeout(parseBatch, 0);
|
||||
} else {
|
||||
if (parseTimer) {
|
||||
if (parseTimer !== undefined) {
|
||||
clearTimeout(parseTimer);
|
||||
parseTimer = undefined;
|
||||
}
|
||||
@@ -238,7 +238,7 @@ export const ProxiesEditorViewer = (props: Props) => {
|
||||
}
|
||||
};
|
||||
let idleId: number | undefined;
|
||||
let timeoutId: ReturnType<typeof setTimeout> | undefined;
|
||||
let timeoutId: number | undefined;
|
||||
if (window.requestIdleCallback) {
|
||||
idleId = window.requestIdleCallback(serialize);
|
||||
} else {
|
||||
@@ -248,7 +248,7 @@ export const ProxiesEditorViewer = (props: Props) => {
|
||||
if (idleId !== undefined && window.cancelIdleCallback) {
|
||||
window.cancelIdleCallback(idleId);
|
||||
}
|
||||
if (timeoutId) {
|
||||
if (timeoutId !== undefined) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -355,7 +355,7 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
}
|
||||
};
|
||||
let idleId: number | undefined;
|
||||
let timeoutId: ReturnType<typeof setTimeout> | undefined;
|
||||
let timeoutId: number | undefined;
|
||||
if (window.requestIdleCallback) {
|
||||
idleId = window.requestIdleCallback(serialize);
|
||||
} else {
|
||||
@@ -365,7 +365,7 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
if (idleId !== undefined && window.cancelIdleCallback) {
|
||||
window.cancelIdleCallback(idleId);
|
||||
}
|
||||
if (timeoutId) {
|
||||
if (timeoutId !== undefined) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user