diff --git a/package.json b/package.json index 0805b6ef..189e9c46 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rubick", - "version": "2.2.5", + "version": "2.2.6", "author": "muwoo <2424880409@qq.com>", "private": true, "scripts": { diff --git a/public/preload.js b/public/preload.js index 2cf73b02..894c7840 100644 --- a/public/preload.js +++ b/public/preload.js @@ -41,7 +41,7 @@ window.rubick = { ipcSendSync('showMainWindow'); }, showOpenDialog(options) { - ipcSendSync('showOpenDialog', options); + return ipcSendSync('showOpenDialog', options); }, setExpendHeight(height) { ipcSendSync('setExpendHeight', height); @@ -162,4 +162,8 @@ window.rubick = { shellBeep: () => { ipcSend('shellBeep'); }, + + getFileIcon: (path) => { + return ipcSendSync('getFileIcon', { path }); + }, }; diff --git a/src/main/common/api.ts b/src/main/common/api.ts index a6a3f93d..4efc1ed1 100644 --- a/src/main/common/api.ts +++ b/src/main/common/api.ts @@ -110,7 +110,7 @@ class API { } public showOpenDialog({ data }, window) { - dialog.showOpenDialogSync(window, data); + return dialog.showOpenDialogSync(window, data); } public setExpendHeight({ data: height }, window: BrowserWindow, e) { @@ -307,6 +307,10 @@ class API { shell.showItemInFolder(data.path); return true; } + public async getFileIcon({ data }) { + const nativeImage = await app.getFileIcon(data.path, { size: 'normal' }); + return nativeImage.toDataURL(); + } public shellBeep() { shell.beep();