generated from azures04/Photino-Boilerplate
new commit
This commit is contained in:
parent
fe85d2dcc4
commit
07398a9eac
@ -129,6 +129,24 @@ class Program{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "installer::quit":
|
||||||
|
if (jsonPayload.TryGetProperty("createShortcut", out var createShortcut) && jsonPayload.TryGetProperty("launchAfterExit", out var launchAfterExit)) {
|
||||||
|
try {
|
||||||
|
InstallationFinish installationFinish = jsonPayload.Deserialize<InstallationFinish>(Constants._jsonOptions)!;
|
||||||
|
if (installationFinish.CreateShortcut) {
|
||||||
|
//TO-DO : Fetch executable path from remote
|
||||||
|
// Create a shortcut with it
|
||||||
|
}
|
||||||
|
if (installationFinish.LaunchAfterExit) {
|
||||||
|
//TO-DO : Fetch executable path from remote
|
||||||
|
// Launch it
|
||||||
|
}
|
||||||
|
responsePayload = new { success = true };
|
||||||
|
} catch (Exception) {
|
||||||
|
responsePayload = new { success = false };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var finalResponse = new { requestId, payload = responsePayload };
|
var finalResponse = new { requestId, payload = responsePayload };
|
||||||
|
|||||||
@ -53,8 +53,7 @@ public static class BashUtils {
|
|||||||
public static void OpenUrl(string url) {
|
public static void OpenUrl(string url) {
|
||||||
try {
|
try {
|
||||||
Process.Start(url);
|
Process.Start(url);
|
||||||
}
|
} catch {
|
||||||
catch {
|
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
|
||||||
url = url.Replace("&", "^&");
|
url = url.Replace("&", "^&");
|
||||||
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
|
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
|
||||||
|
|||||||
6
src/main/schemas/Installation.cs
Normal file
6
src/main/schemas/Installation.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace BrikInstaller.Schemas;
|
||||||
|
|
||||||
|
public class InstallationFinish {
|
||||||
|
public bool CreateShortcut { get; set; }
|
||||||
|
public bool LaunchAfterExit { get; set; }
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using BrikInstaller.Utils;
|
||||||
|
|
||||||
namespace BrikInstaller.Services;
|
namespace BrikInstaller.Services;
|
||||||
|
|
||||||
@ -73,4 +74,45 @@ public static class InstallationService {
|
|||||||
}
|
}
|
||||||
return final;
|
return final;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ShortcutService {
|
||||||
|
public static void CreateShortcut(string appName, string targetExePath, bool createDesktop, bool autoStart) {
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
|
||||||
|
CreateWindowsShortcut(appName, targetExePath);
|
||||||
|
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
|
||||||
|
CreateMacShortcut(appName, targetExePath);
|
||||||
|
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
|
||||||
|
CreateLinuxShortcut(appName, targetExePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CreateMacShortcut(string appName, string targetExePath) {
|
||||||
|
string desktopPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Desktop");
|
||||||
|
string shortcutPath = Path.Combine(desktopPath, appName);
|
||||||
|
|
||||||
|
BashUtils.GetCommandOutput($"ln -sf \"{targetExePath}\" \"{shortcutPath}\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CreateWindowsShortcut(string appName, string targetExePath) {
|
||||||
|
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
||||||
|
string shortcutLocation = Path.Combine(desktopPath, $"{appName}.lnk");
|
||||||
|
|
||||||
|
string script = $"$s=(New-Object -ComObject WScript.Shell).CreateShortcut('{shortcutLocation}');$s.TargetPath='{targetExePath}';$s.Save()";
|
||||||
|
Process.Start(new ProcessStartInfo("powershell", $"-Command \"{script}\"") { CreateNoWindow = true });
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CreateLinuxShortcut(string appName, string targetExePath) {
|
||||||
|
string desktopEntry = $@"
|
||||||
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Name={appName}
|
||||||
|
Exec=""{targetExePath}""
|
||||||
|
Terminal=false
|
||||||
|
";
|
||||||
|
string desktopPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Desktop");
|
||||||
|
File.WriteAllText(Path.Combine(desktopPath, $"{appName}.desktop"), desktopEntry);
|
||||||
|
Process.Start("chmod", $"+x \"{Path.Combine(desktopPath, $"{appName}.desktop")}\"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -189,6 +189,15 @@ async function checkInstallationPath(path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function quit() {
|
||||||
|
const finishState = {
|
||||||
|
createShortcut: createShortcut["checked"],
|
||||||
|
launchAfterExit: launchAfterExit["checked"]
|
||||||
|
}
|
||||||
|
console.log(finishState)
|
||||||
|
await system.call("installer::quit", finishState)
|
||||||
|
}
|
||||||
|
|
||||||
onFrameShowed("onboarding", () => {
|
onFrameShowed("onboarding", () => {
|
||||||
const languageDropdown = document.querySelector("details.language")
|
const languageDropdown = document.querySelector("details.language")
|
||||||
if (languageDropdown.getAttribute("value") == null) {
|
if (languageDropdown.getAttribute("value") == null) {
|
||||||
|
|||||||
@ -268,7 +268,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<form>
|
<form>
|
||||||
<div>
|
<div>
|
||||||
<input type="checkbox" name="createShortcut" id="createShortcut" value="createShortcut" checked>
|
<input type="checkbox" name="createShortcut" id="createShortcut" value="createShortcut">
|
||||||
<label for="createShortcut" data-i18n="create_shortcut">createShortcut</label>
|
<label for="createShortcut" data-i18n="create_shortcut">createShortcut</label>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@ -277,7 +277,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<section class="buttons">
|
<section class="buttons">
|
||||||
<button class="primary" data-i18n="exit" onclick="window.close()"></button>
|
<button class="primary" data-i18n="exit" onclick="quit()"></button>
|
||||||
</section>
|
</section>
|
||||||
</article>
|
</article>
|
||||||
</aside>
|
</aside>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user