1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-28 18:22:02 +08:00
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-08-03 12:14:49 +08:00
parent dae59b423c
commit 0b7f4873f0
14 changed files with 89 additions and 40 deletions

View File

@ -77,8 +77,11 @@ func init() {
}}, }},
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
if len(arg) > 0 && arg[0] != "" && arg[0] != ice.EXIT { if len(arg) > 0 && arg[0] != "" && arg[0] != ice.EXIT {
m.Cmdy(arg).Search(arg[0], func(key string, cmd *ice.Command) { m.Search(arg[0], func(key string, cmd *ice.Command) {
m.Cut(kit.Format(kit.Value(cmd.List, kit.Format("%d.name", len(arg)-1)))) field := kit.Format(kit.Value(cmd.List, kit.Format("%d.name", len(arg)-1)))
if m.Cmdy(arg[0], mdb.INPUTS, field); m.Length() == 0 {
m.Cmdy(arg).Cut(field)
}
}) })
} }
}}, }},

View File

@ -277,6 +277,9 @@ func ImportantHashAction(arg ...Any) ice.Actions {
}, HashAction(arg...)) }, HashAction(arg...))
} }
func saveImportant(m *ice.Message, key, sub string, arg ...string) { func saveImportant(m *ice.Message, key, sub string, arg ...string) {
if m.Option("skip.important") == ice.TRUE {
return
}
kit.If(m.Conf(key, kit.Keys(META, "important")) == ice.TRUE, func() { ice.SaveImportant(m, arg...) }) kit.If(m.Conf(key, kit.Keys(META, "important")) == ice.TRUE, func() { ice.SaveImportant(m, arg...) })
} }
func ToMaps(value Map) Maps { func ToMaps(value Map) Maps {

View File

@ -123,7 +123,7 @@ func _dir_list(m *ice.Message, root string, dir string, level int, deep bool, di
} }
if deep && isDir { if deep && isDir {
switch s.Name() { switch s.Name() {
case "pluged": case "pluged", "node_modules":
continue continue
} }
_total, _last := _dir_list(m, root, pp, level+1, deep, dir_type, dir_reg, fields) _total, _last := _dir_list(m, root, pp, level+1, deep, dir_type, dir_reg, fields)

View File

@ -63,7 +63,7 @@ func init() {
} }
}}, }},
ISLOCAL: {Hand: func(m *ice.Message, arg ...string) { ISLOCAL: {Hand: func(m *ice.Message, arg ...string) {
if arg[0] = strings.Split(strings.TrimPrefix(arg[0], "["), "]")[0]; arg[0] == "::1" || strings.HasPrefix(arg[0], "127.") { if arg[0] = strings.Split(strings.TrimPrefix(arg[0], "["), "]")[0]; arg[0] == "::1" || strings.HasPrefix(arg[0], "127.") || arg[0] == LOCALHOST {
m.Echo(ice.OK) m.Echo(ice.OK)
} else if mdb.HashSelectField(m, strings.Split(arg[0], nfs.DF)[0], mdb.TYPE) == aaa.WHITE { } else if mdb.HashSelectField(m, strings.Split(arg[0], nfs.DF)[0], mdb.TYPE) == aaa.WHITE {
m.Echo(ice.OK) m.Echo(ice.OK)

View File

@ -9,4 +9,5 @@ const (
const ( const (
FLOAT = "float" FLOAT = "float"
OUTPUT = "output"
) )

View File

@ -90,17 +90,14 @@ func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) {
if next := msg.Option(ice.MSG_TARGET); next == "" || len(target) == 0 { if next := msg.Option(ice.MSG_TARGET); next == "" || len(target) == 0 {
m.Go(func() { _space_exec(msg, source, target, c) }, strings.Join(kit.Simple(SPACE, name, msg.Detailv()), lex.SP)) m.Go(func() { _space_exec(msg, source, target, c) }, strings.Join(kit.Simple(SPACE, name, msg.Detailv()), lex.SP))
} else { } else {
done := false
m.Warn(!mdb.HashSelectDetail(m, next, func(value ice.Map) { m.Warn(!mdb.HashSelectDetail(m, next, func(value ice.Map) {
switch c := value[mdb.TARGET].(type) { switch c := value[mdb.TARGET].(type) {
case (*websocket.Conn): // 转发报文 case (*websocket.Conn): // 转发报文
_space_echo(msg, source, target, c) _space_echo(msg, source, target, c)
case ice.Handler: // 接收响应 case ice.Handler: // 接收响应
done = true m.Go(func() { c(msg) })
c(msg)
} }
}), ice.ErrNotFound, next) }), ice.ErrNotFound, next)
kit.If(done, func() { mdb.HashRemove(m, mdb.HASH, next) })
} }
} }
} }

View File

@ -1,6 +1,8 @@
(function() {
const ACTION_STORE = "web.flows:action:"
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg, cb) { can.onmotion.clear(can), can.ui = can.onappend.layout(can), can.onmotion.hidden(can, can.ui.profile), can.onmotion.hidden(can, can.ui.display) _init: function(can, msg, cb) { can.onmotion.clear(can), can.ui = can.onappend.layout(can), can.onmotion.hidden(can, can.ui.profile), can.onmotion.hidden(can, can.ui.display)
cb && cb(msg), can.core.Item(can.Action(), function(key) { can.onaction[key] = can.onaction[key]||can.onaction.refresh, can.Action(key, can.misc.localStorage(can, "web.flows.action."+key)) }), can.onkeymap._build(can) cb && cb(msg), can.core.Item(can.Action(), function(key) { can.onaction[key] = can.onaction[key]||can.onaction.refresh, can.Action(key, can.misc.localStorage(can, ACTION_STORE+key)) }), can.onkeymap._build(can)
if (can.Option(mdb.ZONE)) { return can.onmotion.hidden(can, can.ui.project), can.onimport._content(can, msg, can.Option(mdb.ZONE)) } can.onimport._project(can, msg) if (can.Option(mdb.ZONE)) { return can.onmotion.hidden(can, can.ui.project), can.onimport._content(can, msg, can.Option(mdb.ZONE)) } can.onimport._project(can, msg)
}, },
_project: function(can, msg) { var target; msg.Table(function(value) { _project: function(can, msg) { var target; msg.Table(function(value) {
@ -122,7 +124,7 @@ Volcanos(chat.ONACTION, {
[html.MARGIN, 20, 40, 60], [html.MARGIN, 20, 40, 60],
["delay", 100, 200, 500, 1000], ["delay", 100, 200, 500, 1000],
], _trans: {play: "播放", prev: "上一步", next: "下一步"}, ], _trans: {play: "播放", prev: "上一步", next: "下一步"},
refresh: function(event, can, button) { can.misc.localStorage(can, "web.flows.action."+button, can.Action(button)), can.onimport._flows(can, can.db._content_plugin) }, refresh: function(event, can, button) { can.misc.localStorage(can, ACTION_STORE+button, can.Action(button)), can.onimport._flows(can, can.db._content_plugin) },
travel: function() {}, delay: function() {}, travel: function() {}, delay: function() {},
play: function(event, can) { var list = can.onexport.travel(can, can.db.root, true) play: function(event, can) { var list = can.onexport.travel(can, can.db.root, true)
can.core.List(list, function(item) { item._line && item._line.Value(html.CLASS, ""), item._rect.Value(html.CLASS, ""), item._text.Value(html.CLASS, "") }) can.core.List(list, function(item) { item._line && item._line.Value(html.CLASS, ""), item._rect.Value(html.CLASS, ""), item._text.Value(html.CLASS, "") })
@ -192,3 +194,4 @@ Volcanos(chat.ONKEYMAP, {
ArrowDown: shy("下一步", function(event, can) { can.db.current && can.db.current.to? can.ondetail._select(event, can, can.db.current.to): can.onaction.next(event, can) }), ArrowDown: shy("下一步", function(event, can) { can.db.current && can.db.current.to? can.ondetail._select(event, can, can.db.current.to): can.onaction.next(event, can) }),
}}, _engine: {}, }}, _engine: {},
}) })
})()

View File

@ -32,9 +32,11 @@ func init() {
m.Push(arg[0], web.UserWeb(m).Host) m.Push(arg[0], web.UserWeb(m).Host)
case mdb.LINK: case mdb.LINK:
m.Push(arg[0], m.Option(ice.MSG_USERWEB)) m.Push(arg[0], m.Option(ice.MSG_USERWEB))
m.Push(arg[0], "http://localhost:20000")
m.Push(arg[0], "http://localhost:20001")
m.Copy(m.Cmd(web.SPIDE).CutTo(web.CLIENT_URL, arg[0])) m.Copy(m.Cmd(web.SPIDE).CutTo(web.CLIENT_URL, arg[0]))
case mdb.HASH:
m.Cmd(mdb.SEARCH, mdb.FOREACH, "", "type,name,text", func(value ice.Maps) {
kit.If(value[mdb.TYPE] == "link", func() { m.Push(arg[0], value[mdb.TEXT]) })
})
} }
}}, }},
FAVOR_INPUTS: {Hand: func(m *ice.Message, arg ...string) { FAVOR_INPUTS: {Hand: func(m *ice.Message, arg ...string) {

View File

@ -21,9 +21,7 @@ func _inner_list(m *ice.Message, ext, file, dir string) {
m.Cmdy(nfs.CAT, path.Join(dir, file)) m.Cmdy(nfs.CAT, path.Join(dir, file))
}, func() { }, func() {
_inner_show(m.RenderResult().SetResult(), ext, file, dir) _inner_show(m.RenderResult().SetResult(), ext, file, dir)
if m.Result() == "" { kit.If(m.Result() == "", func() { m.Cmdy(nfs.CAT, path.Join(dir, file)) })
m.Cmdy(nfs.CAT, path.Join(dir, file))
}
}) })
}) })
} }
@ -101,9 +99,7 @@ func init() {
case ctx.INDEX: case ctx.INDEX:
m.Cmdy(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND, ice.OptionFields(ctx.INDEX)) m.Cmdy(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND, ice.OptionFields(ctx.INDEX))
case ctx.ARGS: case ctx.ARGS:
kit.If(m.Option(ctx.INDEX) != "", func() { m.Cmdy(ctx.COMMAND, mdb.INPUTS, m.Option(ctx.INDEX))
m.Cmdy(m.Option(ctx.INDEX)).Search(m.Option(ctx.INDEX), func(key string, cmd *ice.Command) { m.Cut(kit.Format(kit.Value(cmd.List, "0.name"))) })
})
case nfs.PATH: case nfs.PATH:
m.Cmdy(nfs.DIR, p, nfs.DIR_CLI_FIELDS) m.Cmdy(nfs.DIR, p, nfs.DIR_CLI_FIELDS)
kit.If(strings.HasPrefix(p, bind[0]), func() { m.Cmdy(nfs.DIR, strings.Replace(p, bind[0], bind[1], 1), nfs.DIR_CLI_FIELDS) }) kit.If(strings.HasPrefix(p, bind[0]), func() { m.Cmdy(nfs.DIR, strings.Replace(p, bind[0], bind[1], 1), nfs.DIR_CLI_FIELDS) })

28
core/code/makefile.go Normal file
View File

@ -0,0 +1,28 @@
package code
import (
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/web/html"
kit "shylinux.com/x/toolkits"
)
func _makefile_xterm(m *ice.Message, arg ...string) {
ctx.Process(m, XTERM, func() []string {
m.Push(ctx.STYLE, html.OUTPUT)
return []string{mdb.TYPE, "sh", nfs.PATH, kit.Select("", kit.Dir(arg[2], arg[1]), arg[2] != ice.SRC)}
}, arg...)
}
const MAKEFILE = "makefile"
func init() {
Index.MergeCommands(ice.Commands{
MAKEFILE: {Name: "makefile path auto", Help: "构建", Actions: ice.MergeActions(ice.Actions{
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _makefile_xterm(m, arg...) }},
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _makefile_xterm(m, arg...) }},
}, PlugAction())},
})
}

View File

@ -33,14 +33,6 @@ const SH = nfs.SH
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
SH: {Name: "sh path auto", Help: "命令", Actions: ice.MergeActions(ice.Actions{ SH: {Name: "sh path auto", Help: "命令", Actions: ice.MergeActions(ice.Actions{
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
if arg[0] == mdb.FOREACH && arg[1] == ssh.SHELL {
return
m.Cmd(nfs.CAT, "/etc/shells", func(text string) {
kit.If(text != "" && !strings.HasPrefix(text, "#"), func() { m.PushSearch(mdb.TYPE, ssh.SHELL, mdb.NAME, path.Base(text), mdb.TEXT, path.Base(text)) })
})
}
}},
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
cmds, text := _sh_cmds(m, path.Join(arg[2], arg[1])) cmds, text := _sh_cmds(m, path.Join(arg[2], arg[1]))
ProcessXterm(m, cmds, text, path.Join(arg[2], arg[1])) ProcessXterm(m, cmds, text, path.Join(arg[2], arg[1]))

View File

@ -21,6 +21,7 @@ import (
func _xterm_get(m *ice.Message, h string) xterm.XTerm { func _xterm_get(m *ice.Message, h string) xterm.XTerm {
h = kit.Select(m.Option(mdb.HASH), h) h = kit.Select(m.Option(mdb.HASH), h)
m.Assert(h != "") m.Assert(h != "")
m.Option("skip.important", ice.TRUE)
if m.Option(ice.MSG_USERPOD) == "" { if m.Option(ice.MSG_USERPOD) == "" {
mdb.HashModify(m, mdb.TIME, m.Time(), cli.DAEMON, kit.Keys(m.Option(ice.MSG_DAEMON))) mdb.HashModify(m, mdb.TIME, m.Time(), cli.DAEMON, kit.Keys(m.Option(ice.MSG_DAEMON)))
} else { } else {
@ -60,7 +61,7 @@ func _xterm_get(m *ice.Message, h string) xterm.XTerm {
}).(xterm.XTerm) }).(xterm.XTerm)
} }
func _xterm_echo(m *ice.Message, h string, str string) { func _xterm_echo(m *ice.Message, h string, str string) {
m.Options(ice.LOG_DISABLE, ice.TRUE, "__target", "", ice.MSG_DAEMON, mdb.HashSelectField(m, h, cli.DAEMON)) m.Options(ice.MSG_COUNT, "0", ice.LOG_DISABLE, ice.TRUE, "__target", "", ice.MSG_DAEMON, mdb.HashSelectField(m, h, cli.DAEMON))
web.PushNoticeGrow(m, h, str) web.PushNoticeGrow(m, h, str)
} }
func _xterm_cmds(m *ice.Message, h string, cmd string, arg ...ice.Any) { func _xterm_cmds(m *ice.Message, h string, cmd string, arg ...ice.Any) {
@ -126,7 +127,11 @@ func init() {
}}, }},
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }}, web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }},
ctx.PROCESS: {Hand: func(m *ice.Message, arg ...string) { ctx.PROCESS: {Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 1 {
ctx.ProcessField(m, m.PrefixKey(), arg, arg...)
} else {
ctx.ProcessField(m, m.PrefixKey(), func() string { return m.Cmdx("", mdb.CREATE, arg) }, arg...) ctx.ProcessField(m, m.PrefixKey(), func() string { return m.Cmdx("", mdb.CREATE, arg) }, arg...)
}
}}, }},
"terminal": {Help: "本机", Hand: func(m *ice.Message, arg ...string) { "terminal": {Help: "本机", Hand: func(m *ice.Message, arg ...string) {
if h := kit.Select(m.Option(mdb.HASH), arg, 0); h == "" { if h := kit.Select(m.Option(mdb.HASH), arg, 0); h == "" {
@ -162,5 +167,11 @@ end tell
} }
func ProcessXterm(m *ice.Message, cmds, text string, arg ...string) { func ProcessXterm(m *ice.Message, cmds, text string, arg ...string) {
ctx.Process(m, XTERM, []string{mdb.TYPE, cmds, mdb.NAME, kit.Select("", arg, 0), mdb.TEXT, text}, arg...) ctx.Process(m, XTERM, func() []string {
if ls := kit.Simple(kit.UnMarshal(m.Option(ctx.ARGS))); len(ls) > 0 {
return ls
} else {
return []string{mdb.TYPE, cmds, mdb.NAME, kit.Select("", arg, 0), mdb.TEXT, text}
}
}, arg...)
} }

View File

@ -8,6 +8,7 @@ import (
"shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/lex"
"shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/tcp"
kit "shylinux.com/x/toolkits" kit "shylinux.com/x/toolkits"
"shylinux.com/x/webview" "shylinux.com/x/webview"
) )
@ -47,12 +48,21 @@ func (w WebView) Menu() bool {
} }
func (w WebView) Title(text string) { w.WebView.SetTitle(text) } func (w WebView) Title(text string) { w.WebView.SetTitle(text) }
func (w WebView) Webview(url string) { w.WebView.Navigate(url) } func (w WebView) Webview(url string) { w.WebView.Navigate(url) }
func (w WebView) Open(url string) { w.WebView.Navigate(url) } func (w WebView) Open(url string) {
func (w WebView) OpenUrl(url string) { cli.Opens(ice.Pulse, url) } w.Message.Debug("open %v", url)
func (w WebView) OpenApp(app string) { cli.Opens(ice.Pulse, app) } w.WebView.Navigate(url)
}
func (w WebView) OpenUrl(url string) {
w.Message.Debug("open %v", url)
cli.Opens(w.Message, url)
}
func (w WebView) OpenApp(app string) {
w.Message.Debug("open %v", app)
cli.Opens(w.Message, app)
}
func (w WebView) OpenCmd(cmd string) { func (w WebView) OpenCmd(cmd string) {
w.Cmd(nfs.SAVE, kit.HomePath(".bash_temp"), cmd) w.Cmd(nfs.SAVE, kit.HomePath(".bash_temp"), cmd)
cli.Opens(ice.Pulse, "Terminal.app", "-n") cli.Opens(w.Message, "Terminal.app", "-n")
} }
func (w WebView) SetSize(width, height int) { func (w WebView) SetSize(width, height int) {
w.Cmd(nfs.SAVE, "etc/webview.size", kit.Format("%v,%v", width, height)) w.Cmd(nfs.SAVE, "etc/webview.size", kit.Format("%v,%v", width, height))
@ -67,7 +77,10 @@ func (w WebView) Power() string {
return "" return ""
} }
func (w WebView) Close() { kit.If(!w.Menu(), func() { w.WebView.Terminate() }) } func (w WebView) Close() { kit.If(!w.Menu(), func() { w.WebView.Terminate() }) }
func (w WebView) Terminate() { w.WebView.Terminate() } func (w WebView) Terminate() {
w.WebView.Eval("window.onbeforeunload()")
w.WebView.Terminate()
}
func (w WebView) navigate(url string) { func (w WebView) navigate(url string) {
w.WebView.SetSize(1200, 800, webview.HintNone) w.WebView.SetSize(1200, 800, webview.HintNone)
w.WebView.Navigate(url) w.WebView.Navigate(url)
@ -77,7 +90,7 @@ func Run(cb func(*WebView) ice.Any) {
w := webview.New(true) w := webview.New(true)
defer w.Destroy() defer w.Destroy()
defer w.Run() defer w.Run()
view := &WebView{Source: "etc/webview.txt", WebView: w, Message: ice.Pulse} view := &WebView{Source: "etc/webview.txt", WebView: w, Message: ice.Pulse.Spawn(kit.Dict(ice.MSG_USERIP, tcp.LOCALHOST))}
if cb == nil { if cb == nil {
kit.Reflect(view, func(name string, value ice.Any) { w.Bind(name, value) }) kit.Reflect(view, func(name string, value ice.Any) { w.Bind(name, value) })
} else { } else {

View File

@ -190,15 +190,15 @@ func (m *Message) PushDownload(key string, arg ...string) *Message {
return m return m
} }
func (m *Message) EchoFields(cmd string) *Message { func (m *Message) EchoFields(cmd string, arg ...string) *Message {
return m.Echo(`<fieldset class="story" data-index="%s"> return m.Echo(`<fieldset class="story" data-index="%s" data-args=%q>
<legend></legend> <legend></legend>
<form class="option"></form> <form class="option"></form>
<div class="action"></div> <div class="action"></div>
<div class="output"></div> <div class="output"></div>
<div class="status"></div> <div class="status"></div>
</fieldset> </fieldset>
`, cmd) `, cmd, kit.Join(arg))
} }
func (m *Message) EchoButton(arg ...Any) *Message { return m.Echo(Render(m, RENDER_BUTTON, arg...)) } func (m *Message) EchoButton(arg ...Any) *Message { return m.Echo(Render(m, RENDER_BUTTON, arg...)) }
func (m *Message) EchoAnchor(arg ...string) *Message { return m.Echo(Render(m, RENDER_ANCHOR, arg)) } func (m *Message) EchoAnchor(arg ...string) *Message { return m.Echo(Render(m, RENDER_ANCHOR, arg)) }