From 8b23ad92e08b83996716c3df91dc5f2f66e05d76 Mon Sep 17 00:00:00 2001 From: shy Date: Fri, 5 Jul 2024 20:51:24 +0800 Subject: [PATCH] add some --- base/web/product.go | 2 +- base/web/serve.go | 13 +++++++++++-- base/web/space.go | 10 ++++------ base/web/token.go | 2 +- core/code/compile.go | 3 +-- core/code/version.go | 1 - core/wiki/spark.go | 2 +- data.go | 2 +- init.go | 2 +- misc/git/repos.go | 1 - misc/wx/login.go | 1 - 11 files changed, 21 insertions(+), 18 deletions(-) diff --git a/base/web/product.go b/base/web/product.go index a5e74743..0a685eba 100644 --- a/base/web/product.go +++ b/base/web/product.go @@ -11,7 +11,7 @@ const PRODUCT = "product" func init() { Index.MergeCommands(ice.Commands{ - PRODUCT: {Name: "product refresh", Help: "产品展示", Actions: mdb.HashAction(mdb.SHORT, "index", mdb.FIELD, "time,name,text,order,disable,index,args"), Hand: func(m *ice.Message, arg ...string) { + PRODUCT: {Name: "product refresh", Help: "产品展示", Actions: mdb.HashAction(mdb.SHORT, "index", mdb.FIELD, "time,name,text,order,enable,index,args"), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...).SortInt(mdb.ORDER) }}, }) diff --git a/base/web/serve.go b/base/web/serve.go index 8f895546..8ab17bb5 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -39,8 +39,16 @@ func _serve_start(m *ice.Message) { return } kit.For(kit.Split(m.Option(ice.DEV)), func(dev string) { - if m.Cmds(SPIDE, dev).Append(TOKEN) == "" { - m.Sleep30ms(SPACE, tcp.DIAL, ice.DEV, dev, mdb.NAME, ice.Info.NodeName, m.OptionSimple(TOKEN)) + if strings.HasPrefix(dev, HTTP) { + m.Cmd(SPIDE, mdb.CREATE, dev, ice.DEV, "", nfs.REPOS) + dev = ice.DEV + } + if msg := m.Cmds(SPIDE, dev); msg.Append(TOKEN) == "" { + if m.Option(TOKEN) != "" { + m.Sleep30ms(SPACE, tcp.DIAL, ice.DEV, dev, TOKEN, m.Option(TOKEN)) + } else { + m.Sleep30ms(SPACE, tcp.DIAL, ice.DEV, dev) + } } }) } @@ -261,6 +269,7 @@ func init() { if cb, ok := m.Optionv(SERVE_START).(func()); ok { cb() } + ice.Info.Important = ice.HasVar() }}, PROXY_CONF: {Name: "proxyConf name* port host path", Hand: func(m *ice.Message, arg ...string) { if dir := m.OptionDefault(nfs.PATH, PROXY_PATH, tcp.HOST, "127.0.0.1", tcp.PORT, tcp.PORT_9020); true || nfs.Exists(m, dir) { diff --git a/base/web/space.go b/base/web/space.go index 52cc83c9..dac5d22b 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -112,7 +112,7 @@ func _space_fork(m *ice.Message) { defer gdb.EventDeferEvent(m, SPACE_OPEN, args)(SPACE_CLOSE, args) m.Go(func() { SpacePwd(m, name, "") - SpaceEvent(m, OPS_SERVER_OPEN, name, args...) + SpaceEvent(m.Spawn(ice.MSG_USERROLE, aaa.TECH), OPS_SERVER_OPEN, name, args...) }) } _space_handle(m, safe, name, c) @@ -129,7 +129,9 @@ func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) { } msg := m.Spawn(b) if safe && msg.Option(ice.MSG_UNSAFE) != ice.TRUE { // 下行权限 - msg.Option(ice.MSG_USERROLE, kit.Select(msg.Option(ice.MSG_USERROLE), aaa.UserRole(msg, msg.Option(ice.MSG_USERNAME)))) + if !aaa.IsTechOrRoot(msg) { + msg.Option(ice.MSG_USERROLE, kit.Select(msg.Option(ice.MSG_USERROLE), aaa.UserRole(msg, msg.Option(ice.MSG_USERNAME)))) + } // kit.If(kit.IsIn(msg.Option(ice.MSG_USERROLE), "", aaa.VOID), func() { msg.Option(ice.MSG_USERROLE, aaa.UserRole(msg, msg.Option(ice.MSG_USERNAME))) }) } else { // 上行权限 msg.Option(ice.MSG_UNSAFE, ice.TRUE) @@ -355,10 +357,6 @@ func init() { }}, cli.START: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("", tcp.DIAL, arg) }}, tcp.DIAL: {Name: "dial dev=ops name", Hand: func(m *ice.Message, arg ...string) { - if strings.HasPrefix(m.Option(ice.DEV), HTTP) { - m.Cmd(SPIDE, mdb.CREATE, m.Option(ice.DEV), ice.DEV) - m.Option(ice.DEV, ice.DEV) - } _space_dial(m, m.Option(ice.DEV), kit.Select(ice.Info.NodeName, m.Option(mdb.NAME)), arg...) }}, cli.CLOSE: {Hand: func(m *ice.Message, arg ...string) { mdb.HashRemove(m, m.OptionSimple(mdb.NAME)) }}, diff --git a/base/web/token.go b/base/web/token.go index c31178ac..78de433b 100644 --- a/base/web/token.go +++ b/base/web/token.go @@ -25,7 +25,7 @@ func init() { } }) }}, - }, mdb.HashAction(mdb.SHORT, mdb.UNIQ, mdb.EXPIRE, mdb.MONTH, html.CHECKBOX, ice.TRUE)), Hand: func(m *ice.Message, arg ...string) { + }, mdb.ExportHashAction(mdb.SHORT, mdb.UNIQ, mdb.EXPIRE, mdb.MONTH, html.CHECKBOX, ice.TRUE)), Hand: func(m *ice.Message, arg ...string) { if mdb.HashSelect(m, arg...); len(arg) > 0 { m.EchoScript(kit.MergeURL2(m.Option(ice.MSG_USERWEB), nfs.PS, TOKEN, arg[0])) } else { diff --git a/core/code/compile.go b/core/code/compile.go index 64138bed..27196713 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -111,12 +111,11 @@ func init() { kit.If(cli.SystemFindGo(m), func() { m.PushButton(kit.Dict(m.CommandKey(), m.Commands("").Help)) }) }) }}, - }, web.DreamTablesAction(), ctx.ConfAction(cli.ENV, kit.Dict(GOPRIVATE, "shylinux.com,github.com", GOPROXY, "https://goproxy.cn,direct", CGO_ENABLED, "1"))), Hand: func(m *ice.Message, arg ...string) { + }, web.DreamTablesAction(), ctx.ConfAction(cli.ENV, kit.Dict(GOPRIVATE, "shylinux.com,github.com", GOPROXY, "https://goproxy.cn,direct", CGO_ENABLED, "0"))), Hand: func(m *ice.Message, arg ...string) { main, file, goos, arch := _compile_target(m, arg...) defer web.ToastProcess(m, file)() env := kit.Simple(cli.PATH, cli.BinPath(), cli.HOME, kit.Select(kit.Path(""), kit.Env(cli.HOME)), mdb.Configv(m, cli.ENV), m.Optionv(cli.ENV), cli.GOOS, goos, cli.GOARCH, arch) kit.If(runtime.GOOS == cli.WINDOWS, func() { env = append(env, GOPATH, kit.HomePath(GO), GOCACHE, kit.HomePath("go/go-build")) }) - env = append(env, CGO_ENABLED, "1") m.Options(cli.CMD_ENV, env).Cmd(AUTOGEN, VERSION) _compile_get(m, main) defer m.StatusTime(VERSION, strings.TrimPrefix(GoVersion(m), "go version")) diff --git a/core/code/version.go b/core/code/version.go index d3dc9361..378cc05f 100644 --- a/core/code/version.go +++ b/core/code/version.go @@ -34,7 +34,6 @@ func init() { res := m.Cmdx(nfs.CAT, path.Join(nfs.USR_LOCAL_WORK, m.Option(web.SPACE), ice.GO_MOD), func(ls []string, text string) string { if len(ls) > 1 { if v, ok := repos[ls[0]]; ok && !strings.Contains(v, "-") { - m.Debug("what %v %v => %v", ls[0], ls[1], v) text = lex.TB + ls[0] + lex.SP + v } } diff --git a/core/wiki/spark.go b/core/wiki/spark.go index c32840bb..a7becab8 100644 --- a/core/wiki/spark.go +++ b/core/wiki/spark.go @@ -140,7 +140,7 @@ open http://localhost:9020 func _spark_product(m *ice.Message, arg ...string) { if len(arg) == 0 { m.Cmd("web.product").Table(func(value ice.Maps) { - if value[mdb.DISABLE] != ice.FALSE { + if value[mdb.ENABLE] == ice.TRUE { _spark_product(m, value[ctx.INDEX], value[mdb.NAME], value[mdb.TEXT]) } }) diff --git a/data.go b/data.go index 9b19ffb3..95db84fb 100644 --- a/data.go +++ b/data.go @@ -70,6 +70,6 @@ func loadImportant(m *Message) { defer f.Close() kit.For(f, func(s string) { kit.If(s != "" && !strings.HasPrefix(s, "# "), func() { m.Cmd(kit.Split(s)) }) }) } - Info.Important = HasVar() + // Info.Important = HasVar() } func removeImportant(m *Message) { os.Remove(VAR_DATA_IMPORTANT) } diff --git a/init.go b/init.go index c1f27992..5a96750f 100644 --- a/init.go +++ b/init.go @@ -26,7 +26,7 @@ func (s *Frame) Begin(m *Message, arg ...string) { func (s *Frame) Start(m *Message, arg ...string) { m.Cmd(INIT, arg) kit.For([]string{LOG, GDB, SSH}, func(k string) { m.Sleep30ms().Start(k) }) - Info.Important = HasVar() + // Info.Important = HasVar() m.Sleep30ms().Cmd(arg) } func (s *Frame) Close(m *Message, arg ...string) { diff --git a/misc/git/repos.go b/misc/git/repos.go index 62428db5..1f0d8b58 100644 --- a/misc/git/repos.go +++ b/misc/git/repos.go @@ -569,7 +569,6 @@ func init() { }}, STATUS: {Help: "状态", Icon: "bi bi-app-indicator", Hand: func(m *ice.Message, arg ...string) { if repos := kit.Select(m.Option(REPOS), arg, 0); repos != "" { - m.Toast(kit.Format("what %v", repos)) _repos_status(m, repos, _repos_open(m, repos)) } else { last := "" diff --git a/misc/wx/login.go b/misc/wx/login.go index 48714751..1b8a50ff 100644 --- a/misc/wx/login.go +++ b/misc/wx/login.go @@ -83,7 +83,6 @@ func init() { web.PP(LOGIN): {Actions: ice.MergeActions(ice.Actions{ aaa.SESS: {Name: "sess code", Help: "会话", Hand: func(m *ice.Message, arg ...string) { m.Option(ice.MSG_USERZONE, WX) - m.Option("what", kit.Format("what %v", mdb.Conf(m, "header", "meta.demo"))) if mdb.Conf(m, "header", "meta.demo") == ice.TRUE { m.Echo(aaa.SessCreate(m.Spawn(), ice.Info.Username)) return