Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ out
/.idea
/coverage/
/json/
*.vpy
*.lwi
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "vset",
"productName": "VSET",
"version": "4.3.6",
"type": "module",
"version": "4.4.1",
"description": "VSET",
"author": "NangInShell",
"main": "./out/main/index.js",
Expand Down
Binary file modified resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions src/main/childProcessManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ function safeUnpipe(): void {
vspipe.proc.stdout.unpipe(ffmpeg.proc.stdin)
}
catch {}
try {
ffmpeg.proc.stdin.end()
}
catch {}
}
}

Expand Down
24 changes: 19 additions & 5 deletions src/main/getCorePath.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { TaskConfig } from '@shared/type/taskConfig'
import { existsSync, mkdirSync } from 'node:fs'
import path from 'node:path'
import { app } from 'electron'

Expand All @@ -19,13 +20,14 @@ export function getCorePath(): string {

/**
* 获取 VSET-core 中的可执行文件路径
* @returns {object} 包含 vspipe、ffmpeg 和 ffprobe 的路径
* @returns {object} 包含 vspipe、ffmpeg、ffprobemediainfo 的路径
*/
export function getExecPath(): { vspipe: string, ffmpeg: string, ffprobe: string } {
export function getExecPath(): { vspipe: string, ffmpeg: string, ffprobe: string, mediainfo: string } {
return {
vspipe: path.join(getCorePath(), 'VSPipe.exe'),
ffmpeg: path.join(getCorePath(), 'ffmpeg.exe'),
ffprobe: path.join(getCorePath(), 'ffprobe.exe'),
mediainfo: path.join(getCorePath(), 'MediaInfo.exe'),
}
}

Expand All @@ -36,6 +38,18 @@ export function getExtraSRModelPath(): string {
return path.join(getCorePath(), 'vs-coreplugins', 'models', 'VSET_ExtraSrModel')
}

function ensureVpyDir(): string {
const dir = process.env.NODE_ENV === 'development'
? path.join(app.getAppPath(), 'resources', 'vpyFile')
: path.join(app.getAppPath(), '..', 'vpyFile')

if (!existsSync(dir)) {
mkdirSync(dir, { recursive: true })
}

return dir
}

/**
* 获取 VSET 生成的设置文件路径
* 暂时存放在 outputfolder 目录下
Expand All @@ -46,8 +60,8 @@ export function getGenSettingsPath(taskConfig: TaskConfig): string {

/**
* 获取 VSET 生成的 vpy 文件路径
* 暂时存放在 outputfolder 目录下
* 存放在软件 vpyFile 目录下
*/
export function getGenVpyPath(taskConfig: TaskConfig, baseName: string): string {
return path.join(taskConfig.outputFolder, `${baseName}.vpy`)
export function getGenVpyPath(_taskConfig: TaskConfig, baseName: string): string {
return path.join(ensureVpyDir(), `${baseName}.vpy`)
}
24 changes: 23 additions & 1 deletion src/main/getSystemInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { readdir } from 'node:fs/promises'
import si from 'systeminformation'
import { getExtraSRModelPath } from './getCorePath'

export async function getGpuInfo(): Promise<Array<string>> {
const deviceList: Array<string> = []
Expand All @@ -11,6 +13,26 @@ export async function getGpuInfo(): Promise<Array<string>> {

export async function getCpuInfo(): Promise<string> {
const cpu = await si.cpu()

return cpu.brand
}

export async function getMemoryInfo(): Promise<string> {
const mem = await si.mem()
const totalGB = (mem.total / (1024 * 1024 * 1024)).toFixed(2)
return `${totalGB} GB`
}

export async function getExtraSRModelList(): Promise<Array<string>> {
const modelDir = getExtraSRModelPath()
try {
const files = await readdir(modelDir)
// 过滤出 .onnx 文件并去掉扩展名
return files
.filter(file => file.endsWith('.onnx'))
.map(file => file.replace('.onnx', ''))
}
catch (error) {
console.error('Error reading extra SR model directory:', error)
return []
}
}
34 changes: 28 additions & 6 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,47 @@ import { IpcChannelInvoke, IpcChannelSend } from '@shared/constant/ipc'
import { app, BrowserWindow, ipcMain, nativeImage, shell } from 'electron'
import appIcon from '../../resources/icon.png?asset'
import { killAllProcesses } from './childProcessManager'
import { getCpuInfo, getGpuInfo } from './getSystemInfo'
import { getCpuInfo, getExtraSRModelList, getGpuInfo, getMemoryInfo } from './getSystemInfo'
import { openDirectory } from './openDirectory'
import { preview, previewFrame } from './previewOutput'
import { PauseCommand, runCommand } from './runCommand'
import { writeSettingsJson } from './writeFile'

function createWindow(): BrowserWindow {
const mainWindow = new BrowserWindow({
width: 900,
height: 700,
minWidth: 900,
minHeight: 670,
width: 1000,
height: 875,
minWidth: 1000,
minHeight: 875,
show: false,
autoHideMenuBar: true,
frame: false,
resizable: true,
icon: nativeImage.createFromPath(appIcon),
title: 'VSET 4.3.6',
webPreferences: {
preload: path.join(__dirname, '../preload/index.js'),
sandbox: false,
},
})

// ipcMain

ipcMain.on('window:minimize', () => {
mainWindow?.minimize()
})

ipcMain.on('window:maximize', () => {
if (mainWindow?.isMaximized()) {
mainWindow.unmaximize()
}
Comment on lines +37 to +39

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

mainWindow.unmaximize() 的调用与 else 块中的 mainWindow?.maximize() 在可选链操作符 ?. 的使用上不一致。虽然在这里是安全的,但保持一致的风格可以提高代码的可读性和健壮性。

Suggested change
if (mainWindow?.isMaximized()) {
mainWindow.unmaximize()
}
if (mainWindow?.isMaximized()) {
mainWindow?.unmaximize()
}

else {
mainWindow?.maximize()
}
})

ipcMain.on('window:close', () => {
mainWindow?.close()
})
ipcMain.on(IpcChannelSend.EXECUTE_COMMAND, runCommand)

ipcMain.on(IpcChannelSend.PAUSE, PauseCommand)
Expand All @@ -45,6 +63,10 @@ function createWindow(): BrowserWindow {

ipcMain.handle(IpcChannelInvoke.GET_CPU_INFO, getCpuInfo)

ipcMain.handle(IpcChannelInvoke.GET_MEMORY_INFO, getMemoryInfo)

ipcMain.handle(IpcChannelInvoke.GET_EXTRA_SR_MODEL_LIST, getExtraSRModelList)

// mainWindow
mainWindow.on('ready-to-show', () => {
mainWindow?.show()
Expand Down
Loading
Loading