FIX: clean my own mess
This commit is contained in:
parent
37b0747e05
commit
2c165d7148
8 changed files with 50 additions and 30 deletions
2
.github/workflows/desktop-build.yml
vendored
2
.github/workflows/desktop-build.yml
vendored
|
|
@ -50,7 +50,7 @@ jobs:
|
|||
run: npx neu update
|
||||
|
||||
- name: Build application
|
||||
run: npm run build
|
||||
run: npm run build:desktop
|
||||
|
||||
- name: Prepare Release
|
||||
run: |
|
||||
|
|
|
|||
BIN
.gitignore
vendored
BIN
.gitignore
vendored
Binary file not shown.
|
|
@ -4324,6 +4324,7 @@
|
|||
</footer>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/pocketbase@0.21.3/dist/pocketbase.umd.js"></script>
|
||||
<script src="/neutralino.js"></script>
|
||||
<script type="module" src="/js/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
47
js/app.js
47
js/app.js
|
|
@ -1,4 +1,5 @@
|
|||
//js/app.js
|
||||
console.log('[App] Script loaded');
|
||||
import { LosslessAPI } from './api.js';
|
||||
import {
|
||||
apiSettings,
|
||||
|
|
@ -25,7 +26,7 @@ import * as Neutralino from '@neutralinojs/lib';
|
|||
import './smooth-scrolling.js';
|
||||
|
||||
// Assign Neutralino to window for global access
|
||||
if (typeof window !== 'undefined') {
|
||||
if (typeof window !== 'undefined' && window.NL_MODE) {
|
||||
window.Neutralino = Neutralino;
|
||||
}
|
||||
|
||||
|
|
@ -237,6 +238,31 @@ async function disablePwaForAuthGate() {
|
|||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
// Initialize desktop environment (Neutralino)
|
||||
const isDesktop = typeof window !== 'undefined' && (window.NL_MODE || window.location.port === '5050');
|
||||
if (typeof window !== 'undefined' && window.Neutralino) {
|
||||
console.log('[App] Neutralino object detected. Environment:', isDesktop ? 'Desktop' : 'Web');
|
||||
if (isDesktop) {
|
||||
console.log('[App] Initializing Neutralino desktop environment...');
|
||||
try {
|
||||
Neutralino.init();
|
||||
console.log('[App] Neutralino.init() called successfully.');
|
||||
|
||||
// Register events immediately
|
||||
Neutralino.events.on('windowClose', () => {
|
||||
console.log('[App] Window close event triggered.');
|
||||
Neutralino.app.exit();
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('[App] Failed to initialize desktop environment:', error);
|
||||
}
|
||||
} else {
|
||||
console.log('[App] Skipping Neutralino.init() on regular web environment.');
|
||||
}
|
||||
} else {
|
||||
console.log('[App] Neutralino object NOT detected.');
|
||||
}
|
||||
|
||||
const api = new LosslessAPI(apiSettings);
|
||||
|
||||
const audioPlayer = document.getElementById('audio-player');
|
||||
|
|
@ -385,22 +411,9 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
// Initialize tracker
|
||||
initTracker(player);
|
||||
|
||||
// Initialize desktop environment (Neutralino)
|
||||
if (window.Neutralino) {
|
||||
console.log('Initializing Neutralino desktop environment (Lite Mode)...');
|
||||
try {
|
||||
Neutralino.init();
|
||||
|
||||
// Register events immediately
|
||||
Neutralino.events.on('windowClose', () => {
|
||||
Neutralino.app.exit();
|
||||
});
|
||||
|
||||
// Start RPC immediately after init
|
||||
initializeDiscordRPC(player);
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize desktop environment:', error);
|
||||
}
|
||||
if (typeof window !== 'undefined' && window.Neutralino && (window.NL_MODE || window.location.port === '5050')) {
|
||||
console.log('[App] Starting Discord RPC...');
|
||||
initializeDiscordRPC(player);
|
||||
}
|
||||
|
||||
const castBtn = document.getElementById('cast-btn');
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ export function initializeDiscordRPC(player) {
|
|||
if (player.currentTrack) {
|
||||
sendUpdate(player.currentTrack, player.audio.paused);
|
||||
} else {
|
||||
console.log('[DiscordRPC] Sending idling heartbeat...');
|
||||
const idlingData = {
|
||||
details: 'Idling',
|
||||
state: 'Monochrome',
|
||||
|
|
|
|||
|
|
@ -45,4 +45,4 @@
|
|||
}
|
||||
],
|
||||
"nativeAllowList": ["app.exit", "window.*", "extensions.*", "events.*"]
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,8 @@
|
|||
"main": "sw.js",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build && npx neu build",
|
||||
"build": "vite build",
|
||||
"build:desktop": "vite build --mode neutralino && npx neu build && node -e \"const fs = require('fs'); fs.cpSync('extensions', 'dist/Monochrome/extensions', {recursive: true}); fs.copyFileSync('neutralino.config.json', 'dist/Monochrome/neutralino.config.json')\"",
|
||||
"preview": "vite preview",
|
||||
"start": "vite preview",
|
||||
"lint:js": "eslint .",
|
||||
|
|
|
|||
|
|
@ -3,16 +3,19 @@ import { VitePWA } from 'vite-plugin-pwa';
|
|||
import neutralino from 'vite-plugin-neutralino';
|
||||
import authGatePlugin from './vite-plugin-auth-gate.js';
|
||||
|
||||
export default defineConfig({
|
||||
base: './',
|
||||
build: {
|
||||
outDir: 'www',
|
||||
emptyOutDir: true,
|
||||
},
|
||||
plugins: [
|
||||
neutralino(),
|
||||
authGatePlugin(),
|
||||
VitePWA({
|
||||
export default defineConfig(({ mode }) => {
|
||||
const IS_NEUTRALINO = mode === 'neutralino';
|
||||
|
||||
return {
|
||||
base: './',
|
||||
build: {
|
||||
outDir: IS_NEUTRALINO ? 'www' : 'dist',
|
||||
emptyOutDir: IS_NEUTRALINO,
|
||||
},
|
||||
plugins: [
|
||||
IS_NEUTRALINO && neutralino(),
|
||||
authGatePlugin(),
|
||||
VitePWA({
|
||||
registerType: 'prompt',
|
||||
workbox: {
|
||||
globPatterns: ['**/*.{js,css,html,ico,png,svg,json}'],
|
||||
|
|
@ -49,4 +52,5 @@ export default defineConfig({
|
|||
manifest: false, // Use existing public/manifest.json
|
||||
}),
|
||||
],
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue