From 96ff8a778554ce4abcaf25d003efc4f264399675 Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Tue, 18 Mar 2025 11:38:43 -0400 Subject: [PATCH] [TS] Fix ts-strict errors in Vue components (Part 3) (#3126) --- .../LiteGraphCanvasSplitterOverlay.vue | 4 ++-- src/components/install/MigrationPicker.vue | 4 ++-- src/components/maintenance/TaskCard.vue | 4 ++-- src/components/maintenance/TaskListItem.vue | 8 ++++---- .../maintenance/TerminalOutputDrawer.vue | 2 +- .../sidebar/tabs/NodeLibrarySidebarTab.vue | 4 ++-- src/components/sidebar/tabs/QueueSidebarTab.vue | 10 +++++++--- .../sidebar/tabs/modelLibrary/DownloadItem.vue | 16 +++++++++------- .../nodeLibrary/NodeBookmarkTreeExplorer.vue | 2 ++ .../sidebar/tabs/nodeLibrary/NodeTreeLeaf.vue | 5 ++++- src/components/sidebar/tabs/queue/TaskItem.vue | 13 +++++++++---- .../sidebar/tabs/workflows/WorkflowTreeLeaf.vue | 6 +++--- .../templates/TemplateWorkflowsContent.vue | 8 ++++---- src/views/InstallView.vue | 2 +- src/views/ManualConfigurationView.vue | 2 +- src/views/ServerStartView.vue | 2 +- src/views/UserSelectView.vue | 2 +- src/views/templates/BaseViewTemplate.vue | 2 +- 18 files changed, 56 insertions(+), 40 deletions(-) diff --git a/src/components/LiteGraphCanvasSplitterOverlay.vue b/src/components/LiteGraphCanvasSplitterOverlay.vue index 3b4c7c2ca..cc0c5c8d9 100644 --- a/src/components/LiteGraphCanvasSplitterOverlay.vue +++ b/src/components/LiteGraphCanvasSplitterOverlay.vue @@ -2,8 +2,8 @@ sourcePath.value !== '' && pathError.value === '' ) -const validateSource = async (sourcePath: string) => { +const validateSource = async (sourcePath: string | undefined) => { if (!sourcePath) { pathError.value = '' return @@ -109,7 +109,7 @@ const validateSource = async (sourcePath: string) => { pathError.value = '' const validation = await electron.validateComfyUISource(sourcePath) - if (!validation.isValid) pathError.value = validation.error + if (!validation.isValid) pathError.value = validation.error ?? 'ERROR' } catch (error) { console.error(error) pathError.value = t('install.pathValidationFailed') diff --git a/src/components/maintenance/TaskCard.vue b/src/components/maintenance/TaskCard.vue index 6fdd16808..310b4db27 100644 --- a/src/components/maintenance/TaskCard.vue +++ b/src/components/maintenance/TaskCard.vue @@ -74,8 +74,8 @@ const description = computed(() => ) // Use a minimum run time to ensure tasks "feel" like they have run -const reactiveLoading = computed(() => runner.value.refreshing) -const reactiveExecuting = computed(() => runner.value.executing) +const reactiveLoading = computed(() => !!runner.value.refreshing) +const reactiveExecuting = computed(() => !!runner.value.executing) const isLoading = useMinLoadingDurationRef(reactiveLoading, 250) const isExecuting = useMinLoadingDurationRef(reactiveExecuting, 250) diff --git a/src/components/maintenance/TaskListItem.vue b/src/components/maintenance/TaskListItem.vue index c3494dd1e..db4a59317 100644 --- a/src/components/maintenance/TaskListItem.vue +++ b/src/components/maintenance/TaskListItem.vue @@ -71,16 +71,16 @@ const severity = computed(() => ) // Use a minimum run time to ensure tasks "feel" like they have run -const reactiveLoading = computed(() => runner.value.refreshing) -const reactiveExecuting = computed(() => runner.value.executing) +const reactiveLoading = computed(() => !!runner.value.refreshing) +const reactiveExecuting = computed(() => !!runner.value.executing) const isLoading = useMinLoadingDurationRef(reactiveLoading, 250) const isExecuting = useMinLoadingDurationRef(reactiveExecuting, 250) // Popover -const infoPopover = ref() +const infoPopover = ref | null>(null) const toggle = (event: Event) => { - infoPopover.value.toggle(event) + infoPopover.value?.toggle(event) } diff --git a/src/components/maintenance/TerminalOutputDrawer.vue b/src/components/maintenance/TerminalOutputDrawer.vue index b8728afcf..d68f3d06c 100644 --- a/src/components/maintenance/TerminalOutputDrawer.vue +++ b/src/components/maintenance/TerminalOutputDrawer.vue @@ -35,7 +35,7 @@ let xterm: Terminal | null = null // Created and destroyed with the Drawer - contents copied from hidden buffer const terminalCreated = ( { terminal, useAutoSize }: ReturnType, - root: Ref + root: Ref ) => { xterm = terminal useAutoSize({ root, autoRows: true, autoCols: true }) diff --git a/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue b/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue index 831bbbbc5..2a4af87ef 100644 --- a/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue +++ b/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue @@ -26,7 +26,7 @@ class="node-lib-search-box p-2 2xl:p-4" v-model:modelValue="searchQuery" @search="handleSearch" - @show-filter="($event) => searchFilter.toggle($event)" + @show-filter="($event) => searchFilter?.toggle($event)" @remove-filter="onRemoveFilter" :placeholder="$t('g.searchNodes') + '...'" filter-icon="pi pi-filter" @@ -97,7 +97,7 @@ const { expandNode, toggleNodeOnEvent } = useTreeExpansion(expandedKeys) const nodeBookmarkTreeExplorerRef = ref | null>(null) -const searchFilter = ref(null) +const searchFilter = ref | null>(null) const alphabeticalSort = ref(false) const searchQuery = ref('') diff --git a/src/components/sidebar/tabs/QueueSidebarTab.vue b/src/components/sidebar/tabs/QueueSidebarTab.vue index 22f2f7381..741e3a976 100644 --- a/src/components/sidebar/tabs/QueueSidebarTab.vue +++ b/src/components/sidebar/tabs/QueueSidebarTab.vue @@ -194,7 +194,7 @@ const confirmRemoveAll = (event: Event) => { }) } -const menu = ref(null) +const menu = ref | null>(null) const menuTargetTask = ref(null) const menuTargetNode = ref(null) const menuItems = computed(() => [ @@ -213,7 +213,11 @@ const menuItems = computed(() => [ { label: t('g.goToNode'), icon: 'pi pi-arrow-circle-right', - command: () => useLitegraphService().goToNode(menuTargetNode.value?.id), + command: () => { + if (!menuTargetNode.value) return + + useLitegraphService().goToNode(menuTargetNode.value.id) + }, visible: !!menuTargetNode.value } ]) @@ -225,7 +229,7 @@ const handleContextMenu = ({ }: { task: TaskItemImpl event: Event - node?: ComfyNode + node: ComfyNode | null }) => { menuTargetTask.value = task menuTargetNode.value = node diff --git a/src/components/sidebar/tabs/modelLibrary/DownloadItem.vue b/src/components/sidebar/tabs/modelLibrary/DownloadItem.vue index dc9bcec1a..ffd032aa0 100644 --- a/src/components/sidebar/tabs/modelLibrary/DownloadItem.vue +++ b/src/components/sidebar/tabs/modelLibrary/DownloadItem.vue @@ -1,9 +1,9 @@