fix formatting and linter warnings
This commit is contained in:
parent
c0eb4129ac
commit
60dbbde2af
5 changed files with 38 additions and 31 deletions
|
|
@ -10,8 +10,7 @@ import { VitePluginBuildConfig } from "@electron-forge/plugin-vite/dist/Config";
|
||||||
import { PublisherGithub } from "@electron-forge/publisher-github";
|
import { PublisherGithub } from "@electron-forge/publisher-github";
|
||||||
import type { ForgeConfig } from "@electron-forge/shared-types";
|
import type { ForgeConfig } from "@electron-forge/shared-types";
|
||||||
import { FuseV1Options, FuseVersion } from "@electron/fuses";
|
import { FuseV1Options, FuseVersion } from "@electron/fuses";
|
||||||
|
import * as fs from "fs";
|
||||||
import * as fs from "fs"
|
|
||||||
|
|
||||||
const STRINGS = {
|
const STRINGS = {
|
||||||
author: "Revolt Platforms LTD",
|
author: "Revolt Platforms LTD",
|
||||||
|
|
@ -114,7 +113,7 @@ fs.readdir("avia_core", (err: NodeJS.ErrnoException, files: string[]) => {
|
||||||
if (err) return;
|
if (err) return;
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
if (["js", "ts", "tsx"].includes(file.split('.').pop().toLowerCase())) {
|
if (["js", "ts", "tsx"].includes(file.split(".").pop().toLowerCase())) {
|
||||||
customVitePluginBuild.push({
|
customVitePluginBuild.push({
|
||||||
entry: `avia_core/${file}`,
|
entry: `avia_core/${file}`,
|
||||||
config: "vite.main.config.ts",
|
config: "vite.main.config.ts",
|
||||||
|
|
|
||||||
4
src/hackfix.d.ts
vendored
Normal file
4
src/hackfix.d.ts
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
declare module "*?asset" {
|
||||||
|
export const assetURL: string;
|
||||||
|
export default assetURL;
|
||||||
|
}
|
||||||
21
src/main.ts
21
src/main.ts
|
|
@ -1,4 +1,6 @@
|
||||||
import { IUpdateInfo, updateElectronApp } from "update-electron-app";
|
import * as fs from "fs";
|
||||||
|
import * as path from "path";
|
||||||
|
import { updateElectronApp } from "update-electron-app";
|
||||||
|
|
||||||
import { BrowserWindow, Notification, app, shell } from "electron";
|
import { BrowserWindow, Notification, app, shell } from "electron";
|
||||||
import started from "electron-squirrel-startup";
|
import started from "electron-squirrel-startup";
|
||||||
|
|
@ -9,17 +11,16 @@ import { initDiscordRpc } from "./native/discordRpc";
|
||||||
import { initTray } from "./native/tray";
|
import { initTray } from "./native/tray";
|
||||||
import { BUILD_URL, createMainWindow, mainWindow } from "./native/window";
|
import { BUILD_URL, createMainWindow, mainWindow } from "./native/window";
|
||||||
|
|
||||||
import * as fs from "fs";
|
|
||||||
import * as path from "path";
|
|
||||||
|
|
||||||
const applyAppName = () => {
|
const applyAppName = () => {
|
||||||
try {
|
try {
|
||||||
app.setName("AviaClient");
|
app.setName("AviaClient");
|
||||||
(app as any).name = "AviaClient";
|
app.name = "AviaClient";
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
app.setAppUserModelId("AviaClient");
|
app.setAppUserModelId("AviaClient");
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (started) {
|
if (started) {
|
||||||
|
|
@ -32,7 +33,7 @@ if (!config.hardwareAcceleration) {
|
||||||
|
|
||||||
const acquiredLock = app.requestSingleInstanceLock();
|
const acquiredLock = app.requestSingleInstanceLock();
|
||||||
|
|
||||||
const onNotifyUser = (_info: IUpdateInfo) => {
|
const onNotifyUser = () => {
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: "Update Available",
|
title: "Update Available",
|
||||||
body: "Restart the app to install the update.",
|
body: "Restart the app to install the update.",
|
||||||
|
|
@ -61,7 +62,7 @@ const loadInject = () => {
|
||||||
"aviadesktopversion.js",
|
"aviadesktopversion.js",
|
||||||
"customFrameNativeMenu.js",
|
"customFrameNativeMenu.js",
|
||||||
"disableTrayIcon.js",
|
"disableTrayIcon.js",
|
||||||
"clientBackup.js"
|
"clientBackup.js",
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const plugin of plugins) {
|
for (const plugin of plugins) {
|
||||||
|
|
@ -69,7 +70,9 @@ const loadInject = () => {
|
||||||
const pluginCode: string = fs.readFileSync(pluginPath, "utf8");
|
const pluginCode: string = fs.readFileSync(pluginPath, "utf8");
|
||||||
await mainWindow.webContents.executeJavaScript(pluginCode, true);
|
await mainWindow.webContents.executeJavaScript(pluginCode, true);
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,10 @@
|
||||||
import { Menu, Tray, nativeImage, app } from "electron";
|
import { Menu, Tray, app, nativeImage } from "electron";
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-unresolved
|
|
||||||
import trayIconAsset from "../../avia_assets/icon.png?asset";
|
import trayIconAsset from "../../avia_assets/icon.png?asset";
|
||||||
// eslint-disable-next-line import/no-unresolved
|
|
||||||
import macOsTrayIconAsset from "../../avia_assets/iconTemplate.png?asset";
|
import macOsTrayIconAsset from "../../avia_assets/iconTemplate.png?asset";
|
||||||
import { version } from "../../package.json";
|
import { version } from "../../package.json";
|
||||||
import { config } from "./config";
|
|
||||||
|
|
||||||
|
import { config } from "./config";
|
||||||
import { mainWindow, quitApp } from "./window";
|
import { mainWindow, quitApp } from "./window";
|
||||||
|
|
||||||
// internal tray state
|
// internal tray state
|
||||||
|
|
@ -34,10 +32,10 @@ export function initTray() {
|
||||||
config.sync();
|
config.sync();
|
||||||
if (config.disableTrayClick) { return; }
|
if (config.disableTrayClick) { return; }
|
||||||
if (mainWindow.isVisible()) {
|
if (mainWindow.isVisible()) {
|
||||||
mainWindow.hide();
|
mainWindow.hide();
|
||||||
} else {
|
} else {
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
mainWindow.focus();
|
mainWindow.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,14 +48,18 @@ export function createMainWindow() {
|
||||||
height: 720,
|
height: 720,
|
||||||
backgroundColor: "#191919",
|
backgroundColor: "#191919",
|
||||||
frame: !config.customFrame,
|
frame: !config.customFrame,
|
||||||
...(config.customFrame && config.customFrameNativeMenu ? {
|
...(config.customFrame && config.customFrameNativeMenu
|
||||||
// remove the default titlebar
|
? {
|
||||||
titleBarStyle: 'hidden',
|
// remove the default titlebar
|
||||||
// expose window controls in Windows/Linux
|
titleBarStyle: "hidden",
|
||||||
...(process.platform !== 'darwin' ? {
|
// expose window controls in Windows/Linux
|
||||||
titleBarOverlay: true
|
...(process.platform !== "darwin"
|
||||||
} : {})
|
? {
|
||||||
} : {}),
|
titleBarOverlay: true,
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
icon: windowIcon,
|
icon: windowIcon,
|
||||||
show: !startHidden,
|
show: !startHidden,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
|
|
@ -158,9 +162,8 @@ export function createMainWindow() {
|
||||||
|
|
||||||
// on macOS add margin to the title, and hide custom controls
|
// on macOS add margin to the title, and hide custom controls
|
||||||
// We only use initial values other the menu can disappear
|
// We only use initial values other the menu can disappear
|
||||||
if (process.platform === 'darwin' &&
|
if (process.platform === "darwin" && initialCustomFrame && initialCFNM) {
|
||||||
initialCustomFrame && initialCFNM) {
|
mainWindow.webContents.insertCSS(`
|
||||||
mainWindow.webContents.insertCSS(`
|
|
||||||
#root > div[style="display: flex; flex-direction: column; height: 100%;"] > div > div.h_29px {
|
#root > div[style="display: flex; flex-direction: column; height: 100%;"] > div > div.h_29px {
|
||||||
&> div.d_flex:first-child {
|
&> div.d_flex:first-child {
|
||||||
margin-left: 75px;
|
margin-left: 75px;
|
||||||
|
|
@ -170,7 +173,7 @@ export function createMainWindow() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// configure spellchecker context menu
|
// configure spellchecker context menu
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue