Skip to content

Commit

Permalink
Made the app 2x faster πŸš€
Browse files Browse the repository at this point in the history
- [pnpm] Added serve-handler (to serve the prebuilt app files) βœ…
- New minor release v1.0.2 ✨
  • Loading branch information
oyedejioyewole committed Mar 30, 2023
1 parent d34f2dc commit 4890b57
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 67 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# Javabattery

## v1.0.2 (Improvements πŸš€)

The UI is now prebuilt instead of being built on the fly πŸ—οΈ (the app is now 2x faster πŸš€)

## v1.0.1 (Improvements πŸš€)

Added error handling and configuration files πŸ€“
Expand Down
12 changes: 2 additions & 10 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ watch(status, async (_new) => {
if (!settings.value.enableNotifications) return;
const notification = useWebNotification({
icon: process.dev
? "/favicon.ico"
: window.globals.getPath("public", "favicon.ico"),
icon: "/favicon.ico",
title: "Javabattery",
});
Expand Down Expand Up @@ -79,9 +77,7 @@ onMounted(() =>
useFont([
{
family: "Open Sans",
src: process.dev
? "/fonts/open-sans.woff2"
: window.globals.getPath("public", "fonts", "open-sans.woff2"),
src: "/fonts/open-sans.woff2",
display: "swap",
},
])
Expand Down Expand Up @@ -165,10 +161,6 @@ onMounted(() =>
</template>

<style>
@tailwind base;
@tailwind components;
@tailwind utilities;
@keyframes scale {
from {
scale: 1;
Expand Down
4 changes: 3 additions & 1 deletion components/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const settings = useStorage<Settings>("settings", {
enableHighlighter: true,
});
await window.globals.saveSettings(JSON.stringify(settings.value));
onMounted(
async () => await window.globals.saveSettings(JSON.stringify(settings.value))
);
watch(
settings,
Expand Down
28 changes: 22 additions & 6 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,23 @@ import { autoUpdater } from "electron-updater";
import { writeFile, readFileSync, existsSync } from "fs";
import tinydate from "tinydate";
import { randomUUID } from "crypto";
import { createServer } from "http";
import handler from "serve-handler";

if (app.isPackaged) autoUpdater.checkForUpdatesAndNotify();
let listeningPort: number;

if (app.isPackaged) {
autoUpdater.checkForUpdatesAndNotify();

// Create a server for the prebuilt files
const server = createServer((request, response) => {
return handler(request, response, {
public: join(__dirname, "../.output/public"),
});
});
listeningPort = Math.floor(Math.random() * (65_535 - 1024) + 1024);
server.listen(listeningPort);
}

const createWindow = () => {
const window = new BrowserWindow({
Expand All @@ -28,11 +43,12 @@ const createWindow = () => {
? join(__dirname, "../build/icons/icon.png")
: join(__dirname, "../build/icons/icon.ico"),
});
if (app.isPackaged) {
window.loadFile(join(__dirname, "../.output/public/index.html"));
} else {
window.loadURL(process.env.VITE_DEV_SERVER_URL);
}

window.loadURL(
app.isPackaged
? `http://localhost:${listeningPort}`
: process.env.VITE_DEV_SERVER_URL
);
};

const createTrays = () => {
Expand Down
1 change: 0 additions & 1 deletion electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const { join } = require("path");

contextBridge.exposeInMainWorld("globals", {
openSite: async (url: string) => await shell.openExternal(url),
getPath: (...path: string[]) => join(__dirname, "..", ...path),
saveSettings: async (
settings: string
): Promise<string | NodeJS.ErrnoException> =>
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "OyewoleOyedeji",
"email": "[email protected]"
},
"version": "1.0.1",
"version": "1.0.2",
"private": true,
"main": "out/main.js",
"productName": "Javabattery",
Expand All @@ -24,10 +24,10 @@
"@vueuse/core": "^9.13.0",
"@vueuse/nuxt": "^9.13.0",
"bootstrap-icons": "^1.10.3",
"electron": "^23.2.0",
"electron": "^23.2.1",
"electron-builder": "^23.6.0",
"nuxt": "3.3.2",
"nuxt-electron": "^0.4.4",
"nuxt-electron": "^0.4.5",
"nuxt-fonty": "^1.0.0",
"vite-electron-plugin": "^0.8.2",
"vite-electron-renderer": "^0.0.3",
Expand All @@ -39,9 +39,11 @@
"battery": "^1.0.1",
"electron-updater": "^5.3.0",
"nuxt-battery": "^1.1.10",
"serve-handler": "^6.1.5",
"tinydate": "^1.3.0"
},
"optionalDependencies": {
"@types/node": "^18.15.11"
"@types/node": "^18.15.11",
"@types/serve-handler": "^6.1.1"
}
}
Loading

0 comments on commit 4890b57

Please sign in to comment.