mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-22 13:32:42 +01:00
transitioning to ts
This commit is contained in:
parent
412f1ae3e3
commit
46d030cf8e
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,3 +13,4 @@ build/linux/arch/*
|
|||||||
# JetBrains IDE configuration
|
# JetBrains IDE configuration
|
||||||
.idea
|
.idea
|
||||||
ts-dist/**
|
ts-dist/**
|
||||||
|
ts-dist
|
||||||
|
12
.vscode/settings.json
vendored
12
.vscode/settings.json
vendored
@ -1,3 +1,13 @@
|
|||||||
{
|
{
|
||||||
"cSpell.words": ["hifi", "rescrobbler", "widevine"]
|
"cSpell.words": [
|
||||||
|
"flac",
|
||||||
|
"geqnfr",
|
||||||
|
"hifi",
|
||||||
|
"playpause",
|
||||||
|
"rescrobbler",
|
||||||
|
"trackid",
|
||||||
|
"tracklist",
|
||||||
|
"widevine",
|
||||||
|
"xesam"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
121
package-lock.json
generated
121
package-lock.json
generated
@ -20,6 +20,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mastermindzh/prettier-config": "^1.0.0",
|
"@mastermindzh/prettier-config": "^1.0.0",
|
||||||
|
"@types/express": "^4.17.17",
|
||||||
|
"@types/request": "^2.48.8",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.59.1",
|
"@typescript-eslint/eslint-plugin": "^5.59.1",
|
||||||
"@typescript-eslint/parser": "^5.59.1",
|
"@typescript-eslint/parser": "^5.59.1",
|
||||||
"electron": "git+https://github.com/castlabs/electron-releases.git#v24.1.2+wvcus",
|
"electron": "git+https://github.com/castlabs/electron-releases.git#v24.1.2+wvcus",
|
||||||
@ -915,6 +917,16 @@
|
|||||||
"node": ">= 10"
|
"node": ">= 10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/body-parser": {
|
||||||
|
"version": "1.19.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz",
|
||||||
|
"integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@types/connect": "*",
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/cacheable-request": {
|
"node_modules/@types/cacheable-request": {
|
||||||
"version": "6.0.3",
|
"version": "6.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz",
|
||||||
@ -926,6 +938,45 @@
|
|||||||
"@types/responselike": "^1.0.0"
|
"@types/responselike": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/caseless": {
|
||||||
|
"version": "0.12.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.2.tgz",
|
||||||
|
"integrity": "sha512-6ckxMjBBD8URvjB6J3NcnuAn5Pkl7t3TizAg+xdlzzQGSPSmBcXf8KoIH0ua/i+tio+ZRUHEXp0HEmvaR4kt0w==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/@types/connect": {
|
||||||
|
"version": "3.4.35",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz",
|
||||||
|
"integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/express": {
|
||||||
|
"version": "4.17.17",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz",
|
||||||
|
"integrity": "sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@types/body-parser": "*",
|
||||||
|
"@types/express-serve-static-core": "^4.17.33",
|
||||||
|
"@types/qs": "*",
|
||||||
|
"@types/serve-static": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/express-serve-static-core": {
|
||||||
|
"version": "4.17.34",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.34.tgz",
|
||||||
|
"integrity": "sha512-fvr49XlCGoUj2Pp730AItckfjat4WNb0lb3kfrLWffd+RLeoGAMsq7UOy04PAPtoL01uKwcp6u8nhzpgpDYr3w==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*",
|
||||||
|
"@types/qs": "*",
|
||||||
|
"@types/range-parser": "*",
|
||||||
|
"@types/send": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/http-cache-semantics": {
|
"node_modules/@types/http-cache-semantics": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz",
|
||||||
@ -945,6 +996,12 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/mime": {
|
||||||
|
"version": "1.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz",
|
||||||
|
"integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/@types/minimist": {
|
"node_modules/@types/minimist": {
|
||||||
"version": "1.2.2",
|
"version": "1.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz",
|
||||||
@ -973,6 +1030,44 @@
|
|||||||
"xmlbuilder": ">=11.0.1"
|
"xmlbuilder": ">=11.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/qs": {
|
||||||
|
"version": "6.9.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz",
|
||||||
|
"integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/@types/range-parser": {
|
||||||
|
"version": "1.2.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz",
|
||||||
|
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/@types/request": {
|
||||||
|
"version": "2.48.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/request/-/request-2.48.8.tgz",
|
||||||
|
"integrity": "sha512-whjk1EDJPcAR2kYHRbFl/lKeeKYTi05A15K9bnLInCVroNDCtXce57xKdI0/rQaA3K+6q0eFyUBPmqfSndUZdQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@types/caseless": "*",
|
||||||
|
"@types/node": "*",
|
||||||
|
"@types/tough-cookie": "*",
|
||||||
|
"form-data": "^2.5.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/request/node_modules/form-data": {
|
||||||
|
"version": "2.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz",
|
||||||
|
"integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"asynckit": "^0.4.0",
|
||||||
|
"combined-stream": "^1.0.6",
|
||||||
|
"mime-types": "^2.1.12"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/responselike": {
|
"node_modules/@types/responselike": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz",
|
||||||
@ -987,6 +1082,32 @@
|
|||||||
"integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==",
|
"integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/send": {
|
||||||
|
"version": "0.17.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.1.tgz",
|
||||||
|
"integrity": "sha512-Cwo8LE/0rnvX7kIIa3QHCkcuF21c05Ayb0ZfxPiv0W8VRiZiNW/WuRupHKpqqGVGf7SUA44QSOUKaEd9lIrd/Q==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@types/mime": "^1",
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/serve-static": {
|
||||||
|
"version": "1.15.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.1.tgz",
|
||||||
|
"integrity": "sha512-NUo5XNiAdULrJENtJXZZ3fHtfMolzZwczzBbnAeBbqBwG+LaG6YaJtuwzwGSQZ2wsCrxjEhNNjAkKigy3n8teQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@types/mime": "*",
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/tough-cookie": {
|
||||||
|
"version": "4.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.2.tgz",
|
||||||
|
"integrity": "sha512-Q5vtl1W5ue16D+nIaW8JWebSSraJVlK+EthKn7e7UcD4KWsaSJ8BqGPXNaPghgtcn/fhvrN17Tv8ksUsQpiplw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/@types/verror": {
|
"node_modules/@types/verror": {
|
||||||
"version": "1.10.6",
|
"version": "1.10.6",
|
||||||
"resolved": "https://registry.npmjs.org/@types/verror/-/verror-1.10.6.tgz",
|
"resolved": "https://registry.npmjs.org/@types/verror/-/verror-1.10.6.tgz",
|
||||||
|
@ -45,6 +45,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mastermindzh/prettier-config": "^1.0.0",
|
"@mastermindzh/prettier-config": "^1.0.0",
|
||||||
|
"@types/express": "^4.17.17",
|
||||||
|
"@types/request": "^2.48.8",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.59.1",
|
"@typescript-eslint/eslint-plugin": "^5.59.1",
|
||||||
"@typescript-eslint/parser": "^5.59.1",
|
"@typescript-eslint/parser": "^5.59.1",
|
||||||
"electron": "git+https://github.com/castlabs/electron-releases.git#v24.1.2+wvcus",
|
"electron": "git+https://github.com/castlabs/electron-releases.git#v24.1.2+wvcus",
|
||||||
|
12
src/main.ts
12
src/main.ts
@ -19,7 +19,7 @@ import {
|
|||||||
import { addTray, refreshTray } from "./scripts/tray";
|
import { addTray, refreshTray } from "./scripts/tray";
|
||||||
import { addMenu } from "./scripts/menu";
|
import { addMenu } from "./scripts/menu";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import expressModule from "./scripts/express";
|
import { startExpress } from "./scripts/express";
|
||||||
import mediaKeys from "./constants/mediaKeys";
|
import mediaKeys from "./constants/mediaKeys";
|
||||||
import mediaInfoModule from "./scripts/mediaInfo";
|
import mediaInfoModule from "./scripts/mediaInfo";
|
||||||
import discordModule from "./scripts/discord";
|
import discordModule from "./scripts/discord";
|
||||||
@ -29,7 +29,7 @@ const tidalUrl = "https://listen.tidal.com";
|
|||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
let mainWindow: any;
|
let mainWindow: BrowserWindow;
|
||||||
const icon = path.join(__dirname, "../assets/icon.png");
|
const icon = path.join(__dirname, "../assets/icon.png");
|
||||||
const PROTOCOL_PREFIX = "tidal";
|
const PROTOCOL_PREFIX = "tidal";
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ function setFlags() {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function syncMenuBarWithStore() {
|
function syncMenuBarWithStore() {
|
||||||
const fixedMenuBar = store.get(settings.menuBar);
|
const fixedMenuBar = !!store.get(settings.menuBar);
|
||||||
|
|
||||||
mainWindow.autoHideMenuBar = !fixedMenuBar;
|
mainWindow.autoHideMenuBar = !fixedMenuBar;
|
||||||
mainWindow.setMenuBarVisibility(fixedMenuBar);
|
mainWindow.setMenuBarVisibility(fixedMenuBar);
|
||||||
@ -111,7 +111,7 @@ function createWindow(options = { x: 0, y: 0, backgroundColor: "white" }) {
|
|||||||
mainWindow.webContents.setBackgroundThrottling(false);
|
mainWindow.webContents.setBackgroundThrottling(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
mainWindow.on("close", function (event: any) {
|
mainWindow.on("close", function (event: CloseEvent) {
|
||||||
if (store.get(settings.minimizeOnClose)) {
|
if (store.get(settings.minimizeOnClose)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
mainWindow.hide();
|
mainWindow.hide();
|
||||||
@ -169,9 +169,9 @@ app.on("ready", async () => {
|
|||||||
addGlobalShortcuts();
|
addGlobalShortcuts();
|
||||||
if (store.get(settings.trayIcon)) {
|
if (store.get(settings.trayIcon)) {
|
||||||
addTray(mainWindow, { icon });
|
addTray(mainWindow, { icon });
|
||||||
refreshTray();
|
refreshTray(mainWindow);
|
||||||
}
|
}
|
||||||
store.get(settings.api) && expressModule.run(mainWindow);
|
store.get(settings.api) && startExpress(mainWindow);
|
||||||
store.get(settings.enableDiscord) && discordModule.initRPC();
|
store.get(settings.enableDiscord) && discordModule.initRPC();
|
||||||
} else {
|
} else {
|
||||||
app.quit();
|
app.quit();
|
||||||
|
12
src/models/options.ts
Normal file
12
src/models/options.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
export interface Options {
|
||||||
|
title: string;
|
||||||
|
artists: string;
|
||||||
|
album: string;
|
||||||
|
status: string;
|
||||||
|
url: string;
|
||||||
|
current: string;
|
||||||
|
duration: string;
|
||||||
|
"app-name": string;
|
||||||
|
image: string;
|
||||||
|
icon: string;
|
||||||
|
}
|
@ -1,28 +1,29 @@
|
|||||||
let adBlock,
|
let adBlock: HTMLInputElement,
|
||||||
api,
|
api: HTMLInputElement,
|
||||||
customCSS,
|
customCSS: HTMLInputElement,
|
||||||
disableBackgroundThrottle,
|
disableBackgroundThrottle: HTMLInputElement,
|
||||||
disableHardwareMediaKeys,
|
disableHardwareMediaKeys: HTMLInputElement,
|
||||||
enableCustomHotkeys,
|
enableCustomHotkeys: HTMLInputElement,
|
||||||
enableDiscord,
|
enableDiscord: HTMLInputElement,
|
||||||
gpuRasterization,
|
gpuRasterization: HTMLInputElement,
|
||||||
menuBar,
|
menuBar: HTMLInputElement,
|
||||||
minimizeOnClose,
|
minimizeOnClose: HTMLInputElement,
|
||||||
mpris,
|
mpris: HTMLInputElement,
|
||||||
notifications,
|
notifications: HTMLInputElement,
|
||||||
playBackControl,
|
playBackControl: HTMLInputElement,
|
||||||
port,
|
port: HTMLInputElement,
|
||||||
singleInstance,
|
singleInstance: HTMLInputElement,
|
||||||
skipArtists,
|
skipArtists: HTMLInputElement,
|
||||||
skippedArtists,
|
skippedArtists: HTMLInputElement,
|
||||||
trayIcon,
|
trayIcon: HTMLInputElement,
|
||||||
updateFrequency;
|
updateFrequency: HTMLInputElement;
|
||||||
|
|
||||||
const { store, settings } = require("../../scripts/settings");
|
const { store, settings } = require("../../scripts/settings");
|
||||||
const { ipcRenderer } = require("electron");
|
const { ipcRenderer } = require("electron");
|
||||||
const globalEvents = require("../../constants/globalEvents");
|
const globalEvents = require("../../constants/globalEvents");
|
||||||
const remote = require("@electron/remote");
|
const remote = require("@electron/remote");
|
||||||
const { app } = remote;
|
const { app } = remote;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sync the UI forms with the current settings
|
* Sync the UI forms with the current settings
|
||||||
*/
|
*/
|
||||||
@ -30,7 +31,7 @@ function refreshSettings() {
|
|||||||
adBlock.checked = store.get(settings.adBlock);
|
adBlock.checked = store.get(settings.adBlock);
|
||||||
api.checked = store.get(settings.api);
|
api.checked = store.get(settings.api);
|
||||||
customCSS.value = store.get(settings.customCSS);
|
customCSS.value = store.get(settings.customCSS);
|
||||||
disableBackgroundThrottle.checked = store.get("disableBackgroundThrottle");
|
disableBackgroundThrottle.checked = store.get(settings.disableBackgroundThrottle);
|
||||||
disableHardwareMediaKeys.checked = store.get(settings.flags.disableHardwareMediaKeys);
|
disableHardwareMediaKeys.checked = store.get(settings.flags.disableHardwareMediaKeys);
|
||||||
enableCustomHotkeys.checked = store.get(settings.enableCustomHotkeys);
|
enableCustomHotkeys.checked = store.get(settings.enableCustomHotkeys);
|
||||||
enableDiscord.checked = store.get(settings.enableDiscord);
|
enableDiscord.checked = store.get(settings.enableDiscord);
|
||||||
@ -43,7 +44,7 @@ function refreshSettings() {
|
|||||||
port.value = store.get(settings.apiSettings.port);
|
port.value = store.get(settings.apiSettings.port);
|
||||||
singleInstance.checked = store.get(settings.singleInstance);
|
singleInstance.checked = store.get(settings.singleInstance);
|
||||||
skipArtists.checked = store.get(settings.skipArtists);
|
skipArtists.checked = store.get(settings.skipArtists);
|
||||||
skippedArtists.value = store.get(settings.skippedArtists).join("\n");
|
skippedArtists.value = (store.get(settings.skippedArtists) as string[]).join("\n");
|
||||||
trayIcon.checked = store.get(settings.trayIcon);
|
trayIcon.checked = store.get(settings.trayIcon);
|
||||||
updateFrequency.value = store.get(settings.updateFrequency);
|
updateFrequency.value = store.get(settings.updateFrequency);
|
||||||
}
|
}
|
||||||
@ -51,7 +52,7 @@ function refreshSettings() {
|
|||||||
/**
|
/**
|
||||||
* Open an url in the default browsers
|
* Open an url in the default browsers
|
||||||
*/
|
*/
|
||||||
function openExternal(url) {
|
function openExternal(url: string) {
|
||||||
const { shell } = require("electron");
|
const { shell } = require("electron");
|
||||||
shell.openExternal(url);
|
shell.openExternal(url);
|
||||||
}
|
}
|
||||||
@ -75,31 +76,31 @@ function restart() {
|
|||||||
* Bind UI components to functions after DOMContentLoaded
|
* Bind UI components to functions after DOMContentLoaded
|
||||||
*/
|
*/
|
||||||
window.addEventListener("DOMContentLoaded", () => {
|
window.addEventListener("DOMContentLoaded", () => {
|
||||||
function get(id) {
|
function get(id: string): HTMLInputElement {
|
||||||
return document.getElementById(id);
|
return document.getElementById(id) as HTMLInputElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("close").addEventListener("click", hide);
|
document.getElementById("close").addEventListener("click", hide);
|
||||||
document.getElementById("restart").addEventListener("click", restart);
|
document.getElementById("restart").addEventListener("click", restart);
|
||||||
document.querySelectorAll(".external-link").forEach((elem) =>
|
document.querySelectorAll(".external-link").forEach((elem) =>
|
||||||
elem.addEventListener("click", function (event) {
|
elem.addEventListener("click", function (event) {
|
||||||
openExternal(event.target.getAttribute("data-url"));
|
openExternal((event.target as HTMLElement).getAttribute("data-url"));
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
function addInputListener(source, key) {
|
function addInputListener(source: HTMLInputElement, key: string) {
|
||||||
source.addEventListener("input", function (_event, _data) {
|
source.addEventListener("input", () => {
|
||||||
if (this.value === "on") {
|
if (source.value === "on") {
|
||||||
store.set(key, source.checked);
|
store.set(key, source.checked);
|
||||||
} else {
|
} else {
|
||||||
store.set(key, this.value);
|
store.set(key, source.value);
|
||||||
}
|
}
|
||||||
ipcRenderer.send(globalEvents.storeChanged);
|
ipcRenderer.send(globalEvents.storeChanged);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addTextAreaListener(source, key) {
|
function addTextAreaListener(source: HTMLInputElement, key: string) {
|
||||||
source.addEventListener("input", function (_event, _data) {
|
source.addEventListener("input", () => {
|
||||||
store.set(key, source.value.split("\n"));
|
store.set(key, source.value.split("\n"));
|
||||||
ipcRenderer.send(globalEvents.storeChanged);
|
ipcRenderer.send(globalEvents.storeChanged);
|
||||||
});
|
});
|
@ -1,17 +1,17 @@
|
|||||||
const { setTitle } = require("./scripts/window-functions");
|
import { Notification, app, dialog } from "@electron/remote";
|
||||||
const { dialog, process, Notification } = require("@electron/remote");
|
import { ipcRenderer } from "electron";
|
||||||
|
import { Options } from "./models/options";
|
||||||
|
import { downloadFile } from "./scripts/download";
|
||||||
|
import { addHotkey } from "./scripts/hotkeys";
|
||||||
|
import { setTitle } from "./scripts/window-functions";
|
||||||
const { store, settings } = require("./scripts/settings");
|
const { store, settings } = require("./scripts/settings");
|
||||||
const { ipcRenderer } = require("electron");
|
const notificationPath = `${app.getPath("userData")}/notification.jpg`;
|
||||||
const { app } = require("@electron/remote");
|
|
||||||
const { downloadFile } = require("./scripts/download");
|
|
||||||
const statuses = require("./constants/statuses");
|
const statuses = require("./constants/statuses");
|
||||||
const hotkeys = require("./scripts/hotkeys");
|
|
||||||
const globalEvents = require("./constants/globalEvents");
|
const globalEvents = require("./constants/globalEvents");
|
||||||
const { skipArtists, updateFrequency, customCSS } = require("./constants/settings");
|
const { skipArtists, updateFrequency, customCSS } = require("./constants/settings");
|
||||||
const notificationPath = `${app.getPath("userData")}/notification.jpg`;
|
|
||||||
const appName = "Tidal Hifi";
|
const appName = "Tidal Hifi";
|
||||||
let currentSong = "";
|
let currentSong = "";
|
||||||
let player;
|
let player: any;
|
||||||
let currentPlayStatus = statuses.paused;
|
let currentPlayStatus = statuses.paused;
|
||||||
|
|
||||||
const elements = {
|
const elements = {
|
||||||
@ -45,7 +45,7 @@ const elements = {
|
|||||||
* Get an element from the dom
|
* Get an element from the dom
|
||||||
* @param {*} key key in elements object to fetch
|
* @param {*} key key in elements object to fetch
|
||||||
*/
|
*/
|
||||||
get: function (key) {
|
get: function (key: string) {
|
||||||
return window.document.querySelector(this[key.toLowerCase()]);
|
return window.document.querySelector(this[key.toLowerCase()]);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ const elements = {
|
|||||||
|
|
||||||
if (footer) {
|
if (footer) {
|
||||||
const artists = footer.querySelectorAll(this.artists);
|
const artists = footer.querySelectorAll(this.artists);
|
||||||
if (artists) return Array.from(artists).map((artist) => artist.textContent);
|
if (artists) return Array.from(artists).map((artist) => (artist as HTMLElement).textContent);
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
@ -84,7 +84,7 @@ const elements = {
|
|||||||
* @param {Array} artistsArray
|
* @param {Array} artistsArray
|
||||||
* @returns {String} artists
|
* @returns {String} artists
|
||||||
*/
|
*/
|
||||||
getArtistsString: function (artistsArray) {
|
getArtistsString: function (artistsArray: string[]) {
|
||||||
if (artistsArray.length > 0) return artistsArray.join(", ");
|
if (artistsArray.length > 0) return artistsArray.join(", ");
|
||||||
return "unknown artist(s)";
|
return "unknown artist(s)";
|
||||||
},
|
},
|
||||||
@ -120,7 +120,7 @@ const elements = {
|
|||||||
* Shorthand function to get the text of a dom element
|
* Shorthand function to get the text of a dom element
|
||||||
* @param {*} key key in elements object to fetch
|
* @param {*} key key in elements object to fetch
|
||||||
*/
|
*/
|
||||||
getText: function (key) {
|
getText: function (key: string) {
|
||||||
const element = this.get(key);
|
const element = this.get(key);
|
||||||
return element ? element.textContent : "";
|
return element ? element.textContent : "";
|
||||||
},
|
},
|
||||||
@ -129,7 +129,7 @@ const elements = {
|
|||||||
* Shorthand function to click a dom element
|
* Shorthand function to click a dom element
|
||||||
* @param {*} key key in elements object to fetch
|
* @param {*} key key in elements object to fetch
|
||||||
*/
|
*/
|
||||||
click: function (key) {
|
click: function (key: string) {
|
||||||
this.get(key).click();
|
this.get(key).click();
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
@ -138,7 +138,7 @@ const elements = {
|
|||||||
* Shorthand function to focus a dom element
|
* Shorthand function to focus a dom element
|
||||||
* @param {*} key key in elements object to fetch
|
* @param {*} key key in elements object to fetch
|
||||||
*/
|
*/
|
||||||
focus: function (key) {
|
focus: function (key: string) {
|
||||||
return this.get(key).focus();
|
return this.get(key).focus();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -186,40 +186,40 @@ function playPause() {
|
|||||||
*/
|
*/
|
||||||
function addHotKeys() {
|
function addHotKeys() {
|
||||||
if (store.get(settings.enableCustomHotkeys)) {
|
if (store.get(settings.enableCustomHotkeys)) {
|
||||||
hotkeys.add("Control+p", function () {
|
addHotkey("Control+p", function () {
|
||||||
elements.click("account").click("settings");
|
elements.click("account").click("settings");
|
||||||
});
|
});
|
||||||
hotkeys.add("Control+l", function () {
|
addHotkey("Control+l", function () {
|
||||||
handleLogout();
|
handleLogout();
|
||||||
});
|
});
|
||||||
|
|
||||||
hotkeys.add("Control+h", function () {
|
addHotkey("Control+h", function () {
|
||||||
elements.click("home");
|
elements.click("home");
|
||||||
});
|
});
|
||||||
|
|
||||||
hotkeys.add("backspace", function () {
|
addHotkey("backspace", function () {
|
||||||
elements.click("back");
|
elements.click("back");
|
||||||
});
|
});
|
||||||
|
|
||||||
hotkeys.add("shift+backspace", function () {
|
addHotkey("shift+backspace", function () {
|
||||||
elements.click("forward");
|
elements.click("forward");
|
||||||
});
|
});
|
||||||
|
|
||||||
hotkeys.add("control+u", function () {
|
addHotkey("control+u", function () {
|
||||||
// reloading window without cache should show the update bar if applicable
|
// reloading window without cache should show the update bar if applicable
|
||||||
window.location.reload(true);
|
window.location.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
hotkeys.add("control+r", function () {
|
addHotkey("control+r", function () {
|
||||||
elements.click("repeat");
|
elements.click("repeat");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// always add the hotkey for the settings window
|
// always add the hotkey for the settings window
|
||||||
hotkeys.add("control+=", function () {
|
addHotkey("control+=", function () {
|
||||||
ipcRenderer.send(globalEvents.showSettings);
|
ipcRenderer.send(globalEvents.showSettings);
|
||||||
});
|
});
|
||||||
hotkeys.add("control+0", function () {
|
addHotkey("control+0", function () {
|
||||||
ipcRenderer.send(globalEvents.showSettings);
|
ipcRenderer.send(globalEvents.showSettings);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -231,28 +231,26 @@ function addHotKeys() {
|
|||||||
function handleLogout() {
|
function handleLogout() {
|
||||||
const logoutOptions = ["Cancel", "Yes, please", "No, thanks"];
|
const logoutOptions = ["Cancel", "Yes, please", "No, thanks"];
|
||||||
|
|
||||||
dialog.showMessageBox(
|
dialog
|
||||||
null,
|
.showMessageBox(null, {
|
||||||
{
|
|
||||||
type: "question",
|
type: "question",
|
||||||
title: "Logging out",
|
title: "Logging out",
|
||||||
message: "Are you sure you want to log out?",
|
message: "Are you sure you want to log out?",
|
||||||
buttons: logoutOptions,
|
buttons: logoutOptions,
|
||||||
defaultId: 2,
|
defaultId: 2,
|
||||||
},
|
})
|
||||||
function (response) {
|
.then((result: { response: number }) => {
|
||||||
if (logoutOptions.indexOf("Yes, please") == response) {
|
if (logoutOptions.indexOf("Yes, please") == result.response) {
|
||||||
for (let i = 0; i < window.localStorage.length; i++) {
|
for (let i = 0; i < window.localStorage.length; i++) {
|
||||||
const key = window.localStorage.key(i);
|
const key = window.localStorage.key(i);
|
||||||
if (key.startsWith("_TIDAL_activeSession")) {
|
if (key.startsWith("_TIDAL_activeSession")) {
|
||||||
window.localStorage.removeItem(key);
|
window.localStorage.removeItem(key);
|
||||||
i = window.localStorage.length + 1;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addFullScreenListeners() {
|
function addFullScreenListeners() {
|
||||||
@ -309,7 +307,7 @@ function getCurrentlyPlayingStatus() {
|
|||||||
* Convert the duration from MM:SS to seconds
|
* Convert the duration from MM:SS to seconds
|
||||||
* @param {*} duration
|
* @param {*} duration
|
||||||
*/
|
*/
|
||||||
function convertDuration(duration) {
|
function convertDuration(duration: string) {
|
||||||
const parts = duration.split(":");
|
const parts = duration.split(":");
|
||||||
return parseInt(parts[1]) + 60 * parseInt(parts[0]);
|
return parseInt(parts[1]) + 60 * parseInt(parts[0]);
|
||||||
}
|
}
|
||||||
@ -319,7 +317,7 @@ function convertDuration(duration) {
|
|||||||
*
|
*
|
||||||
* @param {*} options
|
* @param {*} options
|
||||||
*/
|
*/
|
||||||
function updateMediaInfo(options, notify) {
|
function updateMediaInfo(options: Options, notify: boolean) {
|
||||||
if (options) {
|
if (options) {
|
||||||
ipcRenderer.send(globalEvents.updateInfo, options);
|
ipcRenderer.send(globalEvents.updateInfo, options);
|
||||||
if (store.get(settings.notifications) && notify) {
|
if (store.get(settings.notifications) && notify) {
|
||||||
@ -361,7 +359,7 @@ function getTrackID() {
|
|||||||
return window.location;
|
return window.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateMediaSession(options) {
|
function updateMediaSession(options: Options) {
|
||||||
if ("mediaSession" in navigator) {
|
if ("mediaSession" in navigator) {
|
||||||
navigator.mediaSession.metadata = new MediaMetadata({
|
navigator.mediaSession.metadata = new MediaMetadata({
|
||||||
title: options.title,
|
title: options.title,
|
||||||
@ -401,6 +399,8 @@ setInterval(function () {
|
|||||||
current,
|
current,
|
||||||
duration,
|
duration,
|
||||||
"app-name": appName,
|
"app-name": appName,
|
||||||
|
image: "",
|
||||||
|
icon: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
const titleOrArtistsChanged = currentSong !== songDashArtistTitle;
|
const titleOrArtistsChanged = currentSong !== songDashArtistTitle;
|
||||||
@ -413,7 +413,7 @@ setInterval(function () {
|
|||||||
|
|
||||||
const image = elements.getSongIcon();
|
const image = elements.getSongIcon();
|
||||||
|
|
||||||
new Promise((resolve) => {
|
new Promise<void>((resolve) => {
|
||||||
if (image.startsWith("http")) {
|
if (image.startsWith("http")) {
|
||||||
options.image = image;
|
options.image = image;
|
||||||
downloadFile(image, notificationPath).then(
|
downloadFile(image, notificationPath).then(
|
||||||
@ -444,9 +444,9 @@ setInterval(function () {
|
|||||||
* automatically skip a song if the artists are found in the list of artists to skip
|
* automatically skip a song if the artists are found in the list of artists to skip
|
||||||
* @param {*} artists array of artists
|
* @param {*} artists array of artists
|
||||||
*/
|
*/
|
||||||
function skipArtistsIfFoundInSkippedArtistsList(artists) {
|
function skipArtistsIfFoundInSkippedArtistsList(artists: string[]) {
|
||||||
if (store.get(skipArtists)) {
|
if (store.get(skipArtists)) {
|
||||||
const skippedArtists = store.get(settings.skippedArtists);
|
const skippedArtists = store.get(settings.skippedArtists) as string[];
|
||||||
if (skippedArtists.length > 0) {
|
if (skippedArtists.length > 0) {
|
||||||
const artistsToSkip = skippedArtists.map((artist) => artist);
|
const artistsToSkip = skippedArtists.map((artist) => artist);
|
||||||
const artistNames = Object.values(artists).map((artist) => artist);
|
const artistNames = Object.values(artists).map((artist) => artist);
|
||||||
@ -478,7 +478,7 @@ if (process.platform === "linux" && store.get(settings.mpris)) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
var events = {
|
const events = {
|
||||||
next: "next",
|
next: "next",
|
||||||
previous: "previous",
|
previous: "previous",
|
||||||
pause: "pause",
|
pause: "pause",
|
||||||
@ -488,7 +488,7 @@ if (process.platform === "linux" && store.get(settings.mpris)) {
|
|||||||
loopStatus: "repeat",
|
loopStatus: "repeat",
|
||||||
shuffle: "shuffle",
|
shuffle: "shuffle",
|
||||||
seek: "seek",
|
seek: "seek",
|
||||||
};
|
} as { [key: string]: string };
|
||||||
Object.keys(events).forEach(function (eventName) {
|
Object.keys(events).forEach(function (eventName) {
|
||||||
player.on(eventName, function () {
|
player.on(eventName, function () {
|
||||||
const eventValue = events[eventName];
|
const eventValue = events[eventName];
|
@ -1,26 +0,0 @@
|
|||||||
const download = {};
|
|
||||||
const request = require("request");
|
|
||||||
const fs = require("fs");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* download and save a file
|
|
||||||
* @param {*} fileUrl url to download
|
|
||||||
* @param {*} targetPath path to save it at
|
|
||||||
*/
|
|
||||||
download.downloadFile = function(fileUrl, targetPath) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
var req = request({
|
|
||||||
method: "GET",
|
|
||||||
uri: fileUrl,
|
|
||||||
});
|
|
||||||
|
|
||||||
var out = fs.createWriteStream(targetPath);
|
|
||||||
req.pipe(out);
|
|
||||||
|
|
||||||
req.on("end", resolve);
|
|
||||||
|
|
||||||
req.on("error", reject);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = download;
|
|
23
src/scripts/download.ts
Normal file
23
src/scripts/download.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import fs from "fs";
|
||||||
|
import request from "request";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* download and save a file
|
||||||
|
* @param {string} fileUrl url to download
|
||||||
|
* @param {string} targetPath path to save it at
|
||||||
|
*/
|
||||||
|
export const downloadFile = function (fileUrl: string, targetPath: string) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const req = request({
|
||||||
|
method: "GET",
|
||||||
|
uri: fileUrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
const out = fs.createWriteStream(targetPath);
|
||||||
|
req.pipe(out);
|
||||||
|
|
||||||
|
req.on("end", resolve);
|
||||||
|
|
||||||
|
req.on("error", reject);
|
||||||
|
});
|
||||||
|
};
|
@ -1,23 +1,23 @@
|
|||||||
const express = require("express");
|
import { BrowserWindow } from "electron";
|
||||||
|
import express, { Response } from "express";
|
||||||
|
import fs from "fs";
|
||||||
const { mediaInfo } = require("./mediaInfo");
|
const { mediaInfo } = require("./mediaInfo");
|
||||||
const { store, settings } = require("./settings");
|
const { store, settings } = require("./settings");
|
||||||
const globalEvents = require("./../constants/globalEvents");
|
const globalEvents = require("./../constants/globalEvents");
|
||||||
const statuses = require("./../constants/statuses");
|
const statuses = require("./../constants/statuses");
|
||||||
const expressModule = {};
|
|
||||||
const fs = require("fs");
|
|
||||||
|
|
||||||
let expressInstance;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to enable tidal-hifi's express api
|
* Function to enable tidal-hifi's express api
|
||||||
*/
|
*/
|
||||||
expressModule.run = function (mainWindow) {
|
|
||||||
|
// expressModule.run = function (mainWindow)
|
||||||
|
export const startExpress = (mainWindow: BrowserWindow) => {
|
||||||
/**
|
/**
|
||||||
* Shorthand to handle a fire and forget global event
|
* Shorthand to handle a fire and forget global event
|
||||||
* @param {*} res
|
* @param {*} res
|
||||||
* @param {*} action
|
* @param {*} action
|
||||||
*/
|
*/
|
||||||
function handleGlobalEvent(res, action) {
|
function handleGlobalEvent(res: Response, action: any) {
|
||||||
mainWindow.webContents.send("globalEvent", action);
|
mainWindow.webContents.send("globalEvent", action);
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ expressModule.run = function (mainWindow) {
|
|||||||
expressApp.get("/", (req, res) => res.send("Hello World!"));
|
expressApp.get("/", (req, res) => res.send("Hello World!"));
|
||||||
expressApp.get("/current", (req, res) => res.json({ ...mediaInfo, artist: mediaInfo.artists }));
|
expressApp.get("/current", (req, res) => res.json({ ...mediaInfo, artist: mediaInfo.artists }));
|
||||||
expressApp.get("/image", (req, res) => {
|
expressApp.get("/image", (req, res) => {
|
||||||
var stream = fs.createReadStream(mediaInfo.icon);
|
const stream = fs.createReadStream(mediaInfo.icon);
|
||||||
stream.on("open", function () {
|
stream.on("open", function () {
|
||||||
res.set("Content-Type", "image/png");
|
res.set("Content-Type", "image/png");
|
||||||
stream.pipe(res);
|
stream.pipe(res);
|
||||||
@ -50,21 +50,16 @@ expressModule.run = function (mainWindow) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (store.get(settings.api)) {
|
|
||||||
let port = store.get(settings.apiSettings.port);
|
|
||||||
|
|
||||||
expressInstance = expressApp.listen(port, "127.0.0.1", () => {});
|
let port = store.get(settings.apiSettings.port);
|
||||||
expressInstance.on("error", function (e) {
|
|
||||||
let message = e.code;
|
const expressInstance = expressApp.listen(port, "127.0.0.1", () => {});
|
||||||
if (e.code === "EADDRINUSE") {
|
expressInstance.on("error", function (e: { code: string }) {
|
||||||
message = `Port ${port} in use.`;
|
let message = e.code;
|
||||||
}
|
if (e.code === "EADDRINUSE") {
|
||||||
const { dialog } = require("electron");
|
message = `Port ${port} in use.`;
|
||||||
dialog.showErrorBox("Api failed to start.", message);
|
}
|
||||||
});
|
const { dialog } = require("electron");
|
||||||
} else {
|
dialog.showErrorBox("Api failed to start.", message);
|
||||||
expressInstance = undefined;
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = expressModule;
|
|
@ -1,11 +0,0 @@
|
|||||||
const hotkeyjs = require("hotkeys-js");
|
|
||||||
const hotkeys = {};
|
|
||||||
|
|
||||||
hotkeys.add = function(keys, func) {
|
|
||||||
hotkeyjs(keys, function(event, args) {
|
|
||||||
event.preventDefault();
|
|
||||||
func(event, args);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = hotkeys;
|
|
11
src/scripts/hotkeys.ts
Normal file
11
src/scripts/hotkeys.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import hotkeyjs, { HotkeysEvent } from "hotkeys-js";
|
||||||
|
|
||||||
|
export const addHotkey = function (
|
||||||
|
keys: string,
|
||||||
|
func: (event?: KeyboardEvent, args?: HotkeysEvent) => void
|
||||||
|
) {
|
||||||
|
hotkeyjs(keys, function (event, args) {
|
||||||
|
event.preventDefault();
|
||||||
|
func(event, args);
|
||||||
|
});
|
||||||
|
};
|
@ -1,4 +1,4 @@
|
|||||||
const { Menu, app } = require("electron");
|
import { BrowserWindow, Menu, app } from "electron";
|
||||||
const { showSettingsWindow } = require("./settings");
|
const { showSettingsWindow } = require("./settings");
|
||||||
const isMac = process.platform === "darwin";
|
const isMac = process.platform === "darwin";
|
||||||
const { name } = require("./../constants/values");
|
const { name } = require("./../constants/values");
|
||||||
@ -19,9 +19,7 @@ const quitMenuEntry = {
|
|||||||
accelerator: "Control+Q",
|
accelerator: "Control+Q",
|
||||||
};
|
};
|
||||||
|
|
||||||
const menuModule = {};
|
export const getMenu = function (mainWindow: BrowserWindow) {
|
||||||
|
|
||||||
menuModule.getMenu = function (mainWindow) {
|
|
||||||
const toggleWindow = {
|
const toggleWindow = {
|
||||||
label: "Toggle Window",
|
label: "Toggle Window",
|
||||||
click: function () {
|
click: function () {
|
||||||
@ -113,11 +111,9 @@ menuModule.getMenu = function (mainWindow) {
|
|||||||
quitMenuEntry,
|
quitMenuEntry,
|
||||||
];
|
];
|
||||||
|
|
||||||
return Menu.buildFromTemplate(mainMenu);
|
return Menu.buildFromTemplate(mainMenu as any);
|
||||||
};
|
};
|
||||||
|
|
||||||
menuModule.addMenu = function (mainWindow) {
|
export const addMenu = function (mainWindow: BrowserWindow) {
|
||||||
Menu.setApplicationMenu(menuModule.getMenu(mainWindow));
|
Menu.setApplicationMenu(getMenu(mainWindow));
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = menuModule;
|
|
@ -1,5 +1,6 @@
|
|||||||
const Store = require("electron-store");
|
const Store = require("electron-store");
|
||||||
const settings = require("./../constants/settings");
|
|
||||||
|
const settings = require("../constants/settings");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const { BrowserWindow } = require("electron");
|
const { BrowserWindow } = require("electron");
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
const { Tray } = require("electron");
|
import { BrowserWindow, Tray } from "electron";
|
||||||
const { getMenu } = require("./menu");
|
|
||||||
const trayModule = {};
|
|
||||||
let tray;
|
|
||||||
|
|
||||||
trayModule.addTray = function (mainWindow, options = { icon: "" }) {
|
const { getMenu } = require("./menu");
|
||||||
|
|
||||||
|
let tray: Tray;
|
||||||
|
|
||||||
|
export const addTray = function (mainWindow: BrowserWindow, options = { icon: "" }) {
|
||||||
tray = new Tray(options.icon);
|
tray = new Tray(options.icon);
|
||||||
tray.setIgnoreDoubleClickEvents(true);
|
tray.setIgnoreDoubleClickEvents(true);
|
||||||
tray.setToolTip("Tidal-hifi");
|
tray.setToolTip("Tidal-hifi");
|
||||||
@ -25,10 +26,8 @@ trayModule.addTray = function (mainWindow, options = { icon: "" }) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
trayModule.refreshTray = function (mainWindow) {
|
export const refreshTray = function (mainWindow: BrowserWindow) {
|
||||||
if (!tray) {
|
if (!tray) {
|
||||||
trayModule.addTray(mainWindow);
|
addTray(mainWindow);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = trayModule;
|
|
@ -1,11 +0,0 @@
|
|||||||
const windowFunctions = {};
|
|
||||||
|
|
||||||
windowFunctions.setTitle = function(title) {
|
|
||||||
window.document.title = title;
|
|
||||||
};
|
|
||||||
|
|
||||||
windowFunctions.getTitle = function() {
|
|
||||||
return window.document.title;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = windowFunctions;
|
|
7
src/scripts/window-functions.ts
Normal file
7
src/scripts/window-functions.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export const setTitle = function (title: string) {
|
||||||
|
window.document.title = title;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getTitle = function () {
|
||||||
|
return window.document.title;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user