Update: 更新WebSocket模式
This commit is contained in:
@@ -27,6 +27,8 @@ goog.require('Mixly.Web.BU');
|
||||
goog.require('Mixly.Web.FS');
|
||||
goog.require('Mixly.Web.File');
|
||||
goog.require('Mixly.Web.Serial');
|
||||
goog.require('Mixly.WebSocket.Serial');
|
||||
goog.require('Mixly.WebSocket.ArduShell');
|
||||
goog.provide('Mixly.App');
|
||||
|
||||
const {
|
||||
@@ -44,11 +46,24 @@ const {
|
||||
Component,
|
||||
EditorMix,
|
||||
Electron = {},
|
||||
Web = {}
|
||||
Web = {},
|
||||
WebSocket = {}
|
||||
} = Mixly;
|
||||
|
||||
const { Loader } = Electron;
|
||||
|
||||
let currentObj = null;
|
||||
|
||||
if (goog.isElectron) {
|
||||
currentObj = Electron;
|
||||
} else {
|
||||
if (Env.hasSocketServer) {
|
||||
currentObj = WebSocket;
|
||||
} else {
|
||||
currentObj = Web;
|
||||
}
|
||||
}
|
||||
|
||||
const {
|
||||
FS,
|
||||
File,
|
||||
@@ -57,7 +72,7 @@ const {
|
||||
BU,
|
||||
PythonShell,
|
||||
Serial
|
||||
} = goog.isElectron? Electron : Web;
|
||||
} = currentObj;
|
||||
|
||||
const { BOARD, SELECTED_BOARD } = Config;
|
||||
|
||||
@@ -149,7 +164,7 @@ class App extends Component {
|
||||
id: 'port-add-btn',
|
||||
displayText: Msg.Lang['nav.btn.addDevice'],
|
||||
preconditionFn: () => {
|
||||
if (goog.isElectron) {
|
||||
if (goog.isElectron || Env.hasSocketServer) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -165,7 +180,10 @@ class App extends Component {
|
||||
id: 'arduino-compile-btn',
|
||||
displayText: Msg.Lang['nav.btn.compile'],
|
||||
preconditionFn: () => {
|
||||
if (!goog.isElectron || !SELECTED_BOARD?.nav?.compile) {
|
||||
if (!goog.isElectron && !Env.hasSocketServer && !env.hasCompiler) {
|
||||
return false;
|
||||
}
|
||||
if (!SELECTED_BOARD?.nav?.compile || !SELECTED_BOARD?.nav?.upload) {
|
||||
return false;
|
||||
}
|
||||
const workspace = Workspace.getMain();
|
||||
@@ -190,7 +208,10 @@ class App extends Component {
|
||||
id: 'arduino-upload-btn',
|
||||
displayText: Msg.Lang['nav.btn.upload'],
|
||||
preconditionFn: () => {
|
||||
if (!goog.isElectron || !SELECTED_BOARD?.nav?.compile || !SELECTED_BOARD?.nav?.upload) {
|
||||
if (!goog.isElectron && !Env.hasSocketServer && !env.hasCompiler) {
|
||||
return false;
|
||||
}
|
||||
if (!SELECTED_BOARD?.nav?.compile || !SELECTED_BOARD?.nav?.upload) {
|
||||
return false;
|
||||
}
|
||||
const workspace = Workspace.getMain();
|
||||
|
||||
@@ -11,10 +11,10 @@ for (let key in console) {
|
||||
continue;
|
||||
}
|
||||
Debug[key] = (...args) => {
|
||||
if (!SOFTWARE.debug) {
|
||||
console.log(`[${key.toUpperCase()}]`, ...args);
|
||||
} else {
|
||||
if (SOFTWARE.debug) {
|
||||
console[key](...args);
|
||||
} else {
|
||||
console.log(`[${key.toUpperCase()}]`, ...args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,9 @@ const { Socket } = WebSocket;
|
||||
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
if (!goog.isElectron && Env.hasSocketServer) {
|
||||
Socket.init();
|
||||
}
|
||||
const app = new App($('body')[0]);
|
||||
Mixly.app = app;
|
||||
const $xml = $(goog.get(Env.boardIndexPath));
|
||||
@@ -84,9 +87,6 @@ Loader.start = () => {
|
||||
if (!goog.isElectron && window.location.host.indexOf('mixly.cn')) {
|
||||
window.userOpEvents = new UserOPEvents();
|
||||
}
|
||||
if (Env.hasSocketServer) {
|
||||
Socket.init();
|
||||
}
|
||||
if (goog.isElectron && typeof LibManager === 'object') {
|
||||
LibManager.init(() => Loader.init());
|
||||
} else {
|
||||
|
||||
@@ -16,6 +16,7 @@ goog.require('Mixly.StatusBarSerialOutput');
|
||||
goog.require('Mixly.StatusBarSerialChart');
|
||||
goog.require('Mixly.Electron.Serial');
|
||||
goog.require('Mixly.Web.Serial');
|
||||
goog.require('Mixly.WebSocket.Serial');
|
||||
goog.provide('Mixly.StatusBarSerial');
|
||||
|
||||
const {
|
||||
@@ -32,10 +33,23 @@ const {
|
||||
StatusBarSerialOutput,
|
||||
StatusBarSerialChart,
|
||||
Electron = {},
|
||||
Web = {}
|
||||
Web = {},
|
||||
WebSocket = {}
|
||||
} = Mixly;
|
||||
|
||||
const { Serial } = goog.isElectron ? Electron : Web;
|
||||
let currentObj = null;
|
||||
|
||||
if (goog.isElectron) {
|
||||
currentObj = Electron;
|
||||
} else {
|
||||
if (Env.hasSocketServer) {
|
||||
currentObj = WebSocket;
|
||||
} else {
|
||||
currentObj = Web;
|
||||
}
|
||||
}
|
||||
|
||||
const { Serial } = currentObj;
|
||||
|
||||
const { SELECTED_BOARD } = Config;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user