mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
added desktop
package
This commit is contained in:
parent
19df441d1c
commit
0115e34c5d
12
packages/desktop/electron-builder.yml
Normal file
12
packages/desktop/electron-builder.yml
Normal file
@ -0,0 +1,12 @@
|
||||
appId: com.ragestudio.comty
|
||||
productName: Comty
|
||||
copyright: Copyright © RageStudio
|
||||
directories:
|
||||
output: dist
|
||||
buildResources: resources
|
||||
files:
|
||||
- from: .
|
||||
filter:
|
||||
- package.json
|
||||
- app
|
||||
publish: null
|
3
packages/desktop/main/configs/config.js
Normal file
3
packages/desktop/main/configs/config.js
Normal file
@ -0,0 +1,3 @@
|
||||
const Config = require('electron-config')
|
||||
|
||||
module.exports = new Config({ name: 'config' });
|
BIN
packages/desktop/main/icon.png
Normal file
BIN
packages/desktop/main/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
234
packages/desktop/main/index.js
Normal file
234
packages/desktop/main/index.js
Normal file
@ -0,0 +1,234 @@
|
||||
const path = require("path")
|
||||
const {
|
||||
app,
|
||||
BrowserWindow,
|
||||
ipcMain,
|
||||
Tray,
|
||||
Menu,
|
||||
MenuItem,
|
||||
dialog,
|
||||
shell,
|
||||
screen,
|
||||
BrowserView,
|
||||
systemPreferences,
|
||||
Notification,
|
||||
globalShortcut
|
||||
} = require("electron")
|
||||
const log = require("electron-log")
|
||||
const packagejson = require("../../../package.json")
|
||||
const is = require("electron-is")
|
||||
const waitOn = require("wait-on")
|
||||
|
||||
console.log(is.dev())
|
||||
|
||||
let app_path = is.dev() ? "https://indev.comty.pw" : `file://${path.join(__dirname, "..", "renderer")}/index.html`;
|
||||
let mainWindow;
|
||||
let tray;
|
||||
let watcher;
|
||||
|
||||
// This gets rid of this: https://github.com/electron/electron/issues/13186
|
||||
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = true
|
||||
// app.commandLine.appendSwitch("disable-web-security")
|
||||
//app.commandLine.appendSwitch("disable-gpu-vsync=gpu")
|
||||
app.commandLine.appendSwitch("disable-features", "OutOfBlinkCors")
|
||||
|
||||
const gotTheLock = app.requestSingleInstanceLock()
|
||||
const notifySupport = Notification.isSupported()
|
||||
|
||||
// Prevent multiple instances
|
||||
if (!gotTheLock) {
|
||||
app.quit()
|
||||
}
|
||||
|
||||
function relaunchApp() {
|
||||
mainWindow.close()
|
||||
app.relaunch()
|
||||
}
|
||||
|
||||
function resumeApp() {
|
||||
if (mainWindow) {
|
||||
mainWindow.show()
|
||||
mainWindow.focus()
|
||||
} else {
|
||||
createWindow()
|
||||
}
|
||||
}
|
||||
|
||||
function notify(params) {
|
||||
if (!notifySupport || !params) return false
|
||||
let options = {
|
||||
title: "",
|
||||
body: "",
|
||||
icon: null,
|
||||
timeoutType: "default"
|
||||
}
|
||||
|
||||
const keys = Object.keys(params)
|
||||
const values = Object.values(params)
|
||||
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
options[keys[i]] = values[i]
|
||||
}
|
||||
|
||||
new Notification(options).show()
|
||||
}
|
||||
|
||||
function createWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
title: packagejson.title,
|
||||
icon: path.join(__dirname, "./icon.png"),
|
||||
width: 1100,
|
||||
height: 700,
|
||||
minWidth: 1256,
|
||||
minHeight: 755,
|
||||
show: true,
|
||||
frame: false,
|
||||
transparent: false,
|
||||
hasShadow: true,
|
||||
//webgl: true,
|
||||
visualEffectState: "followWindow",
|
||||
backgroundColor: "#00ffffff",
|
||||
webPreferences: {
|
||||
//enableRemoteModule: true,
|
||||
enableBlinkFeatures: true,
|
||||
experimentalFeatures: true,
|
||||
nodeIntegration: true,
|
||||
// Disable in dev since I think hot reload is messing with it
|
||||
webSecurity: !is.dev()
|
||||
}
|
||||
})
|
||||
|
||||
if (is.dev()) {
|
||||
app.commandLine.appendSwitch("remote-debugging-port", "9222")
|
||||
globalShortcut.register("CommandOrControl+R", () => {
|
||||
mainWindow.reload()
|
||||
})
|
||||
|
||||
globalShortcut.register("F5", () => {
|
||||
mainWindow.reload()
|
||||
})
|
||||
}
|
||||
|
||||
mainWindow.webContents.session.webRequest.onHeadersReceived(
|
||||
{
|
||||
urls: ["http://*/*", "https://*/*"]
|
||||
},
|
||||
(details, callback) => {
|
||||
delete details.responseHeaders["Access-Control-Allow-Origin"]
|
||||
delete details.responseHeaders["access-control-allow-origin"]
|
||||
if (details.url.includes("www.google-analytics.com")) {
|
||||
details.responseHeaders["Access-Control-Allow-Origin"] = [app_path]
|
||||
} else {
|
||||
details.responseHeaders["Access-Control-Allow-Origin"] = ["*"]
|
||||
}
|
||||
callback({
|
||||
cancel: false,
|
||||
responseHeaders: details.responseHeaders
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
mainWindow.loadURL(app_path)
|
||||
mainWindow.focus()
|
||||
|
||||
if (is.dev()) {
|
||||
mainWindow.webContents.openDevTools()
|
||||
}
|
||||
|
||||
// const handleRedirect = (e, url) => {
|
||||
// if (url !== mainWindow.webContents.getURL()) {
|
||||
// e.preventDefault()
|
||||
// shell.openExternal(url)
|
||||
// }
|
||||
// };
|
||||
|
||||
// mainWindow.webContents.on("will-navigate", handleRedirect)
|
||||
// mainWindow.webContents.on("new-window", handleRedirect)
|
||||
}
|
||||
|
||||
app.on("ready", () => {
|
||||
if (is.dev()) {
|
||||
loadWindow = new BrowserWindow({
|
||||
width: 700,
|
||||
height: 500,
|
||||
frame: false,
|
||||
resizable: false,
|
||||
center: true,
|
||||
transparent: true,
|
||||
backgroundColor: "#00000000",
|
||||
});
|
||||
|
||||
loadWindow.loadURL(`file://${__dirname}/statics/loading_dev.html`)
|
||||
|
||||
notify({ title: "Starting development server..." })
|
||||
|
||||
// waitOn({ resources: [app_path] }, function (err) {
|
||||
// if (err) {
|
||||
// return log.log(err)
|
||||
// }
|
||||
// })
|
||||
|
||||
createWindow()
|
||||
loadWindow.close()
|
||||
} else {
|
||||
createWindow()
|
||||
}
|
||||
})
|
||||
|
||||
app.on("window-all-closed", () => {
|
||||
mainWindow = null;
|
||||
})
|
||||
|
||||
app.on("before-quit", async () => {
|
||||
mainWindow.removeAllListeners("close");
|
||||
mainWindow = null;
|
||||
})
|
||||
|
||||
ipcMain.handle("update-progress-bar", (event, p) => {
|
||||
mainWindow.setProgressBar(p);
|
||||
})
|
||||
|
||||
ipcMain.handle("hide-window", () => {
|
||||
if (mainWindow) {
|
||||
mainWindow.hide();
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle("show-window", () => {
|
||||
if (mainWindow) {
|
||||
mainWindow.show();
|
||||
mainWindow.focus();
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle("min-max-window", () => {
|
||||
if (mainWindow.isMaximized()) {
|
||||
mainWindow.unmaximize();
|
||||
} else if (mainWindow.maximizable) {
|
||||
mainWindow.maximize();
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle("getSystemPreferences", () => {
|
||||
return systemPreferences
|
||||
})
|
||||
|
||||
ipcMain.handle("minimize-window", () => {
|
||||
mainWindow.minimize();
|
||||
})
|
||||
|
||||
ipcMain.handle("quit-app", () => {
|
||||
app.quit();
|
||||
})
|
||||
|
||||
ipcMain.handle("open-devtools", () => {
|
||||
mainWindow.webContents.openDevTools({ mode: "undocked" });
|
||||
})
|
||||
|
||||
ipcMain.handle("appRelaunch", () => {
|
||||
relaunchApp()
|
||||
})
|
||||
|
||||
ipcMain.handle("inspectElement", (event, payload) => {
|
||||
mainWindow.inspectElement(payload.x, payload.y)
|
||||
})
|
112
packages/desktop/main/statics/loading.css
Normal file
112
packages/desktop/main/statics/loading.css
Normal file
@ -0,0 +1,112 @@
|
||||
body {
|
||||
background-color: transparent;
|
||||
border-radius: 12px;
|
||||
font-family: 'Alata', sans-serif;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
user-select: none;
|
||||
-webkit-app-region: drag;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
background-color: #efefef;
|
||||
color: #2d2d2d;
|
||||
border-radius: 12px;
|
||||
text-align: center;
|
||||
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.bouncy-logo{
|
||||
width: 100%;
|
||||
height: auto;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.bouncy-logo .ball {
|
||||
height: auto;
|
||||
width: 100%;
|
||||
transform: translate(-10px, 0);
|
||||
}
|
||||
|
||||
.bouncy-logo .ball svg {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
margin: auto;
|
||||
|
||||
-webkit-animation-direction: alternate;
|
||||
-webkit-animation-duration: 1s;
|
||||
-webkit-animation-name: my-bounce;
|
||||
-webkit-animation-iteration-count: infinite;
|
||||
animation-direction: alternate;
|
||||
animation-duration: 1s;
|
||||
animation-name: my-bounce;
|
||||
animation-iteration-count: infinite;
|
||||
}
|
||||
|
||||
.shadow{
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.bouncy-logo .ball-shadow {
|
||||
margin: auto;
|
||||
background: radial-gradient(50% 50%, rgba(204, 204, 204, 0.45) 0%, transparent 100%);
|
||||
height: 50px;
|
||||
width: 200px;
|
||||
-webkit-animation-direction: alternate;
|
||||
-webkit-animation-duration: 1s;
|
||||
-webkit-animation-name: my-grow;
|
||||
-webkit-animation-iteration-count: infinite;
|
||||
animation-direction: alternate;
|
||||
animation-duration: 1s;
|
||||
animation-name: my-grow;
|
||||
animation-iteration-count: infinite;
|
||||
}
|
||||
|
||||
@-webkit-keyframes my-grow {
|
||||
from {
|
||||
width: 200px;
|
||||
height: 50px;
|
||||
}
|
||||
to {
|
||||
width: 150px;
|
||||
height: 10px;
|
||||
}
|
||||
}
|
||||
@keyframes my-grow {
|
||||
from {
|
||||
width: 200px;
|
||||
height: 50px;
|
||||
}
|
||||
to {
|
||||
width: 150px;
|
||||
height: 10px;
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes my-bounce {
|
||||
from {
|
||||
top: 0;
|
||||
}
|
||||
to {
|
||||
top: 10%;
|
||||
}
|
||||
}
|
||||
@keyframes my-bounce {
|
||||
from {
|
||||
top: 0;
|
||||
}
|
||||
to {
|
||||
top: 10%;
|
||||
}
|
||||
}
|
23
packages/desktop/main/statics/loading.html
Normal file
23
packages/desktop/main/statics/loading.html
Normal file
@ -0,0 +1,23 @@
|
||||
<html>
|
||||
<link rel="stylesheet" href="./loading.css">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Alata&display=swap" rel="stylesheet">
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="bouncy-logo">
|
||||
<div class="ball">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 120">
|
||||
<path
|
||||
d="M77.55,29.69,92,18.78a1.42,1.42,0,0,0,.25-2,39.2,39.2,0,0,0-56.31-4.21A38.05,38.05,0,0,0,23.23,42a38.09,38.09,0,0,0,3.62,15.1A38.65,38.65,0,0,0,37.8,70.84,39.46,39.46,0,0,0,83.37,73a38.26,38.26,0,0,0,8.41-7.4,1.41,1.41,0,0,0-.23-2L77.65,53a1.43,1.43,0,0,0-1.9.15A17,17,0,0,1,72.55,56a17.75,17.75,0,0,1-9,2.88c-8.32.31-13.62-5.69-14-6.13a17.68,17.68,0,0,1-4.13-10.13,17.93,17.93,0,0,1,4.56-13A17.46,17.46,0,0,1,71.7,26.34a17.3,17.3,0,0,1,4,3.2A1.41,1.41,0,0,0,77.55,29.69Z"
|
||||
style="fill: rgba(51, 51, 51, 0.45); backdrop-filter: blur(2px);"
|
||||
/>
|
||||
<path
|
||||
d="M13,63.17a2.77,2.77,0,0,1,3.75,1.43A48.38,48.38,0,0,0,32.07,84.53,48.83,48.83,0,0,0,52.34,93.3,47.37,47.37,0,0,0,92.57,81.8a2.77,2.77,0,0,1,4,.3l6.23,7.4a2.79,2.79,0,0,1-.21,3.83,63.83,63.83,0,0,1-6,5,62.21,62.21,0,0,1-7.44,4.7A60.84,60.84,0,0,1,77,108a62.3,62.3,0,0,1-27,1.51A62.51,62.51,0,0,1,40.18,107,61.5,61.5,0,0,1,20.1,95.69,61.73,61.73,0,0,1,2.41,71a2.79,2.79,0,0,1,1.42-3.55Z"
|
||||
style="fill: rgba(51, 51, 51, 0.45); backdrop-filter: blur(2px);"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="shadow"><div class="ball-shadow"></div></div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
24
packages/desktop/main/statics/loading_dev.html
Normal file
24
packages/desktop/main/statics/loading_dev.html
Normal file
@ -0,0 +1,24 @@
|
||||
<html>
|
||||
<link rel="stylesheet" href="./loading.css">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Alata&display=swap" rel="stylesheet">
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="bouncy-logo">
|
||||
<div class="ball">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 120">
|
||||
<path
|
||||
d="M77.55,29.69,92,18.78a1.42,1.42,0,0,0,.25-2,39.2,39.2,0,0,0-56.31-4.21A38.05,38.05,0,0,0,23.23,42a38.09,38.09,0,0,0,3.62,15.1A38.65,38.65,0,0,0,37.8,70.84,39.46,39.46,0,0,0,83.37,73a38.26,38.26,0,0,0,8.41-7.4,1.41,1.41,0,0,0-.23-2L77.65,53a1.43,1.43,0,0,0-1.9.15A17,17,0,0,1,72.55,56a17.75,17.75,0,0,1-9,2.88c-8.32.31-13.62-5.69-14-6.13a17.68,17.68,0,0,1-4.13-10.13,17.93,17.93,0,0,1,4.56-13A17.46,17.46,0,0,1,71.7,26.34a17.3,17.3,0,0,1,4,3.2A1.41,1.41,0,0,0,77.55,29.69Z"
|
||||
style="fill: rgba(51, 51, 51, 0.45); backdrop-filter: blur(2px);"
|
||||
/>
|
||||
<path
|
||||
d="M13,63.17a2.77,2.77,0,0,1,3.75,1.43A48.38,48.38,0,0,0,32.07,84.53,48.83,48.83,0,0,0,52.34,93.3,47.37,47.37,0,0,0,92.57,81.8a2.77,2.77,0,0,1,4,.3l6.23,7.4a2.79,2.79,0,0,1-.21,3.83,63.83,63.83,0,0,1-6,5,62.21,62.21,0,0,1-7.44,4.7A60.84,60.84,0,0,1,77,108a62.3,62.3,0,0,1-27,1.51A62.51,62.51,0,0,1,40.18,107,61.5,61.5,0,0,1,20.1,95.69,61.73,61.73,0,0,1,2.41,71a2.79,2.79,0,0,1,1.42-3.55Z"
|
||||
style="fill: rgba(51, 51, 51, 0.45); backdrop-filter: blur(2px);"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="shadow"><div class="ball-shadow"></div></div>
|
||||
</div>
|
||||
<h2> Starting the development server... </h2>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
15
packages/desktop/package.json
Normal file
15
packages/desktop/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "comty-desktop",
|
||||
"version": "0.0.1",
|
||||
"main": "main/index.js",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"start": "electron ."
|
||||
},
|
||||
"dependencies": {
|
||||
"electron": "17.1.2",
|
||||
"electron-log": "^3.0.0",
|
||||
"electron-is": "^1.0.0",
|
||||
"wait-on": "^2.0.0"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user