From de7fee6a23030458f06ac62b82dbd7e1569040c9 Mon Sep 17 00:00:00 2001 From: muwoo <2424880409@qq.com> Date: Fri, 26 May 2023 09:43:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20getFileIcon=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- public/preload.js | 6 +++++- src/main/common/api.ts | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) 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();