@niyamulahsan/create-deskapp 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/.env.example +20 -13
- package/template/AGENTS.md +699 -0
- package/template/package.json +3 -0
- package/template/src/config/app.ts +26 -24
- package/template/src/config/winsetup.ts +93 -91
- package/template/src/core/api/binding-error.ts +57 -0
- package/template/src/core/api/bindings.generated.ts +2 -0
- package/template/src/core/api/generate.manifest.ts +84 -80
- package/template/src/core/api/registry.ts +58 -48
- package/template/src/core/config.ts +101 -99
- package/template/src/core/database/aggregate.ts +89 -85
- package/template/src/core/database/config.ts +50 -48
- package/template/src/core/database/connection.ts +116 -114
- package/template/src/core/database/migrate-hooks.ts +86 -84
- package/template/src/core/database/paginate.ts +226 -224
- package/template/src/core/database/reset.ts +21 -19
- package/template/src/core/database/seed.ts +169 -167
- package/template/src/core/database/status.ts +37 -35
- package/template/src/core/env.ts +108 -106
- package/template/src/core/facade.ts +63 -61
- package/template/src/core/maker/db/fresh.ts +10 -8
- package/template/src/core/maker/db/generate.ts +13 -11
- package/template/src/core/maker/db/helpers.ts +92 -96
- package/template/src/core/maker/db/migrate.ts +37 -35
- package/template/src/core/maker/db/mod.ts +93 -91
- package/template/src/core/maker/db/module-migrate.ts +56 -54
- package/template/src/core/maker/db/push.ts +23 -21
- package/template/src/core/maker/db/reset.ts +8 -6
- package/template/src/core/maker/db/seed.ts +9 -7
- package/template/src/core/maker/db/status.ts +8 -6
- package/template/src/core/maker/help.ts +59 -57
- package/template/src/core/maker/make/controller.ts +25 -22
- package/template/src/core/maker/make/helpers.ts +97 -91
- package/template/src/core/maker/make/mod.ts +69 -67
- package/template/src/core/maker/make/model.ts +16 -14
- package/template/src/core/maker/make/module.ts +53 -39
- package/template/src/core/maker/make/seeder.ts +23 -21
- package/template/src/core/maker/make/test.ts +33 -30
- package/template/src/core/maker/mod.ts +85 -83
- package/template/src/core/maker/run/mod.ts +134 -132
- package/template/src/core/maker/stub.ts +26 -24
- package/template/src/core/maker/stubs/controller/controller.controller.stub +57 -55
- package/template/src/core/maker/stubs/controller/controller.schema.stub +18 -13
- package/template/src/core/maker/stubs/facade/facade.stub +21 -0
- package/template/src/core/maker/stubs/model/model.stub +10 -8
- package/template/src/core/maker/stubs/seeder/seeder.stub +18 -16
- package/template/src/core/maker/stubs/test/test.stub +9 -7
- package/template/src/core/maker/sync-config.ts +93 -94
- package/template/src/core/utils/password.ts +29 -27
- package/template/src/core/utils/playwright.ts +123 -121
- package/template/src/core/utils/queue.ts +68 -66
- package/template/src/core/utils/scheduler.ts +62 -60
- package/template/src/core/utils/storage.ts +3 -1
- package/template/src/core/utils/validation.ts +37 -35
- package/template/src/database/schema.ts +2 -0
- package/template/src/main.ts +120 -118
- package/template/src/modules/app/__tests__/demo.controller.test.ts +75 -0
- package/template/src/modules/app/__tests__/net.controller.test.ts +65 -0
- package/template/src/modules/app/__tests__/playwright.controller.test.ts +50 -0
- package/template/src/modules/app/__tests__/storage.controller.test.ts +114 -0
- package/template/src/modules/app/__tests__/window.controller.test.ts +98 -0
- package/template/src/modules/app/controllers/demo.controller.ts +120 -118
- package/template/src/modules/app/controllers/net.controller.ts +50 -48
- package/template/src/modules/app/controllers/playwright.controller.ts +142 -140
- package/template/src/modules/app/controllers/storage.controller.ts +231 -229
- package/template/src/modules/app/controllers/window.controller.ts +2 -0
- package/template/src/modules/app/facade.ts +21 -0
- package/template/src/preload.ts +25 -2
- package/template/src/ui/src/App.vue +4 -2
- package/template/src/ui/src/app.ts +38 -23
- package/template/src/ui/src/bindings.d.ts +18 -16
- package/template/src/ui/src/components/Button.vue +34 -32
- package/template/src/ui/src/components/Checkbox.vue +26 -29
- package/template/src/ui/src/components/Input.vue +221 -227
- package/template/src/ui/src/components/InputGroup.vue +141 -0
- package/template/src/ui/src/components/InputPasswordToggle.vue +204 -0
- package/template/src/ui/src/components/Modal.vue +65 -55
- package/template/src/ui/src/components/Spinner.vue +44 -42
- package/template/src/ui/src/components/Switch.vue +62 -65
- package/template/src/ui/src/components/TextArea.vue +108 -121
- package/template/src/ui/src/components/Toast.vue +55 -56
- package/template/src/ui/src/components/datatable/DataTableSkeleton.vue +100 -98
- package/template/src/ui/src/components/datatable/Pagination.vue +153 -125
- package/template/src/ui/src/components/datatable/SelectOpption.vue +36 -35
- package/template/src/ui/src/components/datatable/index.vue +336 -258
- package/template/src/ui/src/env.d.ts +16 -13
- package/template/src/ui/src/global.d.ts +21 -2
- package/template/src/ui/src/helpers/nformatter.ts +12 -10
- package/template/src/ui/src/pages/dashboard/index.vue +690 -687
- package/template/src/ui/src/plugins/browserDetect.ts +57 -0
- package/template/src/ui/src/plugins/gum.ts +576 -549
- package/template/src/ui/src/plugins/pulse.ts +2 -0
- package/template/src/ui/src/plugins/routeProgress.ts +89 -0
- package/template/src/ui/src/router/index.ts +44 -25
- package/template/src/ui/src/stores/example.ts +2 -0
- package/template/src/ui/vite.config.ts +40 -38
- package/template/src/window/app-menu.ts +89 -87
- package/template/src/window/config.ts +14 -12
- package/template/src/window/context-menu.ts +23 -21
- package/template/src/window/dialogs.ts +92 -90
- package/template/src/window/manager.ts +2 -0
- package/template/src/window/native.ts +47 -45
- package/template/src/window/tray.ts +132 -130
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// ./src/ui/src/plugins/routeProgress.ts
|
|
2
|
+
|
|
3
|
+
import type { Router } from "vue-router";
|
|
4
|
+
|
|
5
|
+
const BAR_ID = "app-route-progress";
|
|
6
|
+
|
|
7
|
+
function ensureBar(): HTMLElement {
|
|
8
|
+
const existing = document.getElementById(BAR_ID);
|
|
9
|
+
if (existing) return existing;
|
|
10
|
+
|
|
11
|
+
const bar = document.createElement("div");
|
|
12
|
+
bar.id = BAR_ID;
|
|
13
|
+
bar.style.position = "fixed";
|
|
14
|
+
bar.style.top = "0";
|
|
15
|
+
bar.style.left = "0";
|
|
16
|
+
bar.style.right = "0";
|
|
17
|
+
bar.style.height = "2px";
|
|
18
|
+
bar.style.width = "100vw";
|
|
19
|
+
bar.style.opacity = "0";
|
|
20
|
+
bar.style.zIndex = "99999";
|
|
21
|
+
bar.style.pointerEvents = "none";
|
|
22
|
+
bar.style.background = "linear-gradient(90deg, #2563eb, #06b6d4)";
|
|
23
|
+
bar.style.boxShadow = "0 0 8px rgba(37, 99, 235, 0.5)";
|
|
24
|
+
bar.style.transformOrigin = "left center";
|
|
25
|
+
bar.style.transform = "scaleX(0)";
|
|
26
|
+
bar.style.transition = "transform 0.25s ease, opacity 0.2s ease";
|
|
27
|
+
document.body.appendChild(bar);
|
|
28
|
+
return bar;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function setupRouteProgress(router: Router) {
|
|
32
|
+
if (typeof window === "undefined") return;
|
|
33
|
+
|
|
34
|
+
const bar = ensureBar();
|
|
35
|
+
let trickleTimer: number | null = null;
|
|
36
|
+
let finishTimer: number | null = null;
|
|
37
|
+
|
|
38
|
+
const clearTimers = () => {
|
|
39
|
+
if (trickleTimer !== null) {
|
|
40
|
+
window.clearInterval(trickleTimer);
|
|
41
|
+
trickleTimer = null;
|
|
42
|
+
}
|
|
43
|
+
if (finishTimer !== null) {
|
|
44
|
+
window.clearTimeout(finishTimer);
|
|
45
|
+
finishTimer = null;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const start = () => {
|
|
50
|
+
clearTimers();
|
|
51
|
+
bar.style.opacity = "1";
|
|
52
|
+
bar.dataset.progress = "0.18";
|
|
53
|
+
bar.style.transform = "scaleX(0.18)";
|
|
54
|
+
|
|
55
|
+
trickleTimer = window.setInterval(() => {
|
|
56
|
+
const current = Number.parseFloat(bar.dataset.progress || "0.18");
|
|
57
|
+
if (current >= 0.85) return;
|
|
58
|
+
const next = Math.min(current + Math.random() * 0.09, 0.85);
|
|
59
|
+
bar.dataset.progress = String(next);
|
|
60
|
+
bar.style.transform = `scaleX(${next})`;
|
|
61
|
+
}, 180);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const done = () => {
|
|
65
|
+
clearTimers();
|
|
66
|
+
bar.dataset.progress = "1";
|
|
67
|
+
bar.style.transform = "scaleX(1)";
|
|
68
|
+
finishTimer = window.setTimeout(() => {
|
|
69
|
+
bar.style.opacity = "0";
|
|
70
|
+
bar.style.transform = "scaleX(0)";
|
|
71
|
+
bar.dataset.progress = "0";
|
|
72
|
+
}, 220);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
router.beforeEach((to, from) => {
|
|
76
|
+
if (to.path !== from.path) {
|
|
77
|
+
start();
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
router.afterEach(() => {
|
|
83
|
+
done();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
router.onError(() => {
|
|
87
|
+
done();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
@@ -1,25 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
// ./src/ui/src/router/index.ts
|
|
2
|
+
|
|
3
|
+
import { createRouter, createWebHashHistory } from "vue-router";
|
|
4
|
+
import { setupRouteProgress } from "@/ui/plugins/routeProgress";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Router - one route for now, the dashboard at `/`. Route components are
|
|
8
|
+
* lazy-imported from the pages folder; add routes here as your app grows:
|
|
9
|
+
*
|
|
10
|
+
* { path: "/posts", name: "posts", component: () => import("@/ui/pages/posts/index.vue") }
|
|
11
|
+
*
|
|
12
|
+
* The backend serves the built SPA (`src/ui/dist`) for every path, so SPA
|
|
13
|
+
* routes work directly inside the desktop window.
|
|
14
|
+
*/
|
|
15
|
+
export const routes = [
|
|
16
|
+
{
|
|
17
|
+
path: "/",
|
|
18
|
+
name: "dashboard",
|
|
19
|
+
component: () => import("@/ui/pages/dashboard/index.vue")
|
|
20
|
+
}
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const router = createRouter({
|
|
24
|
+
history: createWebHashHistory(),
|
|
25
|
+
routes
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// setupRouteProgress(router);
|
|
29
|
+
|
|
30
|
+
// router.beforeEach(async (to) => {
|
|
31
|
+
// const auth = useAuthStore(); // first make it into pinia store and import from there
|
|
32
|
+
|
|
33
|
+
// if (to.meta.requiresAuth && !auth.isAuthenticated) {
|
|
34
|
+
// return { path: "/login", query: { redirect: to.fullPath } };
|
|
35
|
+
// }
|
|
36
|
+
|
|
37
|
+
// if (to.meta.guestOnly && auth.isAuthenticated) {
|
|
38
|
+
// return { path: "/" };
|
|
39
|
+
// }
|
|
40
|
+
|
|
41
|
+
// return true;
|
|
42
|
+
// });
|
|
43
|
+
|
|
44
|
+
export default router;
|
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
// ./src/ui/vite.config.ts
|
|
2
|
+
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import vue from "@vitejs/plugin-vue";
|
|
6
|
+
import { defineConfig } from "vite";
|
|
7
|
+
|
|
8
|
+
const rootDir = typeof import.meta.dirname === "string"
|
|
9
|
+
? import.meta.dirname
|
|
10
|
+
: path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
|
|
12
|
+
export default defineConfig({
|
|
13
|
+
// Use path.resolve for bulletproof Windows support
|
|
14
|
+
root: path.resolve(rootDir, "."),
|
|
15
|
+
plugins: [vue()],
|
|
16
|
+
base: "./",
|
|
17
|
+
define: {
|
|
18
|
+
__SOCKET_ENABLED__: JSON.stringify(!!process.env.VITE_SOCKET_URL || !!process.env.VITE_API_URL),
|
|
19
|
+
},
|
|
20
|
+
resolve: {
|
|
21
|
+
alias: {
|
|
22
|
+
"@/ui": path.resolve(rootDir, "./src"),
|
|
23
|
+
"@": path.resolve(rootDir, "../../src"),
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
server: {
|
|
27
|
+
port: 5173,
|
|
28
|
+
strictPort: true,
|
|
29
|
+
fs: {
|
|
30
|
+
allow: [path.resolve(rootDir, "../..")],
|
|
31
|
+
},
|
|
32
|
+
proxy: {
|
|
33
|
+
"/__invoke": "http://localhost:8000",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
build: {
|
|
37
|
+
outDir: "dist",
|
|
38
|
+
emptyOutDir: true,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -1,87 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
{ role: { role: "
|
|
74
|
-
|
|
75
|
-
{ role: { role: "
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
Menu.
|
|
87
|
-
|
|
1
|
+
// ./src/window/app-menu.ts
|
|
2
|
+
|
|
3
|
+
import { Menu } from "electron";
|
|
4
|
+
import { type DesktopWindow, win as winApi } from "@/window/manager";
|
|
5
|
+
|
|
6
|
+
export function removeAppMenu(win: DesktopWindow): void {
|
|
7
|
+
win.setMenu(null);
|
|
8
|
+
// On Windows/Linux this controls the application menu bar.
|
|
9
|
+
Menu.setApplicationMenu(null);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface MenuRole {
|
|
13
|
+
role: string;
|
|
14
|
+
}
|
|
15
|
+
export interface MenuActionItem {
|
|
16
|
+
item: { label: string; id?: string; accelerator?: string; enabled?: boolean };
|
|
17
|
+
}
|
|
18
|
+
export interface MenuSubmenu {
|
|
19
|
+
submenu: { label: string; items: MenuItem[] };
|
|
20
|
+
}
|
|
21
|
+
export type MenuItem = MenuActionItem | MenuSubmenu | "separator" | { role: MenuRole };
|
|
22
|
+
|
|
23
|
+
// Map our custom MenuItem types to Electron's MenuItemConstructorOptions
|
|
24
|
+
export function toElectronMenu(items: MenuItem[]): Electron.MenuItemConstructorOptions[] {
|
|
25
|
+
return items.map((item) => {
|
|
26
|
+
if (item === "separator") return { type: "separator" };
|
|
27
|
+
if ("role" in item) return { role: item.role.role as any };
|
|
28
|
+
if ("item" in item) {
|
|
29
|
+
return {
|
|
30
|
+
label: item.item.label,
|
|
31
|
+
id: item.item.id,
|
|
32
|
+
accelerator: item.item.accelerator,
|
|
33
|
+
enabled: item.item.enabled,
|
|
34
|
+
click: () => {
|
|
35
|
+
// Forward clicks to the window's custom event if needed,
|
|
36
|
+
// or handle globally
|
|
37
|
+
const mainWin = winApi.getWindow();
|
|
38
|
+
if (mainWin && item.item.id) {
|
|
39
|
+
// Emulate Deno's event by executing custom JS or sending IPC
|
|
40
|
+
mainWin.webContents.send("menu-click", item.item.id);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if ("submenu" in item) {
|
|
46
|
+
return {
|
|
47
|
+
label: item.submenu.label,
|
|
48
|
+
submenu: toElectronMenu(item.submenu.items)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return {};
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function defaultMenuItems(): MenuItem[] {
|
|
56
|
+
return [
|
|
57
|
+
{
|
|
58
|
+
submenu: {
|
|
59
|
+
label: "File",
|
|
60
|
+
items: [
|
|
61
|
+
{ item: { label: "New", id: "new", accelerator: "CmdOrCtrl+N", enabled: true } },
|
|
62
|
+
{ item: { label: "Open Settings", id: "openSettings", accelerator: "CmdOrCtrl+,", enabled: true } },
|
|
63
|
+
"separator",
|
|
64
|
+
{ role: { role: "quit" } }
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
submenu: {
|
|
70
|
+
label: "Edit",
|
|
71
|
+
items: [
|
|
72
|
+
{ role: { role: "undo" } },
|
|
73
|
+
{ role: { role: "redo" } },
|
|
74
|
+
"separator",
|
|
75
|
+
{ role: { role: "cut" } },
|
|
76
|
+
{ role: { role: "copy" } },
|
|
77
|
+
{ role: { role: "paste" } }
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function installAppMenu(win: DesktopWindow): void {
|
|
85
|
+
// Set menu for the main window (also sets application menu on Windows/Linux).
|
|
86
|
+
const menu = Menu.buildFromTemplate(toElectronMenu(defaultMenuItems()));
|
|
87
|
+
win.setMenu(menu);
|
|
88
|
+
Menu.setApplicationMenu(menu);
|
|
89
|
+
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
// ./src/window/config.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Backward-compat re-export. Window base setup lives in src/config/winsetup.ts.
|
|
5
|
+
*/
|
|
6
|
+
export {
|
|
7
|
+
type ChromeParts,
|
|
8
|
+
type DevToolsMode,
|
|
9
|
+
resolveChrome,
|
|
10
|
+
type WindowPreset,
|
|
11
|
+
windowConfig,
|
|
12
|
+
windowDev,
|
|
13
|
+
windows
|
|
14
|
+
} from "@config/winsetup";
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
// ./src/window/context-menu.ts
|
|
2
|
+
|
|
3
|
+
import { Menu } from "electron";
|
|
4
|
+
import type { DesktopWindow } from "@/window/manager";
|
|
5
|
+
|
|
6
|
+
export function installContextMenu(win: DesktopWindow): void {
|
|
7
|
+
win.webContents.on("context-menu", (_event, _params) => {
|
|
8
|
+
const menu = Menu.buildFromTemplate([
|
|
9
|
+
{ role: "copy" },
|
|
10
|
+
{ role: "paste" },
|
|
11
|
+
{ type: "separator" },
|
|
12
|
+
{ label: "Reload", click: () => win.reload() }
|
|
13
|
+
]);
|
|
14
|
+
menu.popup({ window: win });
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function disableContextMenu(win: DesktopWindow): void {
|
|
19
|
+
// Suppress default/custom context menu when explicitly disabled.
|
|
20
|
+
win.webContents.on("context-menu", (event) => {
|
|
21
|
+
event.preventDefault();
|
|
22
|
+
});
|
|
23
|
+
}
|