Skip to content

Commit

Permalink
(Fix: Terminal) Fix #229
Browse files Browse the repository at this point in the history
  • Loading branch information
Medicean committed Dec 3, 2019
1 parent 9085af9 commit 17d2ee4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ Windows:

> 注意: asp 下设置之后, 当前机器上的IIS子进程都会受影响, 过一段时间子进程退出后正常
* 新增 `aswinmode` 本地指令, 在自动识别操作系统错误时, 可使用该指令手动切换命令行运行的模式 (#229 thx @nullnull1604-outlook)

![terminal_aswinmode.png](https://i.loli.net/2019/12/03/HpbjN6sERhYoiUX.png)

### 其它

* ACE 编辑器增加 `ace/mode/antswordjwt` 语法模式, 支持 JWT Token 语法高亮
Expand Down
1 change: 1 addition & 0 deletions source/language/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ module.exports = {
ascmd [file]\t\tExecute the command with file, eg: ascmd /bin/bash
aslistcmd\t\tList available command interpreters
aspowershell [on|off]\t\tEnable/Disable PowerShell mode, eg: aspowershell on
aswinmode [on|off]\t\tEnable/Disable Windows mode(for recognition errors), eg: aswinmode on
quit\t\tClose terminal
exit\t\tClose terminal
Expand Down
1 change: 1 addition & 0 deletions source/language/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ module.exports = {
ascmd [file]\t\t指定file来执行命令, eg: ascmd /bin/bash
aslistcmd\t\t列出可使用的命令解释器
aspowershell [on|off]\t\t启用/关闭PowerShell模式, eg: aspowershell on
aswinmode [on|off]\t\t强制启用/关闭为Windows模式(针对识别出错的情况), eg: aswinmode on
quit\t\t关闭终端
exit\t\t关闭终端
Expand Down
1 change: 1 addition & 0 deletions source/language/zh_hk.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ module.exports = {
ascmd [file]\t\t指定file來執行命令, eg: ascmd /bin/bash
aslistcmd\t\t列出可使用的命令解釋器
aspowershell [on|off]\t\t啟用/關閉PowerShell模式, eg: aspowershell on
aswinmode [on|off]\t\t強制啟用/關閉為Windows模式(針對識別出錯的情況), eg: aswinmode on
quit\t\t關閉終端
exit\t\t關閉終端
Expand Down
1 change: 1 addition & 0 deletions source/language/zh_tw.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ module.exports = {
ascmd [file]\t\t指定file來執行命令, eg: ascmd /bin/bash
aslistcmd\t\t列出可使用的命令解釋器
aspowershell [on|off]\t\t啟用/關閉PowerShell模式, eg: aspowershell on
aswinmode [on|off]\t\t強制啟用/關閉為Windows模式(針對識別出錯的情況), eg: aswinmode on
quit\t\t關閉終端
exit\t\t關閉終端
Expand Down
18 changes: 17 additions & 1 deletion source/modules/terminal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,22 @@ class Terminal {
}
return;
}
// 当 web 目录使用的是 smb 目录时, windows 下路径为 //xxx.xxx.xxx.xxx/share
// 第一个字符为 / 则会识别为 Linux 系统, 需要使用该指令手动切换成 windows mode
// Fix https://github.com/AntSwordProject/antSword/issues/229
if (cmd.substr(0, 9) === 'aswinmode') {
var _switch = cmd.substr(9).trim().toLowerCase();
if (_switch === "off") {
self.isWin = false;
term.echo("Windows Mode: [[b;red;]Off]");
} else if (_switch === "on") {
self.isWin = true;
term.echo("Windows Mode: [[b;green;]On]");
} else {
term.echo(`Current Windows Mode: ${self.isWin ? "[[b;green;]On]" : "[[b;red;]Off]"}`);
}
return;
}
if (cmd.substr(0, 5) === 'asenv') {
var envstr = cmd.substr(5).trim();
if (envstr.length > 0 && envstr.indexOf('=') > 0) {
Expand Down Expand Up @@ -382,7 +398,7 @@ class Terminal {
exit: false,
// < 1.0.0 时使用3个参数 completion: (term, value, callback) => {}
completion: (value, callback) => {
callback(['asenv', 'ashelp', 'ascmd', 'aslistcmd', 'aspowershell', 'quit', 'exit'].concat(
callback(['asenv', 'ashelp', 'ascmd', 'aslistcmd', 'aspowershell', 'aswinmode', 'quit', 'exit'].concat(
this.isWin ? [
'dir', 'whoami', 'net', 'ipconfig', 'netstat', 'cls', 'wscript', 'nslookup', 'copy', 'del', 'ren', 'md', 'type', 'ping'
] : [
Expand Down

0 comments on commit 17d2ee4

Please sign in to comment.