-
-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow specifying angle backend
- Loading branch information
1 parent
d7f3f11
commit 1e5b887
Showing
4 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { app } from 'electron' | ||
import { join } from 'node:path' | ||
import { writeFileSync, readFileSync } from 'node:fs' | ||
|
||
class Store { | ||
constructor (configName, defaults) { | ||
this.path = join(app.getPath('userData'), configName + '.json') | ||
|
||
this.data = parseDataFile(this.path, defaults) | ||
} | ||
|
||
get (key) { | ||
return this.data[key] | ||
} | ||
|
||
set (key, val) { | ||
this.data[key] = val | ||
writeFileSync(this.path, JSON.stringify(this.data)) | ||
} | ||
} | ||
|
||
function parseDataFile (filePath, defaults) { | ||
try { | ||
return { ...defaults, ...JSON.parse(readFileSync(filePath).toString()) } | ||
} catch (error) { | ||
return defaults | ||
} | ||
} | ||
|
||
export default new Store('settings', { angle: 'default' }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters