简体   繁体   English

直接从应用程序中删除mac electronic应用程序时如何清除用户数据?

[英]how to clear user data while delete mac electron app from application directly?

how to delete user data while deleting the macos electron app? 删除macos electronic应用程序时如何删除用户数据? It seems we need to write a daemon to listen to the folders change, but how to do? 看来我们需要编写一个守护程序来侦听文件夹的更改,但是该怎么办? do you have more clear or easier methods to handle it? 您有更清晰或更简单的方法来处理它吗?

packaging used electron-builder. 包装中使用了电子助力器。

I use electron-localstorage to set one flag into app, while everytime you start app, which will check if the flag can get from app, if not, this was new installed and opend first time, so it will clear the old userdata. 我使用electron-localstorage在应用程序中设置一个标志,而每次您启动应用程序时,都会检查该标志是否可以从应用程序中获取,如果不能,则是第一次安装并首次打开该标志,因此它将清除旧的用户数据。

const userDataPath = app.getPath('userData');
const storage = require('electron-localstorage');

if(platform.isMac && !isDevelopment) {
  storage.setStoragePath(path.join(__dirname,'../data.json'));
  let item = storage.getItem('opened');
  if(!item) {
    rimraf(`${userDataPath}`, () => {
      console.log('clear user data path done!')
    })
  }
  storage.setItem('opened', 'true');
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将数据从.net应用程序发送到电子应用程序 - Send data from .net application to electron app 如何从 windows 为 electron 应用程序制作 mac 安装程序 - How to make a mac installer for electron app from windows Facebook应用程序 - 如何发送应用程序sugesstion和直接发布在用户walll上 - facebook application - how to send app sugesstion and post directly on user walll 直接从 IDE 运行时,如何禁止我的电子向协议处理程序注册? - how can i prohibit my electron to register with protocol handler while running directly from IDE? 如何从node.js服务器获取数据到Electron应用程序? - How to get data from node.js server into Electron app? 如何从协议链接接收 Electron 应用程序中的数据 - How to receive data in Electron app from protocol link 如何通过 DevTools 访问 Electron 应用程序中的“electron.remote.app”? - How to access `electron.remote.app` in Electron application via DevTools? 如何在捆绑电子应用程序之前对其进行编码(对于Mac)? - How do I code sign an Electron app before bundling it (for Mac)? Electron - 如何从 BrowserWindow 获取授权令牌到主 Electron 应用程序 - Electron - how to get an auth token from BrowserWindow to the main Electron App 如何在电子应用程序中创建数据表 - How to create data tables in an electron app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM