refactor(desktop): consolidate desktop-electron into desktop package (#25822)

This commit is contained in:
Brendan Allan 2026-05-05 13:43:36 +08:00 committed by GitHub
commit b4147c8d08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
441 changed files with 113 additions and 13439 deletions

View file

@ -0,0 +1,17 @@
import Store from "electron-store"
import { SETTINGS_STORE } from "./constants"
const cache = new Map<string, Store>()
// We cannot instantiate the electron-store at module load time because
// module import hoisting causes this to run before app.setPath("userData", ...)
// in index.ts has executed, which would result in files being written to the default directory
// (e.g. bad: %APPDATA%\@opencode-ai\desktop\opencode.settings vs good: %APPDATA%\ai.opencode.desktop.dev\opencode.settings).
export function getStore(name = SETTINGS_STORE) {
const cached = cache.get(name)
if (cached) return cached
const next = new Store({ name, fileExtension: "", accessPropertiesByDotNotation: false })
cache.set(name, next)
return next
}