From d6ad1ac3e8d313f61485cdf1d8bbed1e073ada5e Mon Sep 17 00:00:00 2001 From: iwate Date: Thu, 20 Feb 2020 22:59:34 +0900 Subject: [PATCH] setup autoupdate --- .../Controllers/DefaultController.cs | 9 ++- src/Aiplugs.PoshApp/ElectronIpc.cs | 62 +++++++++++++++++-- src/Aiplugs.PoshApp/Startup.cs | 5 +- src/Aiplugs.PoshApp/Views/Shared/App.cshtml | 52 ++-------------- .../Shared/Components/ActivationNotice.cshtml | 57 +++++++++++++++++ src/Aiplugs.PoshApp/Views/Shared/Index.cshtml | 2 + .../Views/Shared/Repositories/Index.cshtml | 3 + .../Views/Shared/Settings/Nav.cshtml | 7 ++- .../Views/Shared/Settings/Version.cshtml | 10 +++ src/Aiplugs.PoshApp/electron.manifest.json | 17 +++-- src/Aiplugs.PoshApp/wwwroot/js/router.js | 1 + 11 files changed, 161 insertions(+), 64 deletions(-) create mode 100644 src/Aiplugs.PoshApp/Views/Shared/Components/ActivationNotice.cshtml create mode 100644 src/Aiplugs.PoshApp/Views/Shared/Settings/Version.cshtml diff --git a/src/Aiplugs.PoshApp/Controllers/DefaultController.cs b/src/Aiplugs.PoshApp/Controllers/DefaultController.cs index 2ef536a..a84c874 100644 --- a/src/Aiplugs.PoshApp/Controllers/DefaultController.cs +++ b/src/Aiplugs.PoshApp/Controllers/DefaultController.cs @@ -1,13 +1,20 @@ using System.Diagnostics; using Microsoft.AspNetCore.Mvc; using Aiplugs.PoshApp.ViewModels; +using System.Threading.Tasks; +using ElectronNET.API; namespace Aiplugs.PoshApp.Controllers { public class DefaultController : Controller { - public IActionResult Index() + public async Task Index() { + if (HybridSupport.IsElectronActive) + { + ViewBag.Version = await Electron.App.GetVersionAsync(); + } + return View(); } diff --git a/src/Aiplugs.PoshApp/ElectronIpc.cs b/src/Aiplugs.PoshApp/ElectronIpc.cs index 1dda960..02555d3 100644 --- a/src/Aiplugs.PoshApp/ElectronIpc.cs +++ b/src/Aiplugs.PoshApp/ElectronIpc.cs @@ -8,26 +8,75 @@ public class ElectronIpc { public static void Setup() { - Electron.IpcMain.On("select-directory", async (args) => { + var menu = new MenuItem[] { + new MenuItem { + Label = "View", + Submenu = new MenuItem[] { + new MenuItem + { + Label = "Reload", + Accelerator = "CmdOrCtrl+R", + Click = () => + { + // on reload, start fresh and close any old + // open secondary windows + Electron.WindowManager.BrowserWindows.ToList().ForEach(browserWindow => { + if(browserWindow.Id != 1) + { + browserWindow.Close(); + } + else + { + browserWindow.Reload(); + } + }); + } + }, + new MenuItem + { + Label = "Open Developer Tools", + Accelerator = "CmdOrCtrl+I", + Click = () => Electron.WindowManager.BrowserWindows.First().WebContents.OpenDevTools() + } + } + }, + new MenuItem { + Label = "Help", + Role = MenuRole.help, + Submenu = new MenuItem[] { + new MenuItem + { + Label = "Learn More", + Click = async () => await Electron.Shell.OpenExternalAsync("https://github.com/aiplugs/poshapp") + } + } + } + }; + + Electron.Menu.SetApplicationMenu(menu); + + Electron.IpcMain.On("select-directory", async (args) => + { var mainWindow = Electron.WindowManager.BrowserWindows.First(); var options = new OpenDialogOptions { Properties = new OpenDialogProperty[] { OpenDialogProperty.openDirectory - } + } }; string[] dirs = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options); Electron.IpcMain.Send(mainWindow, "select-directory-reply", dirs, args); }); - Electron.IpcMain.On("select-file", async (args) => { + Electron.IpcMain.On("select-file", async (args) => + { var mainWindow = Electron.WindowManager.BrowserWindows.First(); var options = new OpenDialogOptions { Properties = new OpenDialogProperty[] { OpenDialogProperty.openFile, - } + } }; string[] dirs = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options); @@ -43,6 +92,11 @@ public static void Setup() { Electron.Clipboard.WriteText(text.ToString()); }); + + Electron.IpcMain.On("check-update", async (args) => + { + await Electron.AutoUpdater.CheckForUpdatesAndNotifyAsync(); + }); } } } diff --git a/src/Aiplugs.PoshApp/Startup.cs b/src/Aiplugs.PoshApp/Startup.cs index 3f08a30..f3b49a6 100644 --- a/src/Aiplugs.PoshApp/Startup.cs +++ b/src/Aiplugs.PoshApp/Startup.cs @@ -76,14 +76,13 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) } public async void ElectronBootstrap() { - var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions + await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { + Title = "POSH App", Width = 1152, Height = 864, Show = true, }); - - browserWindow.SetTitle("POSH App"); } } } diff --git a/src/Aiplugs.PoshApp/Views/Shared/App.cshtml b/src/Aiplugs.PoshApp/Views/Shared/App.cshtml index 61ce97b..d51f595 100644 --- a/src/Aiplugs.PoshApp/Views/Shared/App.cshtml +++ b/src/Aiplugs.PoshApp/Views/Shared/App.cshtml @@ -46,60 +46,16 @@ - - - FREE Plan limit exceeded - - - - $0.00 - forever - - - $1.49 / month・machine - - - - -
    -
  • 2 repositories
  • -
  • 10 scripts / repository
  • -
-
- -
    -
  • Unlimited repositories
  • -
  • Unlimites scripts
  • -
-
-
-
- - - - No thank you - Activate - -
-
+ \ No newline at end of file diff --git a/src/Aiplugs.PoshApp/Views/Shared/Components/ActivationNotice.cshtml b/src/Aiplugs.PoshApp/Views/Shared/Components/ActivationNotice.cshtml new file mode 100644 index 0000000..4bb6a12 --- /dev/null +++ b/src/Aiplugs.PoshApp/Views/Shared/Components/ActivationNotice.cshtml @@ -0,0 +1,57 @@ + + \ No newline at end of file diff --git a/src/Aiplugs.PoshApp/Views/Shared/Index.cshtml b/src/Aiplugs.PoshApp/Views/Shared/Index.cshtml index 4ff9839..ff1bd3f 100644 --- a/src/Aiplugs.PoshApp/Views/Shared/Index.cshtml +++ b/src/Aiplugs.PoshApp/Views/Shared/Index.cshtml @@ -24,6 +24,7 @@ + @@ -37,6 +38,7 @@ + diff --git a/src/Aiplugs.PoshApp/Views/Shared/Repositories/Index.cshtml b/src/Aiplugs.PoshApp/Views/Shared/Repositories/Index.cshtml index 54aabdc..537ae03 100644 --- a/src/Aiplugs.PoshApp/Views/Shared/Repositories/Index.cshtml +++ b/src/Aiplugs.PoshApp/Views/Shared/Repositories/Index.cshtml @@ -96,6 +96,9 @@ this.$signalr.on('GitLogNotFound', name => { if (this.$route.params.id == name) { this.items.splice(0); + this.status.splice(0); + this.origin = null; + this.local = null; this.message = 'This repository have not initialized git.' } }) diff --git a/src/Aiplugs.PoshApp/Views/Shared/Settings/Nav.cshtml b/src/Aiplugs.PoshApp/Views/Shared/Settings/Nav.cshtml index 78750fa..49fd3fd 100644 --- a/src/Aiplugs.PoshApp/Views/Shared/Settings/Nav.cshtml +++ b/src/Aiplugs.PoshApp/Views/Shared/Settings/Nav.cshtml @@ -6,6 +6,11 @@ Activation + + + Version + + @@ -19,8 +24,6 @@ computed: { }, methods: { - }, - async mounted() { } }) \ No newline at end of file diff --git a/src/Aiplugs.PoshApp/Views/Shared/Settings/Version.cshtml b/src/Aiplugs.PoshApp/Views/Shared/Settings/Version.cshtml new file mode 100644 index 0000000..0045418 --- /dev/null +++ b/src/Aiplugs.PoshApp/Views/Shared/Settings/Version.cshtml @@ -0,0 +1,10 @@ + + \ No newline at end of file diff --git a/src/Aiplugs.PoshApp/electron.manifest.json b/src/Aiplugs.PoshApp/electron.manifest.json index 8fe3dd9..72f9c7c 100644 --- a/src/Aiplugs.PoshApp/electron.manifest.json +++ b/src/Aiplugs.PoshApp/electron.manifest.json @@ -3,28 +3,33 @@ "splashscreen": { "imageFile": "" }, - "singleInstance": false, + "singleInstance": true, "build": { - "appId": "com.Aiplugs.PoshApp.app", - "productName": "Aiplugs.PoshApp", + "appId": "com.aiplugs.poshapp", + "productName": "POSH App", "copyright": "Copyright © 2019", - "buildVersion": "1.0.0", + "buildVersion": "0.9.7", "compression": "maximum", "directories": { "output": "../../../bin/Desktop" }, + "publish": [{ + "provider": "github", + "owner": "aiplugs", + "repo": "poshapp" + }], "extraResources": [ { "from": "./bin", "to": "bin", - "filter": ["**/*"] + "filter": [ "**/*" ] } ], "files": [ { "from": "./ElectronHostHook/node_modules", "to": "ElectronHostHook/node_modules", - "filter": ["**/*"] + "filter": [ "**/*" ] }, "**/*" ] diff --git a/src/Aiplugs.PoshApp/wwwroot/js/router.js b/src/Aiplugs.PoshApp/wwwroot/js/router.js index 5b742cf..ae71f78 100644 --- a/src/Aiplugs.PoshApp/wwwroot/js/router.js +++ b/src/Aiplugs.PoshApp/wwwroot/js/router.js @@ -9,5 +9,6 @@ export default new VueRouter({ { path: '/repositories/:id', components: { default: Vue.component('Repository'), nav: Vue.component('RepositoryNav') } }, { path: '/settings/', components: { nav: Vue.component('SettingsNav') } }, { path: '/settings/activation', components: { default: Vue.component('Activation'), nav: Vue.component('SettingsNav') } }, + { path: '/settings/version', components: { default: Vue.component('Version'), nav: Vue.component('SettingsNav') } }, ] }) \ No newline at end of file