mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 20:40:15 +02:00
use dev path for local settings store
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import type { TitleTheme } from '/@/shared/types/types';
|
||||
|
||||
import { dialog, ipcMain, nativeTheme, OpenDialogOptions, safeStorage } from 'electron';
|
||||
import { app, dialog, ipcMain, nativeTheme, OpenDialogOptions, safeStorage } from 'electron';
|
||||
import Store from 'electron-store';
|
||||
import path from 'path';
|
||||
|
||||
const getFrame = () => {
|
||||
const isWindows = process.platform === 'win32';
|
||||
@@ -18,10 +19,18 @@ const getFrame = () => {
|
||||
return 'linux';
|
||||
};
|
||||
|
||||
const isDevelopment = process.env.NODE_ENV === 'development';
|
||||
|
||||
const defaultUserDataPath = app.getPath('userData');
|
||||
const storePath = isDevelopment
|
||||
? path.normalize(`${defaultUserDataPath}-dev`)
|
||||
: path.normalize(defaultUserDataPath);
|
||||
|
||||
export const store = new Store<any>({
|
||||
beforeEachMigration: (_store, context) => {
|
||||
console.log(`settings migrate from ${context.fromVersion} → ${context.toVersion}`);
|
||||
},
|
||||
cwd: storePath,
|
||||
defaults: {
|
||||
disable_auto_updates: false,
|
||||
enableNeteaseTranslation: false,
|
||||
@@ -52,7 +61,11 @@ ipcMain.handle('settings-get', (_event, data: { property: string }) => {
|
||||
});
|
||||
|
||||
ipcMain.on('settings-set', (__event, data: { property: string; value: any }) => {
|
||||
store.set(`${data.property}`, data.value);
|
||||
if (data.value === undefined) {
|
||||
store.delete(data.property);
|
||||
} else {
|
||||
store.set(data.property, data.value);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('password-get', (_event, server: string): null | string => {
|
||||
|
||||
Reference in New Issue
Block a user