mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
opt xterm.js
This commit is contained in:
parent
44c610c203
commit
e829036e17
@ -214,7 +214,9 @@ func ZoneSelect(m *ice.Message, arg ...string) *ice.Message {
|
||||
arg = kit.Slice(arg, 0, 2)
|
||||
m.Fields(len(arg), kit.Fields(TIME, m.Config(SHORT), COUNT), m.Config(FIELD))
|
||||
if m.Cmdy(SELECT, m.PrefixKey(), "", ZONE, arg); kit.Select("", arg, 0) == "" {
|
||||
if m.Config(SHORT) != "" {
|
||||
m.Sort(m.Config(SHORT))
|
||||
}
|
||||
m.PushAction(REMOVE)
|
||||
}
|
||||
if len(arg) == 0 {
|
||||
|
@ -19,7 +19,7 @@ func _dream_list(m *ice.Message) *ice.Message {
|
||||
if m.Richs(SPACE, nil, value[mdb.NAME], func(key string, val ice.Map) {
|
||||
m.Push(mdb.TYPE, val[mdb.TYPE])
|
||||
m.Push(cli.STATUS, cli.START)
|
||||
m.PushButton("vimer", cli.OPEN, cli.STOP)
|
||||
m.PushButton("vimer", "xterm", cli.OPEN, cli.STOP)
|
||||
m.PushAnchor(strings.Split(m.MergePod(value[mdb.NAME]), "?")[0])
|
||||
}) == nil {
|
||||
m.Push(mdb.TYPE, WORKER)
|
||||
@ -123,6 +123,9 @@ func init() {
|
||||
"vimer": {Name: "vimer", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessOpen(m.MergePod(m.Option(mdb.NAME)+"/cmd/web.code.vimer", "", ""))
|
||||
}},
|
||||
"xterm": {Name: "xterm", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessOpen(m.MergePod(m.Option(mdb.NAME)+"/cmd/web.code.xterm", "", ""))
|
||||
}},
|
||||
cli.STOP: {Name: "stop", Help: "停止", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(SPACE, mdb.MODIFY, m.OptionSimple(mdb.NAME), mdb.STATUS, cli.STOP)
|
||||
m.Cmd(SPACE, m.Option(mdb.NAME), ice.EXIT)
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@ -390,6 +391,13 @@ func init() {
|
||||
"/require/usr/": {Name: "/require/usr/", Help: "代码库", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.RenderDownload(path.Join(ice.USR, path.Join(arg...)))
|
||||
}},
|
||||
"/require/node_modules/": {Name: "/require/node_modules/", Help: "依赖库", Hand: func(m *ice.Message, arg ...string) {
|
||||
p := path.Join(ice.USR_VOLCANOS, "node_modules", path.Join(arg...))
|
||||
if _, e := os.Stat(p); e != nil {
|
||||
m.Cmd(cli.SYSTEM, "npm", "install", arg[0], kit.Dict(cli.CMD_DIR, ice.USR_VOLCANOS))
|
||||
}
|
||||
m.RenderDownload(p)
|
||||
}},
|
||||
"/require/": {Name: "/require/", Help: "代码库", Hand: func(m *ice.Message, arg ...string) {
|
||||
_share_repos(m, path.Join(arg[0], arg[1], arg[2]), arg[3:]...)
|
||||
}},
|
||||
|
@ -190,6 +190,7 @@ func init() {
|
||||
}},
|
||||
|
||||
SHARE_TOAST: {Name: "/share/toast/", Help: "推送流", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Optionv(ice.MSG_OPTS, kit.Simple("hash"))
|
||||
m.Cmdy(SPACE, m.Option(ice.POD), m.Optionv("cmds"))
|
||||
}},
|
||||
SHARE_CACHE: {Name: "/share/cache/", Help: "缓存池", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -5,11 +5,11 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/creack/pty"
|
||||
pty "shylinux.com/x/creackpty"
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -22,36 +22,71 @@ func init() {
|
||||
cmd.Env = append(os.Environ(), "TERM=xterm")
|
||||
tty, err := pty.Start(cmd)
|
||||
m.Assert(err)
|
||||
cache.Store(key, tty)
|
||||
|
||||
m.Go(func() {
|
||||
defer m.Cmd(m.PrefixKey(), mdb.PRUNES)
|
||||
defer cache.Delete(key)
|
||||
buf := make([]byte, 1024)
|
||||
for {
|
||||
if n, e := tty.Read(buf); m.Assert(e) {
|
||||
m.PushNotice("grow", base64.StdEncoding.EncodeToString(buf[:n]))
|
||||
if n, e := tty.Read(buf); !m.Warn(e) {
|
||||
m.Optionv(ice.MSG_OPTS, kit.Simple("hash"))
|
||||
m.Option(mdb.HASH, key)
|
||||
m.Option(ice.MSG_DAEMON, m.Conf(m.PrefixKey(), kit.Keys(mdb.HASH, key, mdb.META, mdb.TEXT)))
|
||||
m.PushNoticeGrow(kit.Format(kit.Dict(mdb.TYPE, "data", mdb.TEXT, base64.StdEncoding.EncodeToString(buf[:n]))))
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
m.PushNoticeGrow(kit.Format(kit.Dict(mdb.TYPE, "exit")))
|
||||
})
|
||||
|
||||
cache.Store(key, tty)
|
||||
return key
|
||||
}
|
||||
Index.MergeCommands(ice.Commands{
|
||||
XTERM: {Name: "xterm auto", Help: "终端", Actions: ice.MergeAction(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Watch(web.SPACE_STOP, m.PrefixKey())
|
||||
}},
|
||||
web.SPACE_STOP: {Name: "space.stop", Help: "断开连接", Hand: func(m *ice.Message, arg ...string) {
|
||||
get := func(m *ice.Message, key string) *os.File {
|
||||
if w, ok := cache.Load(key); ok {
|
||||
if w, ok := w.(*os.File); ok {
|
||||
return w
|
||||
}
|
||||
}
|
||||
add(m, key)
|
||||
if w, ok := cache.Load(key); ok {
|
||||
if w, ok := w.(*os.File); ok {
|
||||
return w
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Index.MergeCommands(ice.Commands{
|
||||
XTERM: {Name: "xterm hash id auto prunes", Help: "终端", Actions: ice.MergeAction(ice.Actions{
|
||||
mdb.CREATE: {Name: "create type name", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(mdb.TEXT, m.Option(ice.MSG_DAEMON)) != "" {
|
||||
m.Echo(add(m, m.Cmdx(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, m.OptionSimple("type,name,text"))))
|
||||
}
|
||||
}},
|
||||
"resize": {Name: "resize", Help: "大小", Hand: func(m *ice.Message, arg ...string) {
|
||||
pty.Setsize(get(m, m.Option(mdb.HASH)), &pty.Winsize{Rows: uint16(kit.Int(m.Option("rows"))), Cols: uint16(kit.Int(m.Option("cols")))})
|
||||
}},
|
||||
"select": {Name: "select", Help: "连接", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(mdb.MODIFY, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(mdb.HASH), mdb.TEXT, m.Option(ice.MSG_DAEMON))
|
||||
}},
|
||||
"input": {Name: "input", Help: "输入", Hand: func(m *ice.Message, arg ...string) {
|
||||
if w, ok := cache.Load(m.Option("channel")); ok {
|
||||
if w, ok := w.(*os.File); ok {
|
||||
w.Write([]byte(arg[0]))
|
||||
return
|
||||
}
|
||||
}
|
||||
m.Cmd(mdb.MODIFY, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(mdb.HASH), mdb.TIME, m.Time())
|
||||
get(m, m.Option(mdb.HASH)).Write([]byte(arg[0]))
|
||||
}},
|
||||
}, mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
m.DisplayLocal("", "channel", add(m, kit.Hashs(mdb.UNIQ)))
|
||||
mdb.PRUNES: {Name: "prunes", Help: "清理", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(m.CommandKey()).Tables(func(value ice.Maps) {
|
||||
if _, ok := cache.Load(value[mdb.HASH]); !ok || kit.Time(m.Time())-kit.Time(value[mdb.TIME]) > int64(time.Hour) {
|
||||
m.Cmdy(mdb.DELETE, m.PrefixKey(), "", mdb.HASH, mdb.HASH, value[mdb.HASH])
|
||||
}
|
||||
})
|
||||
}},
|
||||
}, mdb.ZoneAction(mdb.FIELD, "time,id,type,name,text")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.OptionFields("time,hash,type,name,text")
|
||||
}
|
||||
mdb.ZoneSelect(m, kit.Slice(arg, 0, 2)...)
|
||||
m.DisplayLocal("")
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
14
core/mall/paper.go
Normal file
14
core/mall/paper.go
Normal file
@ -0,0 +1,14 @@
|
||||
package mall
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
)
|
||||
|
||||
const PAPER = "paper"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
PAPER: {Name: "paper", Help: "问卷", Actions: ice.MergeAction(ice.Actions{}, mdb.ZoneAction(mdb.FIELD, "time,id,type,name,text"))},
|
||||
})
|
||||
}
|
1
go.mod
1
go.mod
@ -3,6 +3,7 @@ module shylinux.com/x/icebergs
|
||||
go 1.11
|
||||
|
||||
require (
|
||||
shylinux.com/x/creackpty v0.0.1
|
||||
shylinux.com/x/go-qrcode v0.0.1
|
||||
shylinux.com/x/toolkits v0.6.2
|
||||
shylinux.com/x/websocket v0.0.1
|
||||
|
1
go.sum
1
go.sum
@ -1,3 +1,4 @@
|
||||
shylinux.com/x/creackpty v0.0.1/go.mod h1:d7DnPv3oGc23WlzrN8hW7p88wNLPAO/XG4ICVEq96i0=
|
||||
shylinux.com/x/go-qrcode v0.0.1 h1:/eOGqMj1qtgs9Ymd12zTUa1gcJZs9S92kj2lb0QzKsE=
|
||||
shylinux.com/x/go-qrcode v0.0.1/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po=
|
||||
shylinux.com/x/toolkits v0.6.2 h1:WSeAEOiwZ/Ws4v5NvjFJ/h1HJkzMd0mXVCmeQnQlkyw=
|
||||
|
@ -184,7 +184,7 @@ func (m *Message) PushNotice(arg ...Any) {
|
||||
if m.Option(MSG_USERPOD) == "" {
|
||||
m.Cmd(SPACE, m.Option(MSG_DAEMON), arg)
|
||||
} else {
|
||||
m.Cmd("web.spide", OPS, m.MergeURL2("/share/toast/"), kit.Format(kit.Dict(POD, m.Option(MSG_DAEMON), "cmds", kit.Simple(arg...))))
|
||||
m.Cmd("web.spide", OPS, m.MergeURL2("/share/toast/"), kit.Format(kit.Dict("hash", m.Option("hash"), POD, m.Option(MSG_DAEMON), "cmds", kit.Simple(arg...))))
|
||||
}
|
||||
}
|
||||
func (m *Message) PushNoticeGrow(arg ...Any) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user