直接从应用程序中删除mac electronic应用程序时如何清除用户数据? [英] how to clear user data while delete mac electron app from application directly?
问题描述
在删除macos electronic应用程序时如何删除用户数据?看来我们需要编写一个守护程序来侦听文件夹的更改,但是该怎么办?您是否有更清晰或更轻松的方法来处理它?</p>
包装用过的电子助剂.
我使用 electron-localstorage
在应用程序中设置一个标志,而每次启动应用程序时,都会检查该标志是否可以获取如果不是,则是从应用程序中安装的,这是新安装并首次打开,因此它将清除旧的用户数据.
const userDataPath = app.getPath('userData');const storage = require('electron-localstorage');if(platform.isMac&!isDevelopment){storage.setStoragePath(path.join(__ dirname,'../data.json'));让item = storage.getItem('opened');if(!item){rimraf(`$ {userDataPath}`,()=> {console.log('清除用户数据路径已完成!')})}storage.setItem('opened','true');}
how to delete user data while deleting the macos electron app? 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.
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');
}
这篇关于直接从应用程序中删除mac electronic应用程序时如何清除用户数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!