Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix auto-display of minimized window in Windows #81

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"recommendations": ["Vue.volar"]
"recommendations": ["Vue.volar", "esbenp.prettier-vscode"]
}
2 changes: 1 addition & 1 deletion neutralino.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"binaryName": "mobtimer",
"resourcesPath": "/dist/",
"extensionsPath": "/extensions/",
"binaryVersion": "5.1.0",
"binaryVersion": "5.4.0",
"frontendLibrary": {
"patchFile": "/resources/index.html",
"devUrl": "http://localhost:3000",
Expand Down
9 changes: 5 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"homepage": "https://github.com/jouni-kantola/mobtimer#readme",
"dependencies": {
"@neutralinojs/lib": "^5.1.0",
"@neutralinojs/lib": "^5.4.0",
"nanoid": "^5.0.8",
"vue": "^3.5.13"
},
Expand Down
6 changes: 5 additions & 1 deletion resources/scripts/neutralino-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export async function saveIntervalLength(seconds: number) {
}

export async function showWindow() {
await neuWindow.show();
if (await neuWindow.isMinimized()) {
await neuWindow.unminimize();
} else {
await neuWindow.show();
}
}

export async function hideWindow() {
Expand Down
38 changes: 37 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
import type { Plugin, ResolvedConfig } from "vite";

import { defineConfig } from "vite";
import fs from "node:fs/promises";
import path from "node:path";

import vue from "@vitejs/plugin-vue";

const neutralino = (): Plugin => {
let config: ResolvedConfig;

return {
name: "neutralino",
configResolved(resolvedConfig) {
config = resolvedConfig;
},
async transformIndexHtml(html) {
if (config.mode === "development") {
const authInfoFile = await fs.readFile(
path.join(".tmp", "auth_info.json"),
{
encoding: "utf-8",
}
);

const authInfo = JSON.parse(authInfoFile);
const port = authInfo.nlPort;

return html.replace(
/<script src="__neutralino_globals\.js"><\/script>/,
`<script src="http://localhost:${port}/__neutralino_globals.js"></script>`
);
}

return html;
},
};
};

// https://vitejs.dev/config/
export default defineConfig({
root: "resources",
Expand All @@ -11,5 +47,5 @@ export default defineConfig({
server: {
port: 3000,
},
plugins: [vue()],
plugins: [vue(), neutralino()],
});