|
|
@@ -9,11 +9,12 @@ const password = 'skyfffire-password';
|
|
|
const key = crypto.createHash('sha256').update(password).digest();
|
|
|
let memoryCache = {};
|
|
|
|
|
|
-const dataFilePath = path.join(app.getPath('userData'), 'shareSession.json');
|
|
|
-function readData() {
|
|
|
+const loginFilePath = path.join(app.getPath('userData'), 'loginSession.json');
|
|
|
+const symbolFilePath = path.join(app.getPath('userData'), 'symbolSession.json');
|
|
|
+function readData(filePath) {
|
|
|
try {
|
|
|
- if (fs.existsSync(dataFilePath)) {
|
|
|
- const rawData = fs.readFileSync(dataFilePath);
|
|
|
+ if (fs.existsSync(filePath)) {
|
|
|
+ const rawData = fs.readFileSync(filePath);
|
|
|
return JSON.parse(rawData);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
@@ -22,11 +23,11 @@ function readData() {
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
-function writeData(data) {
|
|
|
+function writeData(filePath, data) {
|
|
|
try {
|
|
|
- fs.writeFileSync(dataFilePath, JSON.stringify(data, null, 2));
|
|
|
+ fs.writeFileSync(filePath, JSON.stringify(data, null, 2));
|
|
|
} catch (error) {
|
|
|
- console.error('Error writing data:', error);
|
|
|
+ console.error(`Error writing data to ${filePath}:`, error);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -103,19 +104,19 @@ function createWindow() {
|
|
|
|
|
|
app.whenReady().then(() => {
|
|
|
ipcMain.handle('get-login-info-data', () => {
|
|
|
- return readData();
|
|
|
+ return readData(loginFilePath);
|
|
|
});
|
|
|
|
|
|
ipcMain.handle('set-login-info-data', (event, newData) => {
|
|
|
- writeData(newData);
|
|
|
+ writeData(loginFilePath, newData);
|
|
|
});
|
|
|
|
|
|
ipcMain.handle('get-symbol-data', () => {
|
|
|
- return readData();
|
|
|
+ return readData(symbolFilePath);
|
|
|
});
|
|
|
|
|
|
ipcMain.handle('set-symbol-data', (event, newData) => {
|
|
|
- writeData(newData);
|
|
|
+ writeData(symbolFilePath, newData);
|
|
|
});
|
|
|
});
|
|
|
|