feat: 增加 getFileIcon api

This commit is contained in:
muwoo 2023-05-26 09:43:06 +08:00
parent 971ad0e3e2
commit de7fee6a23
3 changed files with 11 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "rubick", "name": "rubick",
"version": "2.2.5", "version": "2.2.6",
"author": "muwoo <2424880409@qq.com>", "author": "muwoo <2424880409@qq.com>",
"private": true, "private": true,
"scripts": { "scripts": {

View File

@ -41,7 +41,7 @@ window.rubick = {
ipcSendSync('showMainWindow'); ipcSendSync('showMainWindow');
}, },
showOpenDialog(options) { showOpenDialog(options) {
ipcSendSync('showOpenDialog', options); return ipcSendSync('showOpenDialog', options);
}, },
setExpendHeight(height) { setExpendHeight(height) {
ipcSendSync('setExpendHeight', height); ipcSendSync('setExpendHeight', height);
@ -162,4 +162,8 @@ window.rubick = {
shellBeep: () => { shellBeep: () => {
ipcSend('shellBeep'); ipcSend('shellBeep');
}, },
getFileIcon: (path) => {
return ipcSendSync('getFileIcon', { path });
},
}; };

View File

@ -110,7 +110,7 @@ class API {
} }
public showOpenDialog({ data }, window) { public showOpenDialog({ data }, window) {
dialog.showOpenDialogSync(window, data); return dialog.showOpenDialogSync(window, data);
} }
public setExpendHeight({ data: height }, window: BrowserWindow, e) { public setExpendHeight({ data: height }, window: BrowserWindow, e) {
@ -307,6 +307,10 @@ class API {
shell.showItemInFolder(data.path); shell.showItemInFolder(data.path);
return true; return true;
} }
public async getFileIcon({ data }) {
const nativeImage = await app.getFileIcon(data.path, { size: 'normal' });
return nativeImage.toDataURL();
}
public shellBeep() { public shellBeep() {
shell.beep(); shell.beep();