fix: show Add Device button in Web environment
This commit is contained in:
@@ -1,41 +1,41 @@
|
||||
goog.loadJs('common', () => {
|
||||
|
||||
goog.require('path');
|
||||
goog.require('hotkeys');
|
||||
goog.require('Mixly.Url');
|
||||
goog.require('Mixly.Config');
|
||||
goog.require('Mixly.Env');
|
||||
goog.require('Mixly.Msg');
|
||||
goog.require('Mixly.Drag');
|
||||
goog.require('Mixly.Nav');
|
||||
goog.require('Mixly.Menu');
|
||||
goog.require('Mixly.Workspace');
|
||||
goog.require('Mixly.FooterBar');
|
||||
goog.require('Mixly.HTMLTemplate');
|
||||
goog.require('Mixly.LayerExt');
|
||||
goog.require('Mixly.Debug');
|
||||
goog.require('Mixly.Component');
|
||||
goog.require('Mixly.EditorMix');
|
||||
goog.require('Mixly.Electron.Loader');
|
||||
goog.require('Mixly.Electron.FS');
|
||||
goog.require('Mixly.Electron.File');
|
||||
goog.require('Mixly.Electron.LibManager');
|
||||
goog.require('Mixly.Electron.Serial');
|
||||
goog.require('Mixly.Electron.ArduShell');
|
||||
goog.require('Mixly.Electron.BU');
|
||||
goog.require('Mixly.Electron.PythonShell');
|
||||
goog.require('Mixly.Web.BU');
|
||||
goog.require('Mixly.Web.FS');
|
||||
goog.require('Mixly.Web.File');
|
||||
goog.require('Mixly.Web.Serial');
|
||||
goog.require('Mixly.WebCompiler.ArduShell');
|
||||
goog.require('Mixly.WebSocket.File');
|
||||
goog.require('Mixly.WebSocket.Serial');
|
||||
goog.require('Mixly.WebSocket.ArduShell');
|
||||
goog.require('Mixly.WebSocket.BU');
|
||||
goog.provide('Mixly.App');
|
||||
goog.require('path');
|
||||
goog.require('hotkeys');
|
||||
goog.require('Mixly.Url');
|
||||
goog.require('Mixly.Config');
|
||||
goog.require('Mixly.Env');
|
||||
goog.require('Mixly.Msg');
|
||||
goog.require('Mixly.Drag');
|
||||
goog.require('Mixly.Nav');
|
||||
goog.require('Mixly.Menu');
|
||||
goog.require('Mixly.Workspace');
|
||||
goog.require('Mixly.FooterBar');
|
||||
goog.require('Mixly.HTMLTemplate');
|
||||
goog.require('Mixly.LayerExt');
|
||||
goog.require('Mixly.Debug');
|
||||
goog.require('Mixly.Component');
|
||||
goog.require('Mixly.EditorMix');
|
||||
goog.require('Mixly.Electron.Loader');
|
||||
goog.require('Mixly.Electron.FS');
|
||||
goog.require('Mixly.Electron.File');
|
||||
goog.require('Mixly.Electron.LibManager');
|
||||
goog.require('Mixly.Electron.Serial');
|
||||
goog.require('Mixly.Electron.ArduShell');
|
||||
goog.require('Mixly.Electron.BU');
|
||||
goog.require('Mixly.Electron.PythonShell');
|
||||
goog.require('Mixly.Web.BU');
|
||||
goog.require('Mixly.Web.FS');
|
||||
goog.require('Mixly.Web.File');
|
||||
goog.require('Mixly.Web.Serial');
|
||||
goog.require('Mixly.WebCompiler.ArduShell');
|
||||
goog.require('Mixly.WebSocket.File');
|
||||
goog.require('Mixly.WebSocket.Serial');
|
||||
goog.require('Mixly.WebSocket.ArduShell');
|
||||
goog.require('Mixly.WebSocket.BU');
|
||||
goog.provide('Mixly.App');
|
||||
|
||||
const {
|
||||
const {
|
||||
Url,
|
||||
Config,
|
||||
Env,
|
||||
@@ -54,42 +54,42 @@ const {
|
||||
Web = {},
|
||||
WebCompiler = {},
|
||||
WebSocket = {}
|
||||
} = Mixly;
|
||||
} = Mixly;
|
||||
|
||||
const { Loader } = Electron;
|
||||
const { Loader } = Electron;
|
||||
|
||||
let currentObj = null;
|
||||
let currentObj = null;
|
||||
|
||||
if (goog.isElectron) {
|
||||
if (goog.isElectron) {
|
||||
currentObj = Electron;
|
||||
} else {
|
||||
} else {
|
||||
if (Env.hasSocketServer) {
|
||||
currentObj = WebSocket;
|
||||
} else {
|
||||
currentObj = Web;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const {
|
||||
const {
|
||||
FS,
|
||||
File,
|
||||
LibManager,
|
||||
BU,
|
||||
PythonShell,
|
||||
Serial
|
||||
} = currentObj;
|
||||
} = currentObj;
|
||||
|
||||
let ArduShell = null;
|
||||
if (!goog.isElectron && Env.hasCompiler) {
|
||||
let ArduShell = null;
|
||||
if (!goog.isElectron && Env.hasCompiler) {
|
||||
ArduShell = WebCompiler.ArduShell;
|
||||
} else {
|
||||
} else {
|
||||
ArduShell = currentObj.ArduShell;
|
||||
}
|
||||
}
|
||||
|
||||
const { BOARD, SELECTED_BOARD } = Config;
|
||||
const { BOARD, SELECTED_BOARD } = Config;
|
||||
|
||||
|
||||
class App extends Component {
|
||||
class App extends Component {
|
||||
static {
|
||||
HTMLTemplate.add(
|
||||
'html/app.html',
|
||||
@@ -174,7 +174,8 @@ class App extends Component {
|
||||
id: 'port-add-btn',
|
||||
displayText: Msg.Lang['nav.btn.addDevice'],
|
||||
preconditionFn: () => {
|
||||
if (goog.isElectron || Env.hasSocketServer) {
|
||||
// 在 Web 环境下始终显示添加设备按钮
|
||||
if (goog.isElectron) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -470,7 +471,7 @@ class App extends Component {
|
||||
}
|
||||
});
|
||||
|
||||
hotkeys('ctrl+n', function(event) {
|
||||
hotkeys('ctrl+n', function (event) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
File.new();
|
||||
@@ -489,7 +490,7 @@ class App extends Component {
|
||||
}
|
||||
});
|
||||
|
||||
hotkeys('ctrl+o', function(event) {
|
||||
hotkeys('ctrl+o', function (event) {
|
||||
event.preventDefault();
|
||||
File.open();
|
||||
});
|
||||
@@ -513,7 +514,7 @@ class App extends Component {
|
||||
}
|
||||
});
|
||||
|
||||
hotkeys('ctrl+s', function(event) {
|
||||
hotkeys('ctrl+s', function (event) {
|
||||
event.preventDefault();
|
||||
File.save();
|
||||
});
|
||||
@@ -531,7 +532,7 @@ class App extends Component {
|
||||
}
|
||||
});
|
||||
|
||||
hotkeys('ctrl+shift+s', function(event) {
|
||||
hotkeys('ctrl+shift+s', function (event) {
|
||||
event.preventDefault();
|
||||
File.saveAs();
|
||||
});
|
||||
@@ -559,7 +560,7 @@ class App extends Component {
|
||||
});
|
||||
|
||||
if (goog.isElectron && BOARD?.nav?.setting?.thirdPartyLibrary) {
|
||||
hotkeys('ctrl+e', function(event) {
|
||||
hotkeys('ctrl+e', function (event) {
|
||||
event.preventDefault();
|
||||
File.exportLib();
|
||||
});
|
||||
@@ -579,7 +580,7 @@ class App extends Component {
|
||||
});
|
||||
|
||||
if (goog.isElectron && BOARD?.nav?.setting?.thirdPartyLibrary) {
|
||||
hotkeys('ctrl+m', function(event) {
|
||||
hotkeys('ctrl+m', function (event) {
|
||||
LibManager.showManageDialog();
|
||||
});
|
||||
}
|
||||
@@ -609,7 +610,7 @@ class App extends Component {
|
||||
}
|
||||
});
|
||||
|
||||
hotkeys('ctrl+shift+f', function(event) {
|
||||
hotkeys('ctrl+shift+f', function (event) {
|
||||
const href = 'https://gitee.com/bnu_mixly/mixly3/issues';
|
||||
Url.open(href);
|
||||
});
|
||||
@@ -630,7 +631,7 @@ class App extends Component {
|
||||
}
|
||||
});
|
||||
|
||||
hotkeys('ctrl+h', function(event) {
|
||||
hotkeys('ctrl+h', function (event) {
|
||||
const href = 'https://mixly.readthedocs.io/zh-cn/latest/contents.html';
|
||||
Url.open(href);
|
||||
});
|
||||
@@ -682,8 +683,8 @@ class App extends Component {
|
||||
this.#workspace_.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Mixly.App = App;
|
||||
Mixly.App = App;
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user