mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 01:04:06 +08:00
tce add tmux
This commit is contained in:
parent
716f4da5c1
commit
b41f0d0ff6
@ -277,7 +277,9 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
"nserve": &ctx.Cache{Name: "nserve", Value: "0", Help: "主机数量"},
|
||||
"nroute": &ctx.Cache{Name: "nroute", Value: "0", Help: "路由数量"},
|
||||
},
|
||||
Configs: map[string]*ctx.Config{},
|
||||
Configs: map[string]*ctx.Config{
|
||||
"cmd": &ctx.Config{Name: "cmd", Value: "tmux", Help: "路由数量"},
|
||||
},
|
||||
Commands: map[string]*ctx.Command{
|
||||
"client": &ctx.Command{
|
||||
Name: "client address [output [editor]]",
|
||||
@ -743,7 +745,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
delete(list.Meta, "size_i")
|
||||
|
||||
// 执行命令
|
||||
switch m.Option("cmd") {
|
||||
switch m.Confx("cmd") {
|
||||
case "git":
|
||||
git := m.Sess("git", m.Target())
|
||||
|
||||
@ -752,10 +754,18 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
|
||||
status := m.Find("nfs").Cmd("git", "-C", m.Option("dir"), "status")
|
||||
git.Option("status", status.Result(0))
|
||||
case "tmux":
|
||||
tmux := m.Sess("tmux", m.Target())
|
||||
|
||||
buffer := m.Sess("cli").Cmd("system", "tmux", "show-buffer", "-b", "0")
|
||||
tmux.Option("buffer", buffer.Result(0))
|
||||
sessions := m.Sess("cli").Cmd("system", "tmux", "list-sessions")
|
||||
// sessions := m.Sess("cli").Cmd("system", "tmux", "list-sessions", "-F", "#S")
|
||||
tmux.Option("sessions", sessions.Result(0))
|
||||
}
|
||||
|
||||
m.Append("title", "upload")
|
||||
m.Append("tmpl", "userinfo", "share", "list", "git", "upload", "create")
|
||||
m.Append("tmpl", "userinfo", "share", "list", "git", "tmux", "upload", "create")
|
||||
m.Append("template", m.Conf("upload_main"), m.Conf("upload_tmpl"))
|
||||
// }}}
|
||||
}},
|
||||
@ -899,6 +909,11 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
}
|
||||
// }}}
|
||||
}},
|
||||
"/paste": &ctx.Command{Name: "/paste", Help: "应用示例", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
if login := m.Spawn().Cmd("/login"); login.Has("redirect") {
|
||||
m.Sess("cli").Cmd("system", "tmux", "set-buffer", "-b", "0", m.Option("content"))
|
||||
}
|
||||
}},
|
||||
"temp": &ctx.Command{Name: "temp", Help: "应用示例", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
msg := m.Spawn(m.Target())
|
||||
question := []string{}
|
||||
|
@ -85,6 +85,29 @@
|
||||
</fieldset>
|
||||
{{end}}
|
||||
|
||||
{{define "tmux"}}
|
||||
<fieldset><legend>sessions</legend>
|
||||
<pre>{{meta . "sessions"}}</pre>
|
||||
</fieldset>
|
||||
<fieldset><legend>buffer</legend>
|
||||
<button onclick="copy_tmux_buffer('copy')">copy</button>
|
||||
<button onclick="send_tmux_buffer('paste')">send</button>
|
||||
<textarea rows="5" cols="60" name="tmux_buffer">{{meta . "buffer" 0}}</textarea>
|
||||
</fieldset>
|
||||
<script>
|
||||
var buffer = document.getElementsByName("tmux_buffer")[0];
|
||||
function copy_tmux_buffer(action) {
|
||||
buffer.select();
|
||||
console.log(document.execCommand(action));
|
||||
}
|
||||
function send_tmux_buffer(action) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "/paste?content="+encodeURIComponent(buffer.value));
|
||||
xhr.send()
|
||||
}
|
||||
</script>
|
||||
{{end}}
|
||||
|
||||
{{define "upload"}}
|
||||
<fieldset><legend>upload</legend>
|
||||
<form method="POST" action="/create?dir={{option . "dir"}}" enctype="multipart/form-data">
|
||||
@ -117,6 +140,8 @@
|
||||
{{template "share" $sess.share}}
|
||||
{{else if eq . "list"}}
|
||||
{{template "list" $msg.Sessions.list.Meta}}
|
||||
{{else if eq . "tmux"}}
|
||||
{{template "tmux" $msg.Sessions.tmux.Meta}}
|
||||
{{else if eq . "git"}}
|
||||
{{if $msg.Sessions.git}}
|
||||
{{template "git" $msg.Sessions.git.Meta}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user