root há 4 anos atrás
pai
commit
2517da36d9

+ 5 - 5
electron-builder.yml

@@ -1,6 +1,6 @@
-appId: org.CocoRobo.AIInnovationEducation
+appId: org.CocoRobo.CocoRoboVDeskTop
 copyright: Copytright © 2021 CocoRobo LTD
-productName: AI创新教育
+productName: CocoRoboVDeskTop
 npmRebuild: true
 asar: true
 
@@ -32,7 +32,7 @@ mac:
   hardenedRuntime: true
   entitlements: build/entitlements.mac.plist
   entitlementsInherit: build/entitlements.mac.plist
-  artifactName: AIInnovationEducation Installer v${version}.${ext}
+  artifactName: CocoRoboVDeskTop 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: AIInnovationEducation Installer v${version}.${ext}
+  artifactName: CocoRoboVDeskTop 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: AIInnovationEducation Installer v${version}.${ext}
+  artifactName: CocoRoboVDeskTop Installer v${version}.${ext}
   extraFiles:
     - from: src/static/linux/tools
       to: tools

+ 1 - 1
package.json

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

+ 1 - 1
src/main/main.js

@@ -43,7 +43,7 @@ if (platform === 'darwin') {
 	const sudo = require('sudo-prompt');
 	const AutoLaunch = require('auto-launch');
 	const opts = {
-		name: "AIInnovationEducation",
+		name: "CocoRoboVDeskTop",
 		isHidden: false,
 		mac: { useLaunchAgent: true }
 	};

+ 1 - 1
src/renderer/handler.js

@@ -22,7 +22,7 @@ function parsePorts(list) {
         if (mf) {
             // if (mf.indexOf('Arduino') > -1)
             //     result.boards.push(val);
-            if (mf.indexOf('ftdi') > -1)
+            if (mf.toLocaleLowerCase().indexOf('ftdi') > -1)
                 result.wifi.push(val);
         }
     });

+ 1 - 1
src/renderer/index.js

@@ -341,7 +341,7 @@ app.post('/upload', (req, res) => {
             socket.emit('upload', { ProgrammerStatus: 'Done' });
         }).then(() => res.status(200).send('success')).catch(err => {
             res.status(200).send('success')
-            let error = errHandler(err.message);
+            let error = errHandler(err);
             socket.emit('upload', { ProgrammerStatus: 'Error', Error: error });
         });
     } else

+ 42 - 11
src/renderer/uploader.js

@@ -9,7 +9,7 @@ import { setTimeout, setInterval } from 'timers';
 import errHandler from './error_handle';
 var iconv = require('iconv-lite');
 //const serialPort = new SerialPort();
-
+var serialPort;
 // ------ Variabls ------ //
 const platform = process.platform;
 const tool = join(__dirname, '..', '..', 'tools');
@@ -303,7 +303,12 @@ function detect(comName, locationId = '') {
  */
 export function upload(code, val, socket) {
     return new Promise(async (resolve, reject) => {
-        var serialPort = await new SerialPort(val, {
+        if (serialPort && serialPort.isOpen) {
+            try {
+                serialPort.close();
+            } catch (e) { }
+        }
+        serialPort = await new SerialPort(val, {
             baudRate: 115200,
             parity: "none",
             stopBits: 1,
@@ -315,14 +320,37 @@ export function upload(code, val, socket) {
                 let error = errHandler(err);
                 socket.emit('upload', { ProgrammerStatus: 'Error', Error: error });
                 if (serialPort.isOpen) {
-                    serialPort.close();
+                    try {
+                        serialPort.close();
+                    } catch (e) { }
                 }
             }
             else {
-                code = code.replace("\r", "\\r")
-                code = code.replace("\n", "\\n")
-                code = code.replace("\"", "\\\"").replace(/^\s+|\s+$/g, '')
-                var complete_command = "rm /home/user/upload.py && printf \"" + code + "\" >> /home/user/upload.py && python /home/user/upload.py" + "\r\n"
+                //code = code.replace(new RegExp("\r", "gm"), "\\r")
+                //code = code.replace(new RegExp("\n", "gm"), "\\n")
+                code = code.replace(new RegExp("\"", "gm"), "\\\"").replace(/^\s+|\s+$/g, '')
+                var complete_command = "rm /home/user/upload.py && echo \"" + code + "\" > /home/user/upload.py && python /home/user/upload.py" + "\r\n";
+                serialPort.on('data', function (data) {
+                    resolve();
+                    if (data) {
+                        if (data.indexOf("root@sipeed:") == -1 && data.indexOf("rm /home/user/upload.py") != 0 && data.indexOf("python /home/user/upload.py") == -1) {
+                            socket.emit('repl', { code: data });
+                        }
+                    }
+                    console.log('data received: ' + data);
+                })
+
+                serialPort.on('error', function (err) {
+                    if (err) {
+                        err = err.message;
+                        reject(err);
+                        let error = errHandler(err);
+                        socket.emit('upload', { ProgrammerStatus: 'Error', Error: error });
+                    }
+                    console.log(err);
+                    return;
+                });
+
                 serialPort.write(complete_command, function (err, msg) {
                     if (err) {
                         err = err.message;
@@ -330,13 +358,10 @@ export function upload(code, val, socket) {
                         let error = errHandler(err);
                         socket.emit('upload', { ProgrammerStatus: 'Error', Error: error });
                     }
-                    else {
+                    else if (msg) {
                         resolve();
                         socket.emit('repl', { code: msg });
                     }
-                    if (serialPort.isOpen) {
-                        serialPort.close();
-                    }
                 })
             }
         });
@@ -370,6 +395,12 @@ export function upload(code, val, socket) {
     */
 }
 
+
+linuxupload = function () {
+
+
+}
+
 //     * 上传插件收到来自前端的 python 文件,将 python 代码通过 ampy 命令上传至模块中
 //     * ampy --port [端口名] put user_code.py /user_code.py
 // * 等待上传插件将代码上传成功以后,运行该文件

BIN
src/static/common/cocorobo.ico


BIN
src/static/common/cocorobo.png


BIN
src/static/common/cocorobo_.ico


BIN
src/static/common/cocorobo_.png


BIN
src/static/common/cocorobo_black.png


BIN
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""AIInnovationEducation" "$INSTDIR\AIInnovationEducation.exe"
+    WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run""CocoRoboVDeskTop" "$INSTDIR\CocoRoboVDeskTop.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" "AIInnovationEducation"
+    DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "CocoRoboVDeskTop"
 !macroend