feat(websocket-arduino): 委托给 WebCompiler.ArduShell 处理本地上传
This commit is contained in:
@@ -1,32 +1,37 @@
|
||||
goog.loadJs('web', () => {
|
||||
|
||||
goog.require('layui');
|
||||
goog.require('dayjs.duration');
|
||||
goog.require('Mixly.Boards');
|
||||
goog.require('Mixly.Debug');
|
||||
goog.require('Mixly.LayerExt');
|
||||
goog.require('Mixly.Msg');
|
||||
goog.require('Mixly.Workspace');
|
||||
goog.require('Mixly.LayerProgress');
|
||||
goog.require('Mixly.WebSocket.Serial');
|
||||
goog.provide('Mixly.WebSocket.ArduShell');
|
||||
goog.require('layui');
|
||||
goog.require('dayjs.duration');
|
||||
goog.require('Mixly.Boards');
|
||||
goog.require('Mixly.Debug');
|
||||
goog.require('Mixly.LayerExt');
|
||||
goog.require('Mixly.Msg');
|
||||
goog.require('Mixly.Workspace');
|
||||
goog.require('Mixly.LayerProgress');
|
||||
goog.require('Mixly.WebSocket.Serial');
|
||||
goog.require('Mixly.WebCompiler.ArduShell');
|
||||
goog.provide('Mixly.WebSocket.ArduShell');
|
||||
|
||||
const {
|
||||
const {
|
||||
Boards,
|
||||
Debug,
|
||||
LayerExt,
|
||||
Msg,
|
||||
Workspace,
|
||||
LayerProgress,
|
||||
WebSocket
|
||||
} = Mixly;
|
||||
WebSocket,
|
||||
WebCompiler = {}
|
||||
} = Mixly;
|
||||
|
||||
const { Serial } = WebSocket;
|
||||
// 动态获取 WebCompiler.ArduShell,用于本地上传
|
||||
const getWebCompilerArduShell = () => Mixly.WebCompiler?.ArduShell;
|
||||
|
||||
const { layer } = layui;
|
||||
const { Serial } = WebSocket;
|
||||
|
||||
const { layer } = layui;
|
||||
|
||||
|
||||
class WebSocketArduShell {
|
||||
class WebSocketArduShell {
|
||||
static {
|
||||
this.mixlySocket = null;
|
||||
this.socket = null;
|
||||
@@ -92,6 +97,13 @@ class WebSocketArduShell {
|
||||
}
|
||||
|
||||
this.initUpload = function () {
|
||||
// 委托给 WebCompiler.ArduShell 处理本地上传(使用 AVRUploader 或 esptool-js)
|
||||
// 服务器无法访问用户本地的串口设备,必须在浏览器端完成上传
|
||||
const WebCompilerArduShell = getWebCompilerArduShell();
|
||||
if (WebCompilerArduShell) {
|
||||
return WebCompilerArduShell.initUpload();
|
||||
}
|
||||
|
||||
if (!this.mixlySocket.isConnected()) {
|
||||
layer.msg(Msg.Lang['websocket.offline'], { time: 1000 });
|
||||
return;
|
||||
@@ -152,8 +164,7 @@ class WebSocketArduShell {
|
||||
statusBarTerminal.addValue(`\n==${message}==\n`);
|
||||
} else {
|
||||
message = (this.shell.isCompiling() ? Msg.Lang['shell.compileSucc'] : Msg.Lang['shell.uploadSucc']);
|
||||
statusBarTerminal.addValue(`\n==${message}(${Msg.Lang['shell.timeCost']} ${
|
||||
dayjs.duration(time).format('HH:mm:ss.SSS')
|
||||
statusBarTerminal.addValue(`\n==${message}(${Msg.Lang['shell.timeCost']} ${dayjs.duration(time).format('HH:mm:ss.SSS')
|
||||
})==\n`);
|
||||
}
|
||||
layer.msg(message, { time: 1000 });
|
||||
@@ -268,8 +279,8 @@ class WebSocketArduShell {
|
||||
isCompiling() {
|
||||
return this.#running_ && !this.#upload_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebSocket.ArduShell = WebSocketArduShell;
|
||||
WebSocket.ArduShell = WebSocketArduShell;
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user