mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-08-13 03:29:37 +00:00
fix migration problems
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<PackageOutputPath>..\artifacts</PackageOutputPath>
|
||||
<PackageId>ElectronNET.API</PackageId>
|
||||
@@ -29,19 +29,18 @@ This package contains the API to access the "native" electron API.</Description>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>bin\Debug\netcoreapp2.0\ElectronNET.API.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="EngineIoClientDotNet" Version="1.0.7.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.0.0" />
|
||||
<PackageReference Include="SocketIoClientDotNet" Version="1.0.7.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(OS)' == 'Windows_NT'">
|
||||
<Exec Command="$(ProjectDir)devCleanup.cmd" IgnoreExitCode="true" />
|
||||
</Target>
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(OS)' != 'Windows_NT'">
|
||||
<Exec Command="$(ProjectDir)devCleanup.sh" IgnoreExitCode="true" />
|
||||
</Target>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.1.1" />
|
||||
<PackageReference Include="SocketIoClientDotNet" Version="1.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
const { app } = require('electron');
|
||||
// yf add
|
||||
const { BrowserWindow, dialog, shell } = require('electron')
|
||||
|
||||
const { BrowserWindow, dialog, shell } = require('electron');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const process = require('child_process').spawn;
|
||||
@@ -9,45 +7,70 @@ const portfinder = require('detect-port');
|
||||
let io, browserWindows, ipc, apiProcess, loadURL;
|
||||
let appApi, menu, dialogApi, notification, tray, webContents;
|
||||
let globalShortcut, shellApi, screen, clipboard;
|
||||
let splashScreen, mainWindowId;
|
||||
|
||||
// yf add
|
||||
let loadingWindow;
|
||||
let mainWindowId;
|
||||
let countDownInterval;
|
||||
|
||||
// yf add
|
||||
const manifestJsonFile = require("./bin/electron.manifest.json");
|
||||
const manifestJsonFile = require('./bin/electron.manifest.json');
|
||||
if (manifestJsonFile.singleInstance) {
|
||||
const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
|
||||
mainWindowId && BrowserWindow.fromId(mainWindowId) && BrowserWindow.fromId(mainWindowId).show();
|
||||
});
|
||||
|
||||
if (shouldQuit) {
|
||||
app.quit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
app.on('ready', () => {
|
||||
|
||||
// yf add
|
||||
startLoadingWindow();
|
||||
if (isSplashScreenEnabled()) {
|
||||
startSplashScreen();
|
||||
}
|
||||
|
||||
portfinder(8000, (error, port) => {
|
||||
startSocketApiBridge(port);
|
||||
});
|
||||
});
|
||||
|
||||
function isSplashScreenEnabled() {
|
||||
return Boolean(manifestJsonFile.loadingUrl);
|
||||
}
|
||||
|
||||
function startSplashScreen() {
|
||||
let loadingUrl = manifestJsonFile.loadingUrl;
|
||||
let icon = manifestJsonFile.icon;
|
||||
|
||||
if (loadingUrl) {
|
||||
splashScreen = new BrowserWindow({
|
||||
width: manifestJsonFile.width,
|
||||
height: manifestJsonFile.height,
|
||||
transparent: true,
|
||||
frame: false,
|
||||
show: false,
|
||||
icon: path.join(__dirname, icon)
|
||||
});
|
||||
|
||||
if (manifestJsonFile.devTools) {
|
||||
splashScreen.webContents.openDevTools();
|
||||
}
|
||||
|
||||
splashScreen.loadURL(loadingUrl);
|
||||
splashScreen.once('ready-to-show', () => {
|
||||
splashScreen.show();
|
||||
});
|
||||
|
||||
splashScreen.on('closed', () => {
|
||||
splashScreen = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function startSocketApiBridge(port) {
|
||||
io = require('socket.io')(port);
|
||||
|
||||
// yf add
|
||||
startAspCoreBackend(port);
|
||||
|
||||
io.on('connection', (socket) => {
|
||||
|
||||
global.elesocket = socket;
|
||||
global.elesocket.setMaxListeners(0);
|
||||
console.log('ASP.NET Core Application connected...', 'global.elesocket', global.elesocket.id, new Date());
|
||||
global['electronsocket'] = socket;
|
||||
global['electronsocket'].setMaxListeners(0);
|
||||
console.log('ASP.NET Core Application connected...', 'global.electronsocket', global['electronsocket'].id, new Date());
|
||||
|
||||
appApi = require('./api/app')(socket, app);
|
||||
browserWindows = require('./api/browserWindows')(socket);
|
||||
@@ -61,6 +84,10 @@ function startSocketApiBridge(port) {
|
||||
shellApi = require('./api/shell')(socket);
|
||||
screen = require('./api/screen')(socket);
|
||||
clipboard = require('./api/clipboard')(socket);
|
||||
|
||||
if (splashScreen && !splashScreen.isDestroyed()) {
|
||||
splashScreen.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -68,12 +95,10 @@ function startAspCoreBackend(electronPort) {
|
||||
portfinder(8000, (error, electronWebPort) => {
|
||||
loadURL = `http://localhost:${electronWebPort}`
|
||||
const parameters = [`/electronPort=${electronPort}`, `/electronWebPort=${electronWebPort}`];
|
||||
let binaryFile = manifestJsonFile.executable;
|
||||
|
||||
const manifestFile = require("./bin/electron.manifest.json");
|
||||
let binaryFile = manifestFile.executable;
|
||||
|
||||
const os = require("os");
|
||||
if (os.platform() === "win32") {
|
||||
const os = require('os');
|
||||
if (os.platform() === 'win32') {
|
||||
binaryFile = binaryFile + '.exe';
|
||||
}
|
||||
|
||||
@@ -82,79 +107,11 @@ function startAspCoreBackend(electronPort) {
|
||||
apiProcess = process(binFilePath, parameters, options);
|
||||
|
||||
apiProcess.stdout.on('data', (data) => {
|
||||
var text = data.toString();
|
||||
console.log(`stdout: ${data.toString()}`);
|
||||
|
||||
// yf add
|
||||
if (text.indexOf(manifestFile.mainWindowShowed) > -1 &&
|
||||
loadingWindow && !loadingWindow.isDestroyed()) {
|
||||
loadingWindow.close();
|
||||
|
||||
mainWindowId = parseInt(text.replace(`${manifestFile.mainWindowShowed}:`, "").trim());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// yf add
|
||||
function startLoadingWindow() {
|
||||
let loadingUrl = manifestJsonFile.loadingUrl;
|
||||
let icon = manifestJsonFile.icon;
|
||||
if (loadingUrl) {
|
||||
loadingWindow = new BrowserWindow({
|
||||
width: manifestJsonFile.width,
|
||||
height: manifestJsonFile.height,
|
||||
transparent: true,
|
||||
frame: false,
|
||||
show: false,
|
||||
devTools: true,
|
||||
icon: path.join(__dirname, icon)
|
||||
})
|
||||
if (manifestJsonFile.devTools) {
|
||||
loadingWindow.webContents.openDevTools();
|
||||
}
|
||||
loadingWindow.loadURL(loadingUrl);
|
||||
loadingWindow.once('ready-to-show', () => {
|
||||
loadingWindow.show()
|
||||
|
||||
// 激活倒计时
|
||||
activeCountDowInterval(manifestJsonFile)
|
||||
})
|
||||
loadingWindow.on('closed', () => {
|
||||
loadingWindow = null
|
||||
|
||||
clearInterval(countDownInterval)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function activeCountDowInterval(manifestJsonFile) {
|
||||
if (!manifestJsonFile.timeout || !manifestJsonFile.timeout.limit)
|
||||
return
|
||||
|
||||
let limitSecond = manifestJsonFile.timeout.limit
|
||||
let currentSecond = 0;
|
||||
countDownInterval = setInterval(() => {
|
||||
currentSecond++;
|
||||
if (currentSecond < limitSecond)
|
||||
return;
|
||||
|
||||
clearInterval(countDownInterval);
|
||||
|
||||
dialog.showMessageBox(loadingWindow, {
|
||||
type: manifestJsonFile.timeout.messageBox.type || 'error',
|
||||
buttons: manifestJsonFile.timeout.messageBox.buttons || ["前往安装"],
|
||||
title: manifestJsonFile.timeout.messageBox.title || '文件缺失提示',
|
||||
message: manifestJsonFile.timeout.messageBox.message || '计算机缺少组件无法启动该程序,点击前往安装组件后重试',
|
||||
}, (res, isChecked) => {
|
||||
if (manifestJsonFile.timeout.help)
|
||||
shell.openExternal(manifestJsonFile.timeout.help)
|
||||
app.quit();
|
||||
});
|
||||
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
//app.on('activate', () => {
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
{
|
||||
"name": "ElectronNET.Host",
|
||||
"name": "electron.net.host",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"author": "Gregor Biswanger",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"detect-port": "^1.2.1",
|
||||
"electron": "^2.0.2",
|
||||
"electron": "^2.0.5",
|
||||
"socket.io": "^2.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
@@ -15,11 +15,11 @@
|
||||
<Folder Include="wwwroot\assets\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ElectronNET.API" Version="1.0.0" />
|
||||
<PackageReference Include="ElectronNET.API" Version="1.0.0.2" />
|
||||
<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.Design" Version="2.1.1" />
|
||||
<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" />
|
||||
@@ -28,6 +28,9 @@
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="ElectronNET.CLI" Version="*" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ElectronNET.API\ElectronNET.API.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="Assets\electron.ico">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
|
||||
Reference in New Issue
Block a user