mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-08-11 10:39:42 +00:00
implement notification bridge
This commit is contained in:
@@ -31,6 +31,7 @@ namespace ElectronNET.API
|
||||
};
|
||||
|
||||
socket.Emit("createBrowserWindow", JObject.FromObject(browserWindowOptions, _jsonSerializer));
|
||||
socket.Emit("createNotification");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
8
ElectronNET.API/Entities/NotificationOptions.cs
Normal file
8
ElectronNET.API/Entities/NotificationOptions.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace ElectronNET.API.Entities
|
||||
{
|
||||
public class NotificationOptions
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Body { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
const { app, BrowserWindow, Notification } = require('electron');
|
||||
const io = require('socket.io')(3000);
|
||||
const path = require('path');
|
||||
|
||||
@@ -18,7 +18,7 @@ app.on('ready', () => {
|
||||
});
|
||||
|
||||
io.on('connection', (socket) => {
|
||||
console.log('a user connected');
|
||||
console.log('ASP.NET Core Application connected...');
|
||||
|
||||
socket.on('createBrowserWindow', (options) => {
|
||||
console.log(options);
|
||||
@@ -32,5 +32,10 @@ io.on('connection', (socket) => {
|
||||
apiProcess = null;
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('createNotification', (options) => {
|
||||
const notification = new Notification(options);
|
||||
notification.show();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
16
ElectronNET.WebApp/Controllers/HomeController.cs
Normal file
16
ElectronNET.WebApp/Controllers/HomeController.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ElectronNET.WebApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,13 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
39
ElectronNET.WebApp/ScaffoldingReadMe.txt
Normal file
39
ElectronNET.WebApp/ScaffoldingReadMe.txt
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
ASP.NET MVC core dependencies have been added to the project.
|
||||
(These dependencies include packages required to enable scaffolding)
|
||||
|
||||
However you may still need to do make changes to your project.
|
||||
|
||||
1. Suggested changes to Startup class:
|
||||
1.1 Add a constructor:
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
1.2 Add MVC services:
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// Add framework services.
|
||||
services.AddMvc();
|
||||
}
|
||||
|
||||
1.3 Configure web app to use use Configuration and use MVC routing:
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute(
|
||||
name: "default",
|
||||
template: "{controller=Home}/{action=Index}/{id?}");
|
||||
});
|
||||
}
|
||||
@@ -13,7 +13,7 @@ namespace ElectronNET.WebApp
|
||||
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
//services.AddMvc();
|
||||
services.AddMvc();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
@@ -26,9 +26,13 @@ namespace ElectronNET.WebApp
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.Run(async (context) =>
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
await context.Response.WriteAsync("Hello World!");
|
||||
routes.MapRoute(
|
||||
name: "default",
|
||||
template: "{controller=Home}/{action=Index}/{id?}");
|
||||
});
|
||||
|
||||
var electronApp = new App(800, 600, true);
|
||||
|
||||
11
ElectronNET.WebApp/Views/Home/Index.cshtml
Normal file
11
ElectronNET.WebApp/Views/Home/Index.cshtml
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>Home</title>
|
||||
</head>
|
||||
<body>
|
||||
Hello from MVC!
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user