Skip to content

Commit

Permalink
feat: 增加 getFileIcon api
Browse files Browse the repository at this point in the history
  • Loading branch information
muwoo committed May 26, 2023
1 parent 971ad0e commit de7fee6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rubick",
"version": "2.2.5",
"version": "2.2.6",
"author": "muwoo <[email protected]>",
"private": true,
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion public/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ window.rubick = {
ipcSendSync('showMainWindow');
},
showOpenDialog(options) {
ipcSendSync('showOpenDialog', options);
return ipcSendSync('showOpenDialog', options);
},
setExpendHeight(height) {
ipcSendSync('setExpendHeight', height);
Expand Down Expand Up @@ -162,4 +162,8 @@ window.rubick = {
shellBeep: () => {
ipcSend('shellBeep');
},

getFileIcon: (path) => {
return ipcSendSync('getFileIcon', { path });
},
};
6 changes: 5 additions & 1 deletion src/main/common/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit de7fee6

Please sign in to comment.