mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-12 21:27:22 -05:00
fixed logo, updated sdk , changed frontend to support server.js n it runs it well
This commit is contained in:
69
main.js
69
main.js
@@ -434,58 +434,33 @@ async function start() {
|
||||
sendToTauri('status', { message: 'Loading encrypted credentials...' });
|
||||
serviceManager.credentialManager.loadCredentials();
|
||||
|
||||
sendToTauri('status', { message: 'Starting background services (player)...' });
|
||||
sendToTauri('status', { message: 'Installing dependencies...' });
|
||||
const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
||||
const frontendDir = path.join(APPDATA_DIR, 'frontend');
|
||||
if (fs.existsSync(path.join(frontendDir, 'package.json'))) {
|
||||
const { spawnSync } = require('child_process');
|
||||
spawnSync(npmCmd, ['install'], {
|
||||
cwd: frontendDir,
|
||||
stdio: 'ignore',
|
||||
windowsHide: true,
|
||||
shell: process.platform === 'win32'
|
||||
});
|
||||
}
|
||||
|
||||
sendToTauri('status', { message: 'Starting services (player, frontend)...' });
|
||||
await serviceManager.startServices([
|
||||
{ name: 'player', relativeDir: 'player', startScript: 'server.js' }
|
||||
{ name: 'player', relativeDir: 'player', startScript: 'server.js' },
|
||||
{ name: 'frontend', relativeDir: 'frontend', startScript: 'server.js' }
|
||||
]);
|
||||
debugLog("Backend services spawn requested.");
|
||||
|
||||
sendToTauri('status', { message: 'Waiting for microservices to bind port 3000...' });
|
||||
await serviceManager.waitForPorts([3000]);
|
||||
debugLog("Port 3000 is ready.");
|
||||
sendToTauri('status', { message: 'Waiting for microservices to bind...' });
|
||||
await serviceManager.waitForPorts([3000, 4890]);
|
||||
debugLog("Ports 3000 and 4890 are ready.");
|
||||
|
||||
sendToTauri('status', { message: 'Binding UI server on port 4890...' });
|
||||
const frontendDir = path.join(APPDATA_DIR, 'frontend');
|
||||
expressApp = express();
|
||||
expressApp.use((req, res, next) => {
|
||||
res.header('Access-Control-Allow-Origin', '*');
|
||||
res.header('Access-Control-Allow-Methods', 'GET,POST,OPTIONS');
|
||||
res.header('Access-Control-Allow-Headers', '*');
|
||||
if (req.method === 'OPTIONS') return res.sendStatus(200);
|
||||
next();
|
||||
});
|
||||
expressApp.get('/__tauri_cmd/:cmd', (req, res) => {
|
||||
debugLog(`[FRONTEND-SERVER:4890] Command received: ${req.params.cmd} (window: ${req.query.window || 'main'})`);
|
||||
sendToTauri('tauri-cmd', { cmd: req.params.cmd, url: req.query.url, window: req.query.window });
|
||||
res.sendStatus(200);
|
||||
});
|
||||
|
||||
expressApp.use(sameTabNavMiddleware(frontendDir));
|
||||
expressApp.use(express.static(frontendDir, {
|
||||
etag: false,
|
||||
setHeaders: (res) => {
|
||||
res.set('Cache-Control', 'no-store, no-cache, must-revalidate, private');
|
||||
}
|
||||
}));
|
||||
expressApp.use(express.static(path.join(frontendDir, 'src'), {
|
||||
etag: false,
|
||||
setHeaders: (res) => {
|
||||
res.set('Cache-Control', 'no-store, no-cache, must-revalidate, private');
|
||||
}
|
||||
}));
|
||||
expressApp.get('*', (req, res) => {
|
||||
res.set('Cache-Control', 'no-store, no-cache, must-revalidate, private');
|
||||
res.sendFile(path.join(frontendDir, 'index.html'));
|
||||
});
|
||||
|
||||
const FRONTEND_PORT = 4890;
|
||||
expressApp.use('/build', express.static(path.join(__dirname, 'build')));
|
||||
|
||||
expressServer = expressApp.listen(FRONTEND_PORT, '127.0.0.1', () => {
|
||||
sendToTauri('status', { message: 'All backend services running and healthy.' });
|
||||
debugLog("Frontend Express running on 4890. Sending READY to Tauri.");
|
||||
sendToTauri('ready', { url: `http://127.0.0.1:${FRONTEND_PORT}` });
|
||||
});
|
||||
sendToTauri('status', { message: 'All backend services running and healthy.' });
|
||||
debugLog("Sending READY to Tauri.");
|
||||
sendToTauri('ready', { url: 'http://127.0.0.1:4890' });
|
||||
|
||||
} catch (error) {
|
||||
debugLog(`Fatal Start Error: ${error.message}`);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"@tauri-apps/plugin-opener": "^2.7.0",
|
||||
"@tauri-apps/plugin-process": "^2.4.0",
|
||||
"@tauri-apps/plugin-shell": "^2.4.0",
|
||||
"@vyla-entertainment/sdk": "^1.16.0",
|
||||
"@vyla-entertainment/sdk": "^1.18.0",
|
||||
"adm-zip": "^0.6.0",
|
||||
"express": "^4.19.2"
|
||||
},
|
||||
@@ -54,4 +54,4 @@
|
||||
"installerHeaderIcon": "build/icon.ico"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ class Patcher {
|
||||
|
||||
verifyExtraction() {
|
||||
const requiredFiles = [
|
||||
'frontend/index.html',
|
||||
'frontend/server.js',
|
||||
'player/server.js'
|
||||
];
|
||||
|
||||
|
||||
@@ -47,8 +47,14 @@ class ServiceManager {
|
||||
this.credentialManager.setCredential('player', 'TOKEN_SECRET', tokenSecret);
|
||||
}
|
||||
|
||||
const defaultPorts = {
|
||||
player: 3000,
|
||||
frontend: 4890
|
||||
};
|
||||
|
||||
const env = {
|
||||
...process.env,
|
||||
PORT: (this.envConfig[name] && this.envConfig[name].PORT) || defaultPorts[name] || process.env.PORT || 3000,
|
||||
TOKEN_SECRET: tokenSecret,
|
||||
...(this.envConfig[name] || {}),
|
||||
...(this.credentialManager.getServiceCredentials(name) || {})
|
||||
|
||||
@@ -433,7 +433,7 @@ const LINK_HANDLER_SCRIPT: &str =
|
||||
nav.id = 'vyla-floating-nav';
|
||||
nav.innerHTML = `
|
||||
<div class="vyla-nav-logo-wrap" title="Go to Home">
|
||||
<img src="https://gitlab.com/vyla-entertainment/documentation/-/raw/main/assets/images/logo.png" alt="Logo" />
|
||||
<img src="https://gitlab.com/vyla-entertainment/go/-/raw/main/assets/logos/white_logo.png" alt="Logo" />
|
||||
</div>
|
||||
<div class="vyla-nav-links">
|
||||
<button class="vyla-nav-btn" id="vyla-btn-discord" title="Discord Community">
|
||||
|
||||
Reference in New Issue
Block a user