feat: Update Electron Download types (#1621)

* feat: Update Electron Download types

* Fix vite rollup

---------

Co-authored-by: Oto Ciulis <oto.ciulis@gmail.com>
Co-authored-by: huchenlei <huchenlei@proton.me>
This commit is contained in:
oto-ciulis-tt
2024-11-20 17:34:27 -08:00
committed by GitHub
parent c857e7d98c
commit 94f5031f0d
4 changed files with 22 additions and 18 deletions

9
package-lock.json generated
View File

@@ -9,7 +9,7 @@
"version": "1.4.5",
"dependencies": {
"@atlaskit/pragmatic-drag-and-drop": "^1.3.1",
"@comfyorg/comfyui-electron-types": "^0.2.16",
"@comfyorg/comfyui-electron-types": "^0.3.1",
"@comfyorg/litegraph": "^0.8.31",
"@primevue/themes": "^4.0.5",
"@vueuse/core": "^11.0.0",
@@ -1917,10 +1917,9 @@
"dev": true
},
"node_modules/@comfyorg/comfyui-electron-types": {
"version": "0.2.16",
"resolved": "https://registry.npmjs.org/@comfyorg/comfyui-electron-types/-/comfyui-electron-types-0.2.16.tgz",
"integrity": "sha512-Hm6NeyMK4sd2V5AyOnvfI+tvCsXr5NBG8wOZlWyyD17ADpbQnpm6qPMWzvm4vCp/YvTR7cUbDGiY0quhofuQGg==",
"license": "GPL-3.0-only"
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@comfyorg/comfyui-electron-types/-/comfyui-electron-types-0.3.2.tgz",
"integrity": "sha512-3vpAAZq4rNd6oUFvX5s1kor2U7xN3Br8gftdO40IvhLLikttK2cZhPra6YlnzuYIU1gK+PBGEJClvjFnQyIYlA=="
},
"node_modules/@comfyorg/litegraph": {
"version": "0.8.31",

View File

@@ -72,7 +72,7 @@
},
"dependencies": {
"@atlaskit/pragmatic-drag-and-drop": "^1.3.1",
"@comfyorg/comfyui-electron-types": "^0.2.16",
"@comfyorg/comfyui-electron-types": "^0.3.1",
"@comfyorg/litegraph": "^0.8.31",
"@primevue/themes": "^4.0.5",
"@vueuse/core": "^11.0.0",

View File

@@ -1,13 +1,13 @@
import { ref } from 'vue'
import { defineStore } from 'pinia'
import { isElectron, electronAPI } from '@/utils/envUtil'
import { DownloadState, DownloadStatus } from '@comfyorg/comfyui-electron-types'
export interface ElectronDownload {
url: string
status: 'paused' | 'in_progress' | 'cancelled'
progress: number
savePath: string
filename: string
export interface ElectronDownload
extends Pick<DownloadState, 'url' | 'filename'> {
progress?: number
savePath?: string
status?: DownloadStatus
}
/** Electron donwloads store handler */
@@ -20,15 +20,14 @@ export const useElectronDownloadStore = defineStore('downloads', () => {
const initialize = async () => {
if (isElectron()) {
const allDownloads: ElectronDownload[] =
(await DownloadManager.getAllDownloads()) as unknown as ElectronDownload[]
const allDownloads = await DownloadManager.getAllDownloads()
for (const download of allDownloads) {
downloads.value.push(download)
}
// ToDO: replace with ElectronDownload type
DownloadManager.onDownloadProgress((data: any) => {
DownloadManager.onDownloadProgress((data) => {
if (!findByUrl(data.url)) {
downloads.value.push(data)
}
@@ -51,8 +50,11 @@ export const useElectronDownloadStore = defineStore('downloads', () => {
url,
savePath,
filename
}: Pick<ElectronDownload, 'url' | 'savePath' | 'filename'>) =>
DownloadManager.startDownload(url, savePath, filename)
}: {
url: string
savePath: string
filename: string
}) => DownloadManager.startDownload(url, savePath, filename)
const pause = (url: string) => DownloadManager.pauseDownload(url)
const resume = (url: string) => DownloadManager.resumeDownload(url)
const cancel = (url: string) => DownloadManager.cancelDownload(url)

View File

@@ -150,7 +150,10 @@ export default defineConfig({
rollupOptions: {
// Disabling tree-shaking
// Prevent vite remove unused exports
treeshake: false
treeshake: false,
external: [
'electron'
]
}
},