首页 > 其他分享 >electron-store 中文文档

electron-store 中文文档

时间:2024-08-09 18:28:05浏览次数:8  
标签:set const Electron electron 文档 store Store

electron-store

简介

为您的Electron应用或模块提供简单的数据持久化功能 —— 保存和加载用户设置、应用状态、缓存等。

Electron本身没有内置的方式来持久化用户设置和其他数据。此模块为您处理这些问题,以便您可以专注于构建应用。数据被保存在一个名为config.json的JSON文件中,位于app.getPath('userData')目录下。

您可以在主进程和渲染进程中直接使用此模块。如果仅在渲染进程中使用,则需要在主进程中调用Store.initRenderer(),或者在主进程中创建一个新的Store实例 (new Store() )。

安装

npm install electron-store

要求Electron版本30或更高。

注意:此包为原生ESM模块,不再提供CommonJS导出。如果您的项目使用CommonJS,您需要将其转换为ESM。更多关于Electron和ESM的信息。请不要为此类问题提交issues。

使用

import Store from 'electron-store';

const store = new Store();

store.set('unicorn', '

标签:set,const,Electron,electron,文档,store,Store
From: https://www.cnblogs.com/China-Dream/p/18351282

相关文章