Skip to content

Commit

Permalink
Fixed design bugs and tabs system
Browse files Browse the repository at this point in the history
  • Loading branch information
YomoSK committed May 27, 2024
1 parent 672f066 commit b1fa269
Show file tree
Hide file tree
Showing 10 changed files with 6,275 additions and 883 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Electron Build
on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Setup NodeJs v20
uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm i
- run: npx electron-forge import
- run: npm run make

- name: Upload shipped build as artifact
uses: actions/upload-artifact@v4
with:
name: Yomea
path: out/make/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
out
44 changes: 44 additions & 0 deletions forge.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
const { FuseV1Options, FuseVersion } = require('@electron/fuses');

module.exports = {
packagerConfig: {
asar: true,
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {},
},
{
name: '@electron-forge/maker-zip',
platforms: ['darwin'],
},
{
name: '@electron-forge/maker-deb',
config: {},
},
{
name: '@electron-forge/maker-rpm',
config: {},
},
],
plugins: [
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
},
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
};
30 changes: 19 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const { app, BrowserWindow, WebContentsView, ipcMain } = require('electron');
const path = require('path');
const cheerio = require('cheerio');
const mitt = require('mitt');

const winSize = { width: 1024, height: 600 };

Expand All @@ -24,10 +22,9 @@ function createWindow() {
parent: win,
width: winSize.width,
height: winSize.height,
transparent: true,
frame: false,
transparent: true,
center: true,
resizable: false,
vibrancy: 'under-window',
webPreferences: {
nodeIntegration: true,
Expand All @@ -44,20 +41,23 @@ function createWindow() {
});

const view = new WebContentsView();
// view.setBounds({ width: winSize.width, height: winSize.height - 57, x: 0, y: 57 });
view.webContents.loadURL('about:blank');
view.webContents.on('did-navigate', () => {
const url = view.webContents.getURL();
if(url.includes('about:blank')) return;
topbar.webContents.send('navigate', url);
});
win.setContentView(view);
const contentBounds = win.getContentBounds();
contentBounds.y += 57;
contentBounds.height -= 57;
// win.setContentBounds(contentBounds);
// view.webContents.openDevTools({ mode: 'undocked' });

win.on('resize', () => {
console.log(win.getSize());
topbar.setSize(...win.getSize());
console.log(win.getSize());
topbar.setBounds(win.getBounds());
});
topbar.on('resize', () => {
win.setBounds(topbar.getBounds());
});

ipcMain.on('load-page', (_, url) => {
Expand All @@ -66,8 +66,16 @@ function createWindow() {
});

ipcMain.on('close-app', () => win.close());
ipcMain.on('max-app', () => win.maximize());
ipcMain.on('min-app', () => win.minimize());
ipcMain.on('max-app', () => {
if(win.isMaximized()) {
win.setMaximumSize(...Object.values(winSize));
topbar.setMaximumSize(...Object.values(winSize));
}
else {
win.maximize();
topbar.maximize();
}
});

topbar.on('close', () => app.quit());
}
Expand Down
Loading

0 comments on commit b1fa269

Please sign in to comment.