mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 20:58:14 -05:00
🐛 修复 Windows WebTerminal
This commit is contained in:
parent
2d30b2cf47
commit
7990689949
@ -4,7 +4,7 @@
|
|||||||
<br>
|
<br>
|
||||||
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
||||||
<br><br>
|
<br><br>
|
||||||
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.9.22&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.6.7-brightgreen?style=for-the-badge&logo=linux">
|
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.9.23&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.6.7-brightgreen?style=for-the-badge&logo=linux">
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<p>:trollface: <b>哪吒监控</b> 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。</p>
|
<p>:trollface: <b>哪吒监控</b> 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。</p>
|
||||||
|
@ -4,12 +4,15 @@
|
|||||||
package pty
|
package pty
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
opty "github.com/creack/pty"
|
opty "github.com/creack/pty"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var defaultShells = []string{"zsh", "fish", "bash", "sh"}
|
||||||
|
|
||||||
type Pty struct {
|
type Pty struct {
|
||||||
tty *os.File
|
tty *os.File
|
||||||
cmd *exec.Cmd
|
cmd *exec.Cmd
|
||||||
@ -19,9 +22,15 @@ func DownloadDependency() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Start() (*Pty, error) {
|
func Start() (*Pty, error) {
|
||||||
shellPath := os.Getenv("SHELL")
|
var shellPath string
|
||||||
|
for i := 0; i < len(defaultShells); i++ {
|
||||||
|
shellPath, _ = exec.LookPath(defaultShells[i])
|
||||||
|
if shellPath != "" {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
if shellPath == "" {
|
if shellPath == "" {
|
||||||
shellPath = "sh"
|
return nil, errors.New("没有可用终端")
|
||||||
}
|
}
|
||||||
cmd := exec.Command(shellPath)
|
cmd := exec.Command(shellPath)
|
||||||
cmd.Env = append(os.Environ(), "TERM=xterm")
|
cmd.Env = append(os.Environ(), "TERM=xterm")
|
||||||
|
@ -73,12 +73,12 @@ func Start() (*Pty, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
tty, err := winpty.Open(path, shellPath)
|
tty, err := winpty.OpenDefault(path, shellPath)
|
||||||
return &Pty{tty: tty}, err
|
return &Pty{tty: tty}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pty *Pty) Write(p []byte) (n int, err error) {
|
func (pty *Pty) Write(p []byte) (n int, err error) {
|
||||||
return pty.tty.StdIn.Read(p)
|
return pty.tty.StdIn.Write(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pty *Pty) Read(p []byte) (n int, err error) {
|
func (pty *Pty) Read(p []byte) (n int, err error) {
|
||||||
|
@ -163,6 +163,7 @@ function post(path, params, method = 'post') {
|
|||||||
const form = document.createElement('form');
|
const form = document.createElement('form');
|
||||||
form.method = method;
|
form.method = method;
|
||||||
form.action = path;
|
form.action = path;
|
||||||
|
form.target = "_blank";
|
||||||
|
|
||||||
for (const key in params) {
|
for (const key in params) {
|
||||||
if (params.hasOwnProperty(key)) {
|
if (params.hasOwnProperty(key)) {
|
||||||
@ -176,6 +177,7 @@ function post(path, params, method = 'post') {
|
|||||||
|
|
||||||
document.body.appendChild(form);
|
document.body.appendChild(form);
|
||||||
form.submit();
|
form.submit();
|
||||||
|
document.removeChild(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addOrEditServer(server, conf) {
|
function addOrEditServer(server, conf) {
|
||||||
|
2
resource/template/common/footer.html
vendored
2
resource/template/common/footer.html
vendored
@ -9,7 +9,7 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.1/dist/semantic.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.1/dist/semantic.min.js"></script>
|
||||||
<script src="/static/semantic-ui-alerts.min.js"></script>
|
<script src="/static/semantic-ui-alerts.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.min.js"></script>
|
||||||
<script src="/static/main.js?v20210817"></script>
|
<script src="/static/main.js?v20210818"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -40,6 +40,10 @@
|
|||||||
term.loadAddon(fitAddon);
|
term.loadAddon(fitAddon);
|
||||||
term.open(document.getElementById('terminal-container'));
|
term.open(document.getElementById('terminal-container'));
|
||||||
|
|
||||||
|
socket.onopen = () => {
|
||||||
|
onResize()
|
||||||
|
}
|
||||||
|
|
||||||
function onResize() {
|
function onResize() {
|
||||||
fitAddon.fit()
|
fitAddon.fit()
|
||||||
const w = fitAddon.proposeDimensions();
|
const w = fitAddon.proposeDimensions();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
debug: false
|
debug: false
|
||||||
httpport: 80
|
httpport: nz_grpc_port
|
||||||
|
grpcport:
|
||||||
oauth2:
|
oauth2:
|
||||||
type: "nz_oauth2_type" #Oauth2 登录接入类型,gitee/github
|
type: "nz_oauth2_type" #Oauth2 登录接入类型,gitee/github
|
||||||
admin: "nz_admin_logins" #管理员列表,半角逗号隔开
|
admin: "nz_admin_logins" #管理员列表,半角逗号隔开
|
||||||
|
@ -8,4 +8,4 @@ services:
|
|||||||
- ./data:/dashboard/data
|
- ./data:/dashboard/data
|
||||||
ports:
|
ports:
|
||||||
- nz_site_port:80
|
- nz_site_port:80
|
||||||
- nz_grpc_port:5555
|
- nz_grpc_port:nz_grpc_port
|
||||||
|
@ -305,6 +305,7 @@ modify_dashboard_config() {
|
|||||||
|
|
||||||
sed -i "s/nz_oauth2_type/${nz_oauth2_type}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
|
sed -i "s/nz_oauth2_type/${nz_oauth2_type}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
|
||||||
sed -i "s/nz_admin_logins/${nz_admin_logins}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
|
sed -i "s/nz_admin_logins/${nz_admin_logins}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
|
||||||
|
sed -i "s/nz_grpc_port/${nz_grpc_port}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
|
||||||
sed -i "s/nz_github_oauth_client_id/${nz_github_oauth_client_id}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
|
sed -i "s/nz_github_oauth_client_id/${nz_github_oauth_client_id}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
|
||||||
sed -i "s/nz_github_oauth_client_secret/${nz_github_oauth_client_secret}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
|
sed -i "s/nz_github_oauth_client_secret/${nz_github_oauth_client_secret}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
|
||||||
sed -i "s/nz_site_title/${nz_site_title}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
|
sed -i "s/nz_site_title/${nz_site_title}/" ${NZ_DASHBOARD_PATH}/data/config.yaml
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
pb "github.com/naiba/nezha/proto"
|
pb "github.com/naiba/nezha/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = "v0.9.22" // !!记得修改 README 中的 badge 版本!!
|
var Version = "v0.9.23" // !!记得修改 README 中的 badge 版本!!
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Conf *model.Config
|
Conf *model.Config
|
||||||
|
Loading…
Reference in New Issue
Block a user