Skip to content

Commit eb25980

Browse files
committed
chore: update import order and improve code structure
- Added import order parser plugins to .prettierrc for better organization. - Cleaned up import statements across multiple files for consistency. - Refactored code in various modules to enhance readability and maintainability. No functional changes were made, only structural improvements.
1 parent 4371657 commit eb25980

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+215
-181
lines changed

.prettierrc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,11 @@
1818
"^[./]"
1919
],
2020
"importOrderSeparation": true,
21-
"importOrderSortSpecifiers": true
21+
"importOrderSortSpecifiers": true,
22+
"importOrderParserPlugins": [
23+
"typescript",
24+
"jsx",
25+
"classProperties",
26+
"decorators-legacy"
27+
]
2228
}

src/main/app-preload/module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { RgModule } from "@devisfuture/electron-modular";
2+
23
import { AppPreloadIpc } from "./ipc.js";
34
import { AppPreloadWindow } from "./window.js";
45

src/main/app-preload/window.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { isDev } from "#shared/utils.js";
2+
import { WindowManager } from "@devisfuture/electron-modular";
13
import { app } from "electron";
24
import path from "node:path";
3-
import { WindowManager } from "@devisfuture/electron-modular";
4-
import { isDev } from "#shared/utils.js";
5+
56
import type { TWindowManager } from "../types.js";
67

78
@WindowManager<TWindows["preloadApp"]>({

src/main/app-version/ipc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { app } from "electron";
1+
import { ipcMainHandle } from "#shared/ipc/ipc.js";
22
import {
33
IpcHandler,
44
type TIpcHandlerInterface,
55
} from "@devisfuture/electron-modular";
6-
import { ipcMainHandle } from "#shared/ipc/ipc.js";
6+
import { app } from "electron";
77

88
@IpcHandler()
99
export class AppVersionIpc implements TIpcHandlerInterface {

src/main/app-version/module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { RgModule } from "@devisfuture/electron-modular";
2+
23
import { AppVersionIpc } from "./ipc.js";
34

45
@RgModule({

src/main/app/ipc.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import { app, dialog } from "electron";
1+
import { ipcMainOn } from "#shared/ipc/ipc.js";
22
import {
33
Inject,
4-
TParamOnInit,
5-
TIpcHandlerInterface,
64
IpcHandler,
5+
TIpcHandlerInterface,
6+
TParamOnInit,
77
getWindow as getWindows,
88
} from "@devisfuture/electron-modular";
9-
import { ipcMainOn } from "#shared/ipc/ipc.js";
10-
import { AppService } from "./service.js";
9+
import { app, dialog } from "electron";
10+
1111
import { messages } from "../config.js";
12+
13+
import { AppService } from "./service.js";
1214
import type { TDestroyProcess } from "./types.js";
1315

1416
@IpcHandler()
1517
export class AppIpc implements TIpcHandlerInterface {
16-
constructor(
17-
private appService: AppService,
18-
) {
18+
constructor(private appService: AppService) {
1919
process.on("uncaughtException", (error) => {
2020
this.destroyProcess({
2121
error,
@@ -59,7 +59,7 @@ export class AppIpc implements TIpcHandlerInterface {
5959
const mainWindow = getWindow("window:main");
6060
const window = await mainWindow.create();
6161

62-
ipcMainOn('windowClosePreload', async () => {
62+
ipcMainOn("windowClosePreload", async () => {
6363
const preloadAppWindow =
6464
getWindows<TWindows["preloadApp"]>("window:preload-app");
6565
if (preloadAppWindow !== undefined) {

src/main/app/module.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,14 @@ import { RgModule } from "@devisfuture/electron-modular";
22

33
import { MenuModule } from "#main/menu/module.js";
44
import { MenuService } from "#main/menu/service.js";
5-
65
import { TrayModule } from "#main/tray/module.js";
76
import { TrayService } from "#main/tray/service.js";
87

98
import { AppIpc } from "./ipc.js";
109
import { AppService } from "./service.js";
10+
import { MENU_PROVIDER, TRAY_PROVIDER } from "./tokens.js";
11+
import type { TMenuProvider, TTrayProvider } from "./types.js";
1112
import { AppWindow } from "./window.js";
12-
import {
13-
MENU_PROVIDER,
14-
TRAY_PROVIDER,
15-
} from "./tokens.js";
16-
import type {
17-
TMenuProvider,
18-
TTrayProvider,
19-
} from "./types.js";
2013

2114
@RgModule({
2215
imports: [MenuModule, TrayModule],
@@ -40,7 +33,7 @@ import type {
4033
destroy: () => trayService.destroy(),
4134
}),
4235
inject: [TrayService],
43-
}
36+
},
4437
],
4538
})
4639
export class AppModule {}

src/main/app/service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { app } from "electron";
21
import { Inject, Injectable, getWindow } from "@devisfuture/electron-modular";
2+
import { app } from "electron";
3+
34
import { TRAY_PROVIDER } from "./tokens.js";
45
import type { TTrayProvider } from "./types.js";
56

src/main/app/window.ts

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
import { app, BrowserWindow, Event } from "electron";
1+
import { isDev } from "#shared/utils.js";
22
import {
33
Inject,
44
WindowManager,
55
destroyWindows,
66
} from "@devisfuture/electron-modular";
7-
import { isDev } from "#shared/utils.js";
8-
import type { TWindowManager } from "../types.js";
9-
import {
10-
MENU_PROVIDER,
11-
TRAY_PROVIDER,
12-
} from "./tokens.js";
13-
import type {
14-
TMenuProvider,
15-
TTrayProvider,
16-
} from "./types.js";
7+
import { BrowserWindow, Event, app } from "electron";
8+
179
import { menu } from "#main/config.js";
1810

11+
import type { TWindowManager } from "../types.js";
12+
import { MENU_PROVIDER, TRAY_PROVIDER } from "./tokens.js";
13+
import type { TMenuProvider, TTrayProvider } from "./types.js";
14+
1915
@WindowManager<TWindows["main"]>({
2016
hash: "window:main",
2117
isCache: true,
@@ -42,39 +38,41 @@ export class AppWindow implements TWindowManager {
4238
}
4339

4440
onWebContentsDidFinishLoad(window: BrowserWindow): void {
45-
this.menuProvider.collect(this.menuProvider.getMenu().map((item) => {
46-
if (item.name === "app") {
47-
item.submenu = [
48-
{
49-
label: menu.labels.devTools,
50-
click: () => window.webContents.openDevTools(),
51-
},
52-
{
53-
label: menu.labels.quit,
54-
click: () => app.quit(),
55-
},
56-
];
57-
}
58-
return item;
59-
}));
60-
61-
this.trayProvider.collect(this.trayProvider.getMenu().map((item) => {
62-
if (item.name === "show") {
63-
item.click = () => {
64-
window.show();
65-
if (app.dock) {
66-
app.dock.show();
67-
}
68-
};
69-
}
41+
this.menuProvider.collect(
42+
this.menuProvider.getMenu().map((item) => {
43+
if (item.name === "app") {
44+
item.submenu = [
45+
{
46+
label: menu.labels.devTools,
47+
click: () => window.webContents.openDevTools(),
48+
},
49+
{
50+
label: menu.labels.quit,
51+
click: () => app.quit(),
52+
},
53+
];
54+
}
55+
return item;
56+
}),
57+
);
7058

71-
if (item.name === "quit") {
72-
item.click = () => app.quit();
73-
}
74-
return item;
75-
}));
59+
this.trayProvider.collect(
60+
this.trayProvider.getMenu().map((item) => {
61+
if (item.name === "show") {
62+
item.click = () => {
63+
window.show();
64+
if (app.dock) {
65+
app.dock.show();
66+
}
67+
};
68+
}
7669

77-
70+
if (item.name === "quit") {
71+
item.click = () => app.quit();
72+
}
73+
return item;
74+
}),
75+
);
7876
}
7977

8078
onShow(): void {

src/main/auth/ipc.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1-
import { restApi } from "../config.js";
2-
import { IpcHandler, getWindow as getWindows, type TParamOnInit } from "@devisfuture/electron-modular";
1+
import { cacheUser } from "#shared/cache-responses.js";
32
import { ipcMainOn, ipcWebContentsSend } from "#shared/ipc/ipc.js";
4-
import { AuthService } from "./service.js";
53
import { getElectronStorage } from "#shared/store.js";
6-
import { cacheUser } from "#shared/cache-responses.js";
4+
import {
5+
IpcHandler,
6+
type TParamOnInit,
7+
getWindow as getWindows,
8+
} from "@devisfuture/electron-modular";
9+
10+
import { restApi } from "../config.js";
11+
12+
import { AuthService } from "./service.js";
713

814
@IpcHandler()
915
export class AuthIpc {
10-
constructor(private authProvider: AuthService) {}
16+
constructor(private authService: AuthService) {}
1117

12-
onInit({ getWindow }: TParamOnInit<TWindows['auth']>): void {
13-
const authWindow = getWindow('window:auth');
18+
onInit({ getWindow }: TParamOnInit<TWindows["auth"]>): void {
19+
const authWindow = getWindow("window:auth");
1420
const mainWindow = getWindows("window:main");
1521

16-
ipcMainOn('windowAuth', async (_, { provider }) => {
22+
ipcMainOn("windowAuth", async (_, { provider }) => {
1723
authWindow.create({
1824
loadURL: `${restApi.urls.base}${restApi.urls.baseApi}${restApi.urls.auth.base}${restApi.urls.auth[provider]}`,
1925
options: {
@@ -24,20 +30,20 @@ export class AuthIpc {
2430
});
2531
});
2632

27-
ipcMainOn('checkAuth', () => {
33+
ipcMainOn("checkAuth", () => {
2834
const userId = getElectronStorage("userId");
2935
const userFromCache = cacheUser(userId);
3036

3137
if (mainWindow !== undefined) {
32-
ipcWebContentsSend('auth', mainWindow.webContents, {
38+
ipcWebContentsSend("auth", mainWindow.webContents, {
3339
isAuthenticated: Boolean(userFromCache),
3440
});
3541
}
3642
});
3743

3844
ipcMainOn("logout", () => {
3945
if (mainWindow !== undefined) {
40-
this.authProvider.logout(mainWindow);
46+
this.authService.logout(mainWindow);
4147
}
4248
});
4349
}

0 commit comments

Comments
 (0)