我希望能够在基于 Electron 的实用程序(例如启动器和文件检查器)中显示系统级应用程序和文件图标。 Electron 或 Node.js 应用程序是否有访问系统级图标的标准方法?
我查看了 Electron 文档,我看到的最接近的是 represented files 的条目在 macOS 中,但我还没有看到任何有关通过 Electron API 公开系统级图标的信息。
如果有一个标准的跨平台 Electron 或 Node.js API 用于加载特定应用程序和文件的系统级图标资源,我很想知道。如果做不到这一点,我欢迎使用其他 Electron 或 Node.js API 读取图标资源的建议。
编辑:这是一个潜在相关(尽管特定于平台)的问题:Display .icns file in electron renderer process
最佳答案
最明显的 Electron API 函数是 app.getFileIcon但它似乎只能为应用程序和文档提供通用图标,这对于您的应用程序来说可能足够好,也可能不够......
app.getFileIcon(path[, options], callback)
path String options Object (optional) size String small - 16x16 normal - 32x32 large - 48x48 on Linux, 32x32 on Windows, unsupported on macOS. callback Function error Error icon NativeImage
Fetches a path's associated icon.
On Windows, there a 2 kinds of icons:
Icons associated with certain file extensions, like .mp3, .png, etc. Icons inside the file itself, like .exe, .dll, .ico.
On Linux and macOS, icons depend on the application associated with file mime type.
关于node.js - Electron 或 Node.js 应用程序是否有访问系统级图标的标准方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55579879/