root 3 年之前
父節點
當前提交
dd166a157a

+ 5 - 5
electron-builder.yml

@@ -1,6 +1,6 @@
-appId: org.CocoRobo.ElectronUploaderX
+appId: org.CocoRobo.AIInnovationEducation
 copyright: Copytright © 2021 CocoRobo LTD
-productName: CocoBlocklyXDesktop
+productName: AI创新教育
 npmRebuild: true
 asar: true
 
@@ -32,7 +32,7 @@ mac:
   hardenedRuntime: true
   entitlements: build/entitlements.mac.plist
   entitlementsInherit: build/entitlements.mac.plist
-  artifactName: CocoBlocklyXDesktop Installer v${version}.${ext}
+  artifactName: AIInnovationEducation Installer v${version}.${ext}
   extraFiles:
     - from: src/static/mac/tools
       to: tools
@@ -72,7 +72,7 @@ win:
         - x64
         - ia32
   icon: src/static/common/cocorobo.ico
-  artifactName: CocoBlocklyXDesktop Installer v${version}.${ext}
+  artifactName: AIInnovationEducation Installer v${version}.${ext}
   extraFiles:
     - from: src/static/win/cp210x_drivers
       to: cp210x_drivers
@@ -101,7 +101,7 @@ linux:
     - deb
     - AppImage
   icon: src/static/common/cocorobo.png
-  artifactName: CocoBlocklyXDesktop Installer v${version}.${ext}
+  artifactName: AIInnovationEducation Installer v${version}.${ext}
   extraFiles:
     - from: src/static/linux/tools
       to: tools

+ 1 - 1
package.json

@@ -1,5 +1,5 @@
 {
-  "name": "CocoBlocklyXDesktop",
+  "name": "AIInnovationEducation",
   "version": "1.0.0",
   "description": "cocorobo",
   "repository": "https://github.com/CocoRoboLabs/CocoBlockly-desktop.git",

+ 47 - 15
src/main/main.js

@@ -3,8 +3,6 @@ import { app, BrowserWindow, ipcMain } from 'electron';
 import * as path from 'path';
 import { format as formatUrl } from 'url';
 import { exec } from 'child_process';
-
-
 app.allowRendererProcessReuse = false;
 
 const isDevelopment = process.env.NODE_ENV !== 'production';
@@ -12,17 +10,10 @@ const platform = process.platform;
 
 let mainWindow = null, subWindow1 = null, serWindow1;
 let random = null;
-
+const version = app.getVersion();
 let win1 = null, win2 = null, about = null, esptools = null;
 let tmp = null, appIcon = null, menu = null, trayImg = null;
 
-app.on('web-contents-created', (e, webContents) => {
-	webContents.on('new-window', (event, url) => {
-		event.preventDefault();
-		shell.openExternal(url);
-	});
-});
-
 // ------------ Keep only one instance of the app running ------------ //
 // const singleLock = app.requestSingleInstanceLock();
 // !singleLock ? app.quit() : '';
@@ -33,7 +24,10 @@ if (!gotTheLock) {
 	app.quit()
 } else {
 	app.on('second-instance', (event, commandLine, workingDirectory) => {
-
+		if (mainWindow) {
+			if (mainWindow.isMinimized()) mainWindow.restore()
+			mainWindow.focus()
+		}
 	})
 
 	// Create myWindow, load the rest of the app, etc...
@@ -42,7 +36,45 @@ if (!gotTheLock) {
 	})
 }
 
-const version = app.getVersion();
+// ------------ run auto launch & add ca cert in MacOS ------------ //
+if (platform === 'darwin') {
+	app.dock.hide();
+
+	const sudo = require('sudo-prompt');
+	const AutoLaunch = require('auto-launch');
+	const opts = {
+		name: "AIInnovationEducation",
+		isHidden: false,
+		mac: { useLaunchAgent: true }
+	};
+
+	autoLaunch(opts);
+	exec(`"${path.join(__dirname, '..', 'verifyCert.bash')}"`, (err, stdout) => {
+		if (!err && stdout.indexOf('No') > -1)
+			sudo.exec(
+				`security add-trusted-cert -d -r trustRoot -k "/Library/Keychains/System.keychain" "${path.join(__dirname, '..', 'ca.crt')}"`,
+				{ name: 'CocoRobo X Uploader' },
+				err => console.log(err)
+			);
+		else if (err)
+			console.error(err);
+	});
+
+    /**
+     * Auto launch when computer boot.
+     * @opts {object} Auto lanuch's options
+     * @returns {void} void
+     */
+	function autoLaunch(opts) {
+		const autoLaunch = new AutoLaunch(opts);
+		autoLaunch
+			.isEnabled()
+			.then(enabled => enabled ? '' : autoLaunch.enable())
+			.catch(err => console.error(err));
+		return;
+	}
+}
+
 
 
 /**
@@ -81,8 +113,8 @@ ipcMain.on('windowsid', (e, data) => e.returnValue = getWindowsId(data));
 
 // ------------ When app is ready ------------ //
 app.on('ready', () => {
-	subWindow1 = createSubWindow1();
-	serWindow1 = createSubWindow2();
+	createSubWindow1();
+	createSubWindow2();
 	mainWindow = createMainWindow();
 });
 
@@ -107,7 +139,7 @@ function createMainWindow() {
 	}
 	window.once('ready-to-show', () => window.show());
 
-	window.on('closed', () => window = null);
+	window.on('closed', () => { app.quit() });
 
 	window.webContents.on('devtools-opened', () => window.focus());
 	//window.webContents.openDevTools({ mode: 'undocked' });

二進制
src/static/common/cocorobo.ico


二進制
src/static/common/cocorobo.png


二進制
src/static/common/cocorobo_.ico


二進制
src/static/common/cocorobo_.png


二進制
src/static/common/cocorobo_black.png


二進制
src/static/common/logo-1.png


+ 2 - 2
src/static/win/installer.nsh

@@ -7,7 +7,7 @@
 !macroend
 
 !macro customInstall
-    WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run""TXCocoBlocklyXUploader" "$INSTDIR\TXCocoBlocklyXUploader.exe"
+    WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run""AIInnovationEducation" "$INSTDIR\AIInnovationEducation.exe"
     nsExec::Exec ".\resources\ca.bat"
     ${ifNot} ${isUpdated}
         ; ${If} ${RunningX64}
@@ -31,5 +31,5 @@
     #nsExec::Exec 'cmd.exe /c del "$INSTDIR\resources\ca.bat" "$INSTDIR\resources\ca.crt" "$INSTDIR\python\python-3.8.0-amd64.bat" "$INSTDIR\python\python-3.8.0.bat" "$INSTDIR\cp210x_drivers\CP210xVCPInstaller_x64.bat" "$INSTDIR\cp210x_drivers\CP210xVCPInstaller_x86.bat"'
 !macroend
 !macro customUnInstall
-    DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "TXCocoBlocklyXUploader"
+    DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "AIInnovationEducation"
 !macroend