mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-14 14:17:25 -05:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2de96960d9 | |||
| 8fd8be0d05 | |||
| e3283fff45 | |||
| 64ed5981be |
37
main.js
37
main.js
@@ -34,6 +34,7 @@ debugLog("--- Node.js Process Started ---");
|
|||||||
let serviceManager;
|
let serviceManager;
|
||||||
let expressApp;
|
let expressApp;
|
||||||
let expressServer;
|
let expressServer;
|
||||||
|
let updateDecisionHandler = null;
|
||||||
|
|
||||||
debugLog(`AppData Dir: ${APPDATA_DIR}`);
|
debugLog(`AppData Dir: ${APPDATA_DIR}`);
|
||||||
|
|
||||||
@@ -84,12 +85,25 @@ cmdApp.use((req, res, next) => {
|
|||||||
if (req.method === 'OPTIONS') return res.sendStatus(200);
|
if (req.method === 'OPTIONS') return res.sendStatus(200);
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
cmdApp.all('/update/:choice', (req, res) => {
|
||||||
|
const c = String(req.params.choice).toLowerCase();
|
||||||
|
if (updateDecisionHandler) {
|
||||||
|
if (c === 'yes' || c === 'true' || c === 'install') updateDecisionHandler(true);
|
||||||
|
if (c === 'no' || c === 'false' || c === 'skip') updateDecisionHandler(false);
|
||||||
|
}
|
||||||
|
res.sendStatus(200);
|
||||||
|
});
|
||||||
cmdApp.get('/__tauri_cmd/:cmd', (req, res) => {
|
cmdApp.get('/__tauri_cmd/:cmd', (req, res) => {
|
||||||
|
const cmd = req.params.cmd;
|
||||||
|
if (updateDecisionHandler) {
|
||||||
|
if (cmd === 'update_yes' || cmd === 'update_install') updateDecisionHandler(true);
|
||||||
|
if (cmd === 'update_no' || cmd === 'update_skip') updateDecisionHandler(false);
|
||||||
|
}
|
||||||
debugLog(`[CMD-SERVER:4892] Command received: ${req.params.cmd} (window: ${req.query.window || 'main'})`);
|
debugLog(`[CMD-SERVER:4892] 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 });
|
sendToTauri('tauri-cmd', { cmd: req.params.cmd, url: req.query.url, window: req.query.window });
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
});
|
});
|
||||||
cmdApp.listen(4892, '127.0.0.1', () => debugLog("[CMD-SERVER] Dedicated command server listening on 127.0.0.1:4892"));
|
cmdApp.listen(4892, () => debugLog("[CMD-SERVER] Dedicated command server listening on port 4892"));
|
||||||
|
|
||||||
process.stdin.resume();
|
process.stdin.resume();
|
||||||
process.stdin.on('end', () => {
|
process.stdin.on('end', () => {
|
||||||
@@ -324,22 +338,34 @@ async function start() {
|
|||||||
|
|
||||||
const tempApp = express();
|
const tempApp = express();
|
||||||
let userDecision = null;
|
let userDecision = null;
|
||||||
|
updateDecisionHandler = (val) => { userDecision = val; };
|
||||||
|
|
||||||
tempApp.use((req, res, next) => {
|
tempApp.use((req, res, next) => {
|
||||||
res.header('Access-Control-Allow-Origin', '*');
|
res.header('Access-Control-Allow-Origin', '*');
|
||||||
res.header('Access-Control-Allow-Methods', 'GET,POST,OPTIONS');
|
res.header('Access-Control-Allow-Methods', 'GET,POST,OPTIONS');
|
||||||
res.header('Access-Control-Allow-Headers', '*');
|
res.header('Access-Control-Allow-Headers', '*');
|
||||||
res.header('Connection', 'close');
|
|
||||||
if (req.method === 'OPTIONS') return res.sendStatus(200);
|
if (req.method === 'OPTIONS') return res.sendStatus(200);
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
tempApp.get('/update/info', (req, res) => {
|
tempApp.get('/update/info', (req, res) => {
|
||||||
res.json({ available: true, current: localVersion, latest: release.version });
|
res.json({ available: true, current: localVersion, latest: release.version });
|
||||||
});
|
});
|
||||||
tempApp.post('/update/yes', (req, res) => { userDecision = true; res.sendStatus(200); });
|
const handleYes = (req, res) => { userDecision = true; res.sendStatus(200); };
|
||||||
tempApp.post('/update/no', (req, res) => { userDecision = false; res.sendStatus(200); });
|
const handleNo = (req, res) => { userDecision = false; res.sendStatus(200); };
|
||||||
|
|
||||||
|
tempApp.all('/update/yes', handleYes);
|
||||||
|
tempApp.all('/update/install', handleYes);
|
||||||
|
tempApp.all('/update/no', handleNo);
|
||||||
|
tempApp.all('/update/skip', handleNo);
|
||||||
|
tempApp.all('/update/:choice', (req, res) => {
|
||||||
|
const c = String(req.params.choice || '').toLowerCase();
|
||||||
|
if (c === 'yes' || c === 'install' || c === 'true') userDecision = true;
|
||||||
|
if (c === 'no' || c === 'skip' || c === 'false') userDecision = false;
|
||||||
|
res.sendStatus(200);
|
||||||
|
});
|
||||||
|
|
||||||
const tempServer = await new Promise((resolve) => {
|
const tempServer = await new Promise((resolve) => {
|
||||||
const s = tempApp.listen(4891, '127.0.0.1', () => resolve(s));
|
const s = tempApp.listen(4891, () => resolve(s));
|
||||||
s.on('error', (err) => {
|
s.on('error', (err) => {
|
||||||
debugLog(`Update server bind error: ${err.message}`);
|
debugLog(`Update server bind error: ${err.message}`);
|
||||||
resolve(null);
|
resolve(null);
|
||||||
@@ -358,6 +384,7 @@ async function start() {
|
|||||||
await new Promise(r => setTimeout(r, 25));
|
await new Promise(r => setTimeout(r, 25));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateDecisionHandler = null;
|
||||||
if (tempServer) {
|
if (tempServer) {
|
||||||
tempServer.close();
|
tempServer.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vyla-home",
|
"name": "vyla-home",
|
||||||
"version": "1.1.34",
|
"version": "1.1.36",
|
||||||
"description": "Vyla Home Desktop App Launcher",
|
"description": "Vyla Home Desktop App Launcher",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
"@tauri-apps/plugin-opener": "^2.0.0",
|
"@tauri-apps/plugin-opener": "^2.0.0",
|
||||||
"@tauri-apps/plugin-process": "^2.0.0",
|
"@tauri-apps/plugin-process": "^2.0.0",
|
||||||
"@tauri-apps/plugin-shell": "^2.0.0",
|
"@tauri-apps/plugin-shell": "^2.0.0",
|
||||||
"@vyla-entertainment/sdk": "^1.11.0",
|
"@vyla-entertainment/sdk": "^1.12.0",
|
||||||
"adm-zip": "^0.6.0",
|
"adm-zip": "^0.6.0",
|
||||||
"express": "^4.19.2"
|
"express": "^4.19.2"
|
||||||
},
|
},
|
||||||
|
|||||||
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
@@ -4238,7 +4238,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vyla-home"
|
name = "vyla-home"
|
||||||
version = "1.1.34"
|
version = "1.1.36"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"objc2 0.5.2",
|
"objc2 0.5.2",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "vyla-home"
|
name = "vyla-home"
|
||||||
version = "1.1.34"
|
version = "1.1.36"
|
||||||
description = "Vyla Home Desktop App Launcher"
|
description = "Vyla Home Desktop App Launcher"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|||||||
@@ -195,7 +195,34 @@ fn resolve_script_and_root(app: &tauri::App) -> (String, String) {
|
|||||||
(clean_path(&candidate), clean_path(&dir))
|
(clean_path(&candidate), clean_path(&dir))
|
||||||
}
|
}
|
||||||
|
|
||||||
const LINK_HANDLER_SCRIPT: &str = r##"
|
const LINK_HANDLER_SCRIPT: &str =
|
||||||
|
r##"
|
||||||
|
|
||||||
|
window.vylaHome = {
|
||||||
|
sendUpdateChoice: function(choice) {
|
||||||
|
var action = choice ? 'yes' : 'no';
|
||||||
|
[4891, 4892].forEach(function(port) {
|
||||||
|
['127.0.0.1', 'localhost'].forEach(function(host) {
|
||||||
|
fetch('http://' + host + ':' + port + '/update/' + action, { method: 'POST' }).catch(function() {});
|
||||||
|
fetch('http://' + host + ':' + port + '/update/' + action, { method: 'GET' }).catch(function() {});
|
||||||
|
fetch('http://' + host + ':' + port + '/__tauri_cmd/update_' + action, { method: 'GET' }).catch(function() {});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener('click', function(e) {
|
||||||
|
var el = e.target.closest('button, a, .btn');
|
||||||
|
if (!el) return;
|
||||||
|
var text = (el.innerText || el.textContent || '').toLowerCase();
|
||||||
|
var id = (el.id || '').toLowerCase();
|
||||||
|
if (id.includes('install') || id.includes('update-yes') || text.includes('install update')) {
|
||||||
|
window.vylaHome.sendUpdateChoice(true);
|
||||||
|
} else if (id.includes('skip') || id.includes('update-no') || text.includes('skip')) {
|
||||||
|
window.vylaHome.sendUpdateChoice(false);
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
function doInvoke(cmd, args) {
|
function doInvoke(cmd, args) {
|
||||||
if (window.__TAURI__ && window.__TAURI__.core) {
|
if (window.__TAURI__ && window.__TAURI__.core) {
|
||||||
return window.__TAURI__.core.invoke(cmd, args || {});
|
return window.__TAURI__.core.invoke(cmd, args || {});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "Vyla Home",
|
"productName": "Vyla Home",
|
||||||
"version": "1.1.34",
|
"version": "1.1.36",
|
||||||
"identifier": "com.vyla.home",
|
"identifier": "com.vyla.home",
|
||||||
"build": {
|
"build": {
|
||||||
"frontendDist": "../ui"
|
"frontendDist": "../ui"
|
||||||
|
|||||||
Reference in New Issue
Block a user