Trên GitHub, electron-userland/electron-json-storage đã đạt 1.4k sao, ngôn ngữ JavaScript. :package: Easily write and read user settings in Electron apps
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Easily write and read user settings in Electron apps
Electron lacks an easy way to persist and read user settings for your application. electron-json-storage implements an API somewhat similar to localStorage to write and read JSON objects to/from the operating system application data directory, as defined by app.getPath('userData').
Related modules:
electron-settings
electron-store
electron-storage
Installation
Install electron-json-storage by running:
$ npm install --save electron-json-storage
You can require this module from either the main or renderer process (with and without remote).
Running on Electron >10 renderer processes
When loaded in renderer processes, this module will try to make use of
electron.remote in order to fetch the userData path.
Electron 10 now defaults enableRemoteModule to
false,
which means that electron-json-storage will be able to calculate a data path by default.
The solution is to manually call storage.setDataPath() before reading or
writing any values or setting enableRemoteModule to true.
Documentation
storage
.getDefaultDataPath() ⇒ String | Null
.setDataPath(directory)
.getDataPath() ⇒ String
.get(key, [options], callback)
.getSync(key, [options])
.getMany(keys, [options], callback)
.getAll([options], callback)
.set(key, json, [options], callback)
.has(key, [options], callback)
.keys([options], callback)
.remove(key, [options], callback)
.clear([options], callback)
storage.getDefaultDataPath() ⇒ String | Null
This function will return null when running in the
renderer process without support for the remote IPC
mechanism. You have to explicitly set a data path using
.setDataPath() in these cases.
Kind: static method of storage Summary: Get the default data path Returns: String | Null - default data path Access: public Example
If the key doesn't exist in the user data, an empty object is returned.
Also notice that the .json extension is added automatically, but it's
ignored if you pass it yourself.
Passing an extension other than .json will result in a file created
with both extensions. For example, the key foo.data will result in a file
called foo.data.json.
Kind: static method of storage Summary: Read user data Access: public
Kind: static method of storage Summary: Check if a key exists Access: public
Param
Type
Description
key
String
key
[options]
Object
options
[options.dataPath]
String
data path
callback
function
callback (error, hasKey)
Example
const storage = require('electron-json-storage');
storage.has('foobar', function(error, hasKey) {
if (error) throw error;
if (hasKey) {
console.log('There is data stored as `foobar`');
}
});
storage.keys([options], callback)
Kind: static method of storage Summary: Get the list of saved keys Access: public
Param
Type
Description
[options]
Object
options
[options.dataPath]
String
data path
callback
function
callback (error, keys)
Example
const storage = require('electron-json-storage');
storage.keys(function(error, keys) {
if (error) throw error;
for (var key of keys) {
console.log('There is a key called: ' + key);
}
});
storage.remove(key, [options], callback)
Notice this function does nothing, nor throws any error
if the key doesn't exist.
Kind: static method of storage Summary: Remove a key Access: public
Đọc thêm về electron-userland/electron-json-storage ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/electron-userland/electron-json-storage là nguồn chính thức.
electron-userland/electron-json-storage có bao nhiêu sao?
electron-userland/electron-json-storage có 1.4k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/electron-userland/electron-json-storage. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
electron-userland/electron-json-storage có những chủ đề gì?
GitHub topics của electron-userland/electron-json-storage: "electron", "json", "settings", "storage". TopGit xếp repo vào nhóm mã nguồn mở.
electron-userland/electron-json-storage còn đang phát triển không?
Commit gần nhất trên electron-userland/electron-json-storage là 3.2 năm trước (theo timestamp GitHub). Repo có 75 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
electron-userland/electron-json-storage viết bằng ngôn ngữ gì?
electron-userland/electron-json-storage chủ yếu viết bằng JavaScript. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về electron-json-storage?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về electron-json-storage.