mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 10:00:17 +05:30
refactor(main): create src/main/{store,index}.js glue layer; new entrypoint at src/main/index.js
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
||||
"name": "markdown-converter",
|
||||
"version": "4.4.2",
|
||||
"description": "Professional Markdown editor and universal file converter with PDF editing, batch processing, and syntax highlighting",
|
||||
"main": "src/main.js",
|
||||
"main": "src/main/index.js",
|
||||
"scripts": {
|
||||
"start": "electron .",
|
||||
"test": "jest",
|
||||
|
||||
+3
-3422
File diff suppressed because it is too large
Load Diff
+3401
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
||||
// src/main/store.js
|
||||
// Simple JSON-file preferences store (replaces electron-store)
|
||||
|
||||
const { app } = require('electron');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const settingsPath = path.join(app.getPath('userData'), 'settings.json');
|
||||
|
||||
const store = {
|
||||
get(key, defaultValue) {
|
||||
try {
|
||||
const data = fs.readFileSync(settingsPath, 'utf-8');
|
||||
const settings = JSON.parse(data);
|
||||
return settings[key] !== undefined ? settings[key] : defaultValue;
|
||||
} catch {
|
||||
return defaultValue;
|
||||
}
|
||||
},
|
||||
set(key, value) {
|
||||
let settings = {};
|
||||
try {
|
||||
const data = fs.readFileSync(settingsPath, 'utf-8');
|
||||
settings = JSON.parse(data);
|
||||
} catch {}
|
||||
settings[key] = value;
|
||||
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = store;
|
||||
Reference in New Issue
Block a user