Skip to content

Commit

Permalink
fix: electron store
Browse files Browse the repository at this point in the history
  • Loading branch information
aleganza committed May 1, 2024
1 parent 49969a4 commit 158c6f6
Show file tree
Hide file tree
Showing 18 changed files with 841 additions and 638 deletions.
11 changes: 11 additions & 0 deletions .erb/configs/webpack.config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ const configuration: webpack.Configuration = {
* Determine the array of extensions that should be used to resolve modules.
*/
resolve: {
fallback: {
fs: false,
tls: false,
net: false,
path: false,
zlib: false,
http: false,
https: false,
stream: false,
crypto: false,
},
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
modules: [webpackPaths.srcPath, 'node_modules'],
// There is no need to add aliases here, the paths in tsconfig get mirrored
Expand Down
Binary file modified assets/icon/icon.xcf
Binary file not shown.
50 changes: 49 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@
"electron-store": "^8.2.0",
"electron-updater": "^6.1.4",
"hls.js": "^1.5.8",
"path": "^0.12.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.16.0"
"react-router-dom": "^6.16.0",
"stream": "^0.0.2"
},
"devDependencies": {
"@electron/notarize": "^2.1.0",
Expand Down
13 changes: 8 additions & 5 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import MenuBuilder from './menu';
import { resolveHtmlPath } from './util';

const store = new Store();
ipcMain.on('electron-store-get', async (event, val) => {
event.returnValue = store.get(val);
});
ipcMain.on('electron-store-set', async (event, key, val) => {
store.set(key, val);
});
// const authUrl = `https://anilist.co/api/v2/oauth/authorize?client_id=${clientData.clientId}&redirect_uri=${(isAppImage || !(app.isPackaged)) ? clientData.redirectUriAppImage : clientData.redirectUri}&response_type=code`;
// const githubOpenNewIssueUrl = 'https://github.com/aleganza/akuse/issues/new';
// autoUpdater.autoDownload = false;
Expand Down Expand Up @@ -90,14 +96,11 @@ const createWindow = async () => {
},
icon: getAssetPath('icon.png'),
webPreferences: {
nodeIntegration: true,
preload: app.isPackaged
? path.join(__dirname, 'preload.js')
: path.join(__dirname, '../../.erb/dll/preload.js'),
},
// webPreferences: {
// nodeIntegration: true,
// contextIsolation: false
// }
}
});

mainWindow.loadURL(resolveHtmlPath('index.html'));
Expand Down
9 changes: 9 additions & 0 deletions src/main/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ const electronHandler = {
ipcRenderer.once(channel, (_event, ...args) => func(...args));
},
},
store: {
get(key: any) {
return ipcRenderer.sendSync('electron-store-get', key);
},
set(property: any, val: any) {
ipcRenderer.send('electron-store-set', property, val);
},
// Other method you want to add like has(), reset(), etc.
},
};

contextBridge.exposeInMainWorld('electron', electronHandler);
Expand Down
Loading

0 comments on commit 158c6f6

Please sign in to comment.