mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Fix links opening
This commit is contained in:
parent
21fb6e8d93
commit
28aac451bf
1 changed files with 49 additions and 50 deletions
71
src/main.ts
71
src/main.ts
|
@ -1,11 +1,11 @@
|
||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
import { app, BrowserWindow, ipcMain, shell, desktopCapturer } from "electron";
|
import { app, BrowserWindow, ipcMain, shell, desktopCapturer } from "electron";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import 'v8-compile-cache';
|
import "v8-compile-cache";
|
||||||
import * as storage from 'electron-json-storage';
|
import * as storage from "electron-json-storage";
|
||||||
import {setup} from './utils';
|
import { setup } from "./utils";
|
||||||
import './extensions/plugin';
|
import "./extensions/plugin";
|
||||||
import './tray';
|
import "./tray";
|
||||||
var isSetup = null;
|
var isSetup = null;
|
||||||
var contentPath: string = "null";
|
var contentPath: string = "null";
|
||||||
var frame: boolean;
|
var frame: boolean;
|
||||||
|
@ -14,28 +14,28 @@ storage.keys(function(error, keys) {
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
for (var key of keys) {
|
for (var key of keys) {
|
||||||
console.log('There is a key called: ' + key);
|
console.log("There is a key called: " + key);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
storage.has('firstRun', function(error, hasKey) {
|
storage.has("firstRun", function (error, hasKey) {
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
if (!hasKey) {
|
if (!hasKey) {
|
||||||
console.log('First run of the ArmCord. Starting setup.');
|
console.log("First run of the ArmCord. Starting setup.");
|
||||||
isSetup = true;
|
isSetup = true;
|
||||||
setup();
|
setup();
|
||||||
contentPath = __dirname + '/content/setup.html'
|
contentPath = __dirname + "/content/setup.html";
|
||||||
} else {
|
} else {
|
||||||
console.log('ArmCord has been run before. Skipping setup.');
|
console.log("ArmCord has been run before. Skipping setup.");
|
||||||
isSetup = false;
|
isSetup = false;
|
||||||
contentPath = __dirname + '/content/index.html'
|
contentPath = __dirname + "/content/index.html";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
storage.get('settings', function(error, data:any) {
|
storage.get("settings", function (error, data: any) {
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
console.log(data);
|
console.log(data);
|
||||||
frame = data.customTitlebar;
|
frame = data.customTitlebar;
|
||||||
console.log(frame)
|
console.log(frame);
|
||||||
});
|
});
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
|
@ -44,9 +44,9 @@ function createWindow () {
|
||||||
title: "ArmCord",
|
title: "ArmCord",
|
||||||
frame: frame,
|
frame: frame,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, 'preload/preload.js')
|
preload: path.join(__dirname, "preload/preload.js"),
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
ipcMain.on("get-app-path", (event, arg) => {
|
ipcMain.on("get-app-path", (event, arg) => {
|
||||||
event.reply("app-path", app.getAppPath());
|
event.reply("app-path", app.getAppPath());
|
||||||
});
|
});
|
||||||
|
@ -73,34 +73,33 @@ function createWindow () {
|
||||||
});
|
});
|
||||||
ipcMain.on("get-app-version", (event) => {
|
ipcMain.on("get-app-version", (event) => {
|
||||||
event.returnValue = process.env.npm_package_version;
|
event.returnValue = process.env.npm_package_version;
|
||||||
})
|
});
|
||||||
ipcMain.on("splashEnd", (event, arg) => {
|
ipcMain.on("splashEnd", (event, arg) => {
|
||||||
mainWindow.setSize(800, 600);
|
mainWindow.setSize(800, 600);
|
||||||
});
|
});
|
||||||
ipcMain.on("channel", (event) => {
|
ipcMain.on("channel", (event) => {
|
||||||
event.returnValue = storage.getSync('channel');
|
event.returnValue = storage.getSync("channel");
|
||||||
})
|
});
|
||||||
ipcMain.on("armcord-support", (event) => {
|
ipcMain.handle("DESKTOP_CAPTURER_GET_SOURCES", (event, opts) =>
|
||||||
mainWindow.loadURL("https://discord.gg/F25bc4RYDt");
|
desktopCapturer.getSources(opts)
|
||||||
})
|
);
|
||||||
ipcMain.handle(
|
|
||||||
'DESKTOP_CAPTURER_GET_SOURCES',
|
|
||||||
(event, opts) => desktopCapturer.getSources(opts)
|
|
||||||
)
|
|
||||||
mainWindow.webContents.userAgent =
|
mainWindow.webContents.userAgent =
|
||||||
"Mozilla/5.0 (X11; Linux x86) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"; //fake useragent
|
"Mozilla/5.0 (X11; Linux x86) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"; //fake useragent
|
||||||
mainWindow.loadFile(contentPath)
|
mainWindow.webContents.on("new-window", function (e, url) {
|
||||||
|
e.preventDefault();
|
||||||
|
shell.openExternal(url);
|
||||||
|
});
|
||||||
|
mainWindow.loadFile(contentPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
createWindow()
|
createWindow();
|
||||||
|
|
||||||
app.on('activate', function () {
|
app.on("activate", function () {
|
||||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
app.on('window-all-closed', function () {
|
app.on("window-all-closed", function () {
|
||||||
if (process.platform !== 'darwin') app.quit()
|
if (process.platform !== "darwin") app.quit();
|
||||||
})
|
});
|
||||||
|
|
Loading…
Reference in a new issue