2023-01-20 15:33:26 +01:00
|
|
|
import Store from "electron-store"
|
2024-01-05 16:53:00 +01:00
|
|
|
import { isMac } from "./detect-platform"
|
2023-01-20 15:33:26 +01:00
|
|
|
|
2023-07-04 12:16:26 +02:00
|
|
|
const isDev = !!process.env.VITE_DEV_SERVER_URL
|
|
|
|
|
2023-01-20 15:33:26 +01:00
|
|
|
const schema = {
|
|
|
|
additionalProperties: false,
|
|
|
|
|
|
|
|
windowConfig: {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
width: {type: "number"},
|
|
|
|
height: {type: "number"},
|
|
|
|
x: {type: "number"},
|
|
|
|
y: {type: "number"},
|
|
|
|
isMaximized: {type: "boolean"},
|
|
|
|
isFullScreen: {type: "boolean"},
|
|
|
|
},
|
|
|
|
additionalProperties: false,
|
|
|
|
},
|
2023-01-27 17:18:31 +01:00
|
|
|
|
|
|
|
settings: {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
"keymap": { "enum": ["default", "emacs"], default:"default" },
|
|
|
|
"emacsMetaKey": { "enum": [null, "alt", "meta"], default: null },
|
|
|
|
"showLineNumberGutter": {type: "boolean", default:true},
|
|
|
|
"showFoldGutter": {type: "boolean", default:true},
|
2023-12-28 16:48:56 +01:00
|
|
|
"autoUpdate": {type: "boolean", default: true},
|
2023-12-07 00:42:29 +01:00
|
|
|
"allowBetaVersions": {type: "boolean", default: false},
|
2023-12-10 22:59:42 +01:00
|
|
|
"enableGlobalHotkey": {type: "boolean", default: false},
|
2023-12-11 14:30:26 +01:00
|
|
|
"globalHotkey": {type: "string", default: "CmdOrCtrl+Shift+H"},
|
2023-12-23 11:17:13 +01:00
|
|
|
"bufferPath" : {type: "string", default: ""},
|
2024-01-01 20:02:30 +01:00
|
|
|
"showInDock": {type: "boolean", default: true},
|
|
|
|
"showInMenu": {type: "boolean", default: false},
|
2024-01-04 14:52:41 +01:00
|
|
|
"bracketClosing": {type: "boolean", default: false},
|
2023-01-27 17:18:31 +01:00
|
|
|
},
|
2023-03-09 09:46:21 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
theme: {type: "string", default: "system"},
|
2023-03-20 11:09:56 +01:00
|
|
|
|
|
|
|
currency: {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
data: {type: "object"},
|
|
|
|
timeFetched: {type: "number"},
|
|
|
|
},
|
|
|
|
},
|
2023-01-27 17:18:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const defaults = {
|
|
|
|
settings: {
|
|
|
|
keymap: "default",
|
2024-01-05 16:53:00 +01:00
|
|
|
emacsMetaKey: isMac ? "meta" : "alt",
|
2023-01-27 17:18:31 +01:00
|
|
|
showLineNumberGutter: true,
|
|
|
|
showFoldGutter: true,
|
2023-12-28 16:48:56 +01:00
|
|
|
autoUpdate: true,
|
2023-12-07 00:42:29 +01:00
|
|
|
allowBetaVersions: false,
|
2023-12-10 22:59:42 +01:00
|
|
|
enableGlobalHotkey: false,
|
2023-12-11 14:30:26 +01:00
|
|
|
globalHotkey: "CmdOrCtrl+Shift+H",
|
2023-12-23 11:17:13 +01:00
|
|
|
bufferPath: "",
|
2024-01-01 20:02:30 +01:00
|
|
|
showInDock: true,
|
|
|
|
showInMenu: false,
|
2024-01-04 14:52:41 +01:00
|
|
|
bracketClosing: false,
|
2023-03-09 09:46:21 +01:00
|
|
|
},
|
|
|
|
theme: "system",
|
2023-01-20 15:33:26 +01:00
|
|
|
}
|
|
|
|
|
2023-07-04 12:16:26 +02:00
|
|
|
export default new Store({schema, defaults, name: isDev ? "config-dev" : "config"})
|