将文件夹添加到收藏夹并更改文件夹图标[Electron macOS] [英] Add folder to favorites and change folder icon [Electron macOS]

查看:237
本文介绍了将文件夹添加到收藏夹并更改文件夹图标[Electron macOS]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个星期以来,我一直在寻找一种解决方案,将带有特定图标的文件夹添加到收藏夹侧边栏(就像Dropbox一样)

Since one week I'm looking for a solution to add a folder with a specific icon to the favorites sidebar (like Dropbox does it)

电子或物镜C是否有解决方案?

Is there any solution to do this with Electron or Objective C?

到目前为止我发现的东西:

What I've found so far:

  • drag & drop it by yourself
  • fileicon
  • Programmatically add a folder to "Places" in Finder (don't know if I can extend electron)

推荐答案

好,我已经找到了以下解决方案:

Ok I've found this solution:

在macOS上,您可以找到此文件夹 ~/Library/Application Support/com.apple.sharedfilelist/ 它包含一些* .sfl文件.您可以使用此工具/usr/bin/sfltool编辑它们. (它已自动安装在您的Mac > = 10.11 El Capitan 上)

On macOS you can find this Folder ~/Library/Application Support/com.apple.sharedfilelist/ It contents some *.sfl files. You can edit them with this tool /usr/bin/sfltool. (It's installed on your mac >= 10.11 El Capitan automatically)

将文件夹添加到收藏夹的示例:

Example to add a folder to your favorites:

/usr/bin/sfltool add-item com.apple.LSSharedFileList.FavoriteItems file:///YOURPATH

我可以在电子应用程序中通过require('child_process').exec运行此命令,并使用fileicon模块添加文件夹图标. ( https://www.npmjs.com/package/fileicon )

I can run this command via require('child_process').exec in my electron app and add a folder icon with the fileicon module. (https://www.npmjs.com/package/fileicon)

这有点脏,但是我不知道其他解决方案.

This is a little bit dirty, but I don't know an other solution.

[更新] :阅读第一条评论

这篇关于将文件夹添加到收藏夹并更改文件夹图标[Electron macOS]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆