Skip to content

Commit

Permalink
updated everything!
Browse files Browse the repository at this point in the history
  • Loading branch information
metawave committed Jul 5, 2024
1 parent 2cfe749 commit 07870b9
Show file tree
Hide file tree
Showing 6 changed files with 1,180 additions and 1,153 deletions.
12 changes: 0 additions & 12 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: '20.x'

- name: Build/release Electron app
uses: samuelmeuli/action-electron-builder@v1
Expand Down
11 changes: 11 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";


export default [
{files: ["**/*.{js,mjs,cjs,ts}"]},
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
];
22 changes: 13 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"icons-ico": "./bin/convertToIco KanbanFlowLogo.png resources/icon.ico",
"build": "tsc --outDir ./tsc",
"watch": "tsc -w --outDir ./tsc",
"lint": "eslint -c .eslintrc --ext .ts ./src",
"lint": "eslint ./src",
"start": "yarn build && electron ./tsc/src/main/index.js",
"dist": "yarn build && electron-builder",
"dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null"
Expand Down Expand Up @@ -58,16 +58,20 @@
}
},
"dependencies": {
"electron-store": "^8.0.0",
"electron-updater": "^4.3.0",
"electron-store": "^8.2.0",
"electron-updater": "6.1.8",
"url": "^0.11.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.27.0",
"@typescript-eslint/parser": "^4.27.0",
"electron": "^13.1.0",
"electron-builder": "^23.6.0",
"eslint": "^7.28.0",
"typescript": "^4.3.4"
"@eslint/js": "^9.6.0",
"@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"@typescript-eslint/parser": "^7.15.0",
"electron": "^31.1.0",
"electron-builder": "^24.13.3",
"eslint": "8.57.0",
"globals": "^15.8.0",
"typescript": "^5.5.3",
"typescript-eslint": "^7.15.0"
}
}
62 changes: 40 additions & 22 deletions src/main/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
import { app, screen, shell, BrowserWindow, MenuItemConstructorOptions, Menu, Rectangle, Event } from 'electron';
import { autoUpdater } from 'electron-updater';
import {app, BrowserWindow, Event, Menu, MenuItemConstructorOptions, Rectangle, screen, shell} from 'electron';
import {autoUpdater} from 'electron-updater';
import * as pkg from '../../package.json';
import ElectronStore from 'electron-store';
import Store, {Schema} from 'electron-store';

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow: BrowserWindow;

// Config store for storing some settings
type StoreType = {
zoomFactor: number;
windowConfig: Rectangle;
windowMaximized?: boolean;
}
const conf = new ElectronStore<StoreType>({
name: pkg.name,
defaults: {
zoomFactor: 1.0,
windowConfig: {x: null, y: null, width: 1440, height: 900}
}
const confSchema : Schema<any> = {
zoomFactor: {
type: 'number',
default: 1.0
},
windowX: {
type: 'number',
default: 0
},
windowY: {
type: 'number',
default: 0
},
windowWidth: {
type: 'number',
default: 1440
},
windowHeight: {
type: 'number',
default: 900
},
windowMaximized: {
type: 'boolean',
default: false
}
);
};
const conf = new Store({name: pkg.name, schema: confSchema});

function rectContains(bigRect: Rectangle, smallRect: Rectangle): boolean {
return bigRect.x <= smallRect.x &&
Expand All @@ -30,10 +44,10 @@ function rectContains(bigRect: Rectangle, smallRect: Rectangle): boolean {
}

function getWindowConfig(): Rectangle {
let posX = conf.get('windowConfig').x;
let posY = conf.get('windowConfig').y;
const width = conf.get('windowConfig').width;
const height = conf.get('windowConfig').height;
let posX = conf.get('windowX') as number|undefined;
let posY = conf.get('windowY') as number|undefined;
const width = conf.get('windowWith') as number|undefined;
const height = conf.get('windowHeight') as number|undefined;

// check if window is on a screen
const displays = screen.getAllDisplays();
Expand Down Expand Up @@ -68,7 +82,7 @@ function handleLinkClick(e: Event | undefined, reqUrl: string): void {
function createWindow(): void {

// restore some settings
const zFactor = conf.get('zoomFactor');
const zFactor = conf.get('zoomFactor') as number|undefined;

// get window config
const windowConfig = getWindowConfig();
Expand Down Expand Up @@ -195,7 +209,11 @@ function createWindow(): void {
conf.set('zoomFactor', mainWindow.webContents.zoomFactor);

// Window positions and size
conf.set('windowConfig', mainWindow.getBounds());
const windowBounds = mainWindow.getBounds();
conf.set('windowX', windowBounds.x);
conf.set('windowY', windowBounds.y);
conf.set('windowWidth', windowBounds.width);
conf.set('windowHeight', windowBounds.height);

// Is it maximized?
conf.set('windowMaximized', mainWindow.isMaximized());
Expand All @@ -205,7 +223,7 @@ function createWindow(): void {
mainWindow.webContents.on('will-navigate', handleLinkClick);
mainWindow.webContents.setWindowOpenHandler((details => {
handleLinkClick(undefined, details.url);
return { action: "deny" };
return {action: "deny"};
}))

// Emitted when the window is closed.
Expand Down
Loading

0 comments on commit 07870b9

Please sign in to comment.