diff --git a/base/cli/mirrors.go b/base/cli/mirrors.go index 2cf29906..f3a02364 100644 --- a/base/cli/mirrors.go +++ b/base/cli/mirrors.go @@ -1,6 +1,7 @@ package cli import ( + "io" "runtime" "strings" @@ -42,6 +43,9 @@ func init() { REPOS: {Help: "镜像源", Hand: func(m *ice.Message, arg ...string) { switch { case strings.Contains(release(m.Spawn()), ALPINE): + ice.Info.PushStream(m) + m.Optionv(CMD_OUTPUT).(io.Writer).Write([]byte("\n")) + defer ice.Info.PushNotice(m, "toast", "success") m.Cmd(nfs.SAVE, ETC_APK_REPOS, strings.ReplaceAll(m.Cmdx(nfs.CAT, ETC_APK_REPOS), "dl-cdn.alpinelinux.org", "mirrors.tencent.com")) m.Cmdy(SYSTEM, "apk", "update") m.StatusTimeCount() @@ -49,6 +53,9 @@ func init() { }}, "add": {Help: "安装", Hand: func(m *ice.Message, arg ...string) { mdb.ZoneSelect(m, m.Option(CLI)).Table(func(value ice.Maps) { + ice.Info.PushStream(m) + ice.Info.PushNotice(m, "toast", "process", "", "-1") + defer ice.Info.PushNotice(m, "toast", "success") m.Push("res", m.Cmdx(kit.Split(value[CMD]))) }) }}, diff --git a/base/cli/runtime.go b/base/cli/runtime.go index 9c61a624..e348a5f1 100644 --- a/base/cli/runtime.go +++ b/base/cli/runtime.go @@ -160,7 +160,7 @@ const RUNTIME = "runtime" func init() { Index.MergeCommands(ice.Commands{ - RUNTIME: {Name: "runtime info=bootinfo,ifconfig,diskinfo,hostinfo,userinfo,procstat,procinfo,bootinfo,role,api,cli,cmd,mod,env,path,chain,routine auto upgrade restart logs conf", Icon: "usr/icons/info.png", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{ + RUNTIME: {Name: "runtime info=bootinfo,ifconfig,diskinfo,hostinfo,userinfo,procstat,procinfo,bootinfo,role,api,cli,cmd,mod,env,path,chain,routine auto upgrade restart logs conf", Icon: "usr/icons/Infomation.png", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, ice.ETC_PATH) aaa.White(m, ice.LICENSE) diff --git a/base/gdb/event.go b/base/gdb/event.go index 33b80ffd..8690468c 100644 --- a/base/gdb/event.go +++ b/base/gdb/event.go @@ -39,9 +39,7 @@ func EventsAction(arg ...string) ice.Actions { list := kit.DictList(arg...) return ice.Actions{ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { for sub := range m.Target().Commands[m.CommandKey()].Actions { - kit.If(list[sub] == ice.TRUE, func() { - Watch(m, sub) - }) + kit.If(list[sub] == ice.TRUE, func() { Watch(m, sub) }) } }}} } diff --git a/base/gdb/routine.go b/base/gdb/routine.go index 13678102..e6e23188 100644 --- a/base/gdb/routine.go +++ b/base/gdb/routine.go @@ -38,7 +38,7 @@ func init() { } }, m.Option(mdb.NAME)) }}, - }, mdb.StatusHashAction(mdb.FIELD, "time,hash,status,name,cmd"), mdb.ClearOnExitHashAction())}, + }, mdb.StatusHashAction(mdb.LIMIT, 1000, mdb.LEAST, 500, mdb.FIELD, "time,hash,status,name,cmd"), mdb.ClearOnExitHashAction())}, }) } func Go(m *ice.Message, cb ice.Any, arg ...string) { diff --git a/base/nfs/cat.go b/base/nfs/cat.go index 2fce13ad..c042e781 100644 --- a/base/nfs/cat.go +++ b/base/nfs/cat.go @@ -131,6 +131,7 @@ func init() { } type templateMessage interface { + Optionv(key string, arg ...ice.Any) ice.Any PrefixKey(...string) string Cmdx(...ice.Any) string } @@ -142,7 +143,11 @@ func TemplateText(m templateMessage, p string) string { return m.Cmdx(CAT, path.Join(m.PrefixKey(), path.Base(p)), kit.Dict(DIR_ROOT, ice.SRC_TEMPLATE)) } func TemplatePath(m templateMessage, arg ...string) string { - return path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), path.Join(arg...)) + if p := path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), path.Join(arg...)); Exists(m, p) { + return p + } else { + return p + } } func IsSourceFile(m *ice.Message, ext string) bool { return mdb.Conf(m, Prefix(CAT), kit.Keym(SOURCE, ext)) == ice.TRUE diff --git a/base/nfs/save.go b/base/nfs/save.go index 5bcc191e..42a4c5c9 100644 --- a/base/nfs/save.go +++ b/base/nfs/save.go @@ -3,6 +3,7 @@ package nfs import ( "fmt" "io" + "os" "path" ice "shylinux.com/x/icebergs" @@ -10,7 +11,7 @@ import ( ) func _defs_file(m *ice.Message, name string, text ...string) { - if Exists(m, path.Join(m.Option(DIR_ROOT), name)) { + if s, e := os.Stat(path.Join(m.Option(DIR_ROOT), name)); e == nil && s.Size() > 0 { return } for i, v := range text { diff --git a/base/web/admin.go b/base/web/admin.go index d444ffec..99cf43ce 100644 --- a/base/web/admin.go +++ b/base/web/admin.go @@ -1,18 +1,21 @@ package web import ( + "net/http" + ice "shylinux.com/x/icebergs" kit "shylinux.com/x/toolkits" ) +const ADMIN = "admin" + func init() { - const ADMIN = "admin" Index.MergeCommands(ice.Commands{ ADMIN: {Name: ADMIN, Help: "管理", Hand: func(m *ice.Message, arg ...string) { args := []string{} kit.If(len(arg) == 0, func() { arg = append(arg, SPACE, DOMAIN) }) kit.For(arg[1:], func(v string) { args = append(args, ice.ARG, v) }) - m.Cmdy(SPIDE, ice.OPS, SPIDE_RAW, CHAT_CMD+arg[0]+"?debug=true", SPIDE_FORM, args) + m.Cmdy(SPIDE, ice.OPS, SPIDE_RAW, http.MethodGet, CHAT_CMD+arg[0]+"?debug=true", args) }}, }) } diff --git a/base/web/count.go b/base/web/count.go index 44bc93c2..aa7b0702 100644 --- a/base/web/count.go +++ b/base/web/count.go @@ -45,7 +45,7 @@ func init() { mdb.CREATE: {Name: "create type name text", Hand: func(m *ice.Message, arg ...string) { mdb.HashSelectUpdate(m, mdb.HashCreate(m), func(value ice.Map) { value[mdb.COUNT] = kit.Int(value[mdb.COUNT]) + 1 }) }}, - }, ctx.CmdAction(), mdb.HashAction(mdb.SHORT, "type,name", mdb.FIELD, "time,hash,count,type,name,text")), Hand: func(m *ice.Message, arg ...string) { + }, ctx.CmdAction(), mdb.HashAction(mdb.LIMIT, 1000, mdb.LEAST, 500, mdb.SHORT, "type,name", mdb.FIELD, "time,hash,count,type,name,text")), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...).Sort("type,name,text", "str", "str", "str") }}, }) diff --git a/base/web/option.go b/base/web/option.go index b64d4740..ff1d9eb7 100644 --- a/base/web/option.go +++ b/base/web/option.go @@ -103,6 +103,8 @@ func PushNoticeGrow(m *ice.Message, arg ...ice.Any) { PushNotice(m, kit.List("g func PushStream(m *ice.Message) { m.Options(cli.CMD_OUTPUT, file.NewWriteCloser(func(buf []byte) { PushNoticeGrow(m, string(buf)) }, nil)).ProcessHold(toastContent(m, ice.SUCCESS)) } +func init() { ice.Info.PushStream = PushStream } +func init() { ice.Info.PushNotice = PushNotice } func Toast(m *ice.Message, text string, arg ...ice.Any) { // [title [duration [progress]]] if len(arg) > 1 { diff --git a/base/web/route.go b/base/web/route.go index 6e536a68..35fe01f4 100644 --- a/base/web/route.go +++ b/base/web/route.go @@ -56,7 +56,7 @@ const ROUTE = "route" func init() { Index.MergeCommands(ice.Commands{ - ROUTE: {Name: "route space:text cmds:text auto spide cmds build travel monitor prunes", Icon: "usr/icons/route.png", Help: "路由表", Actions: ice.MergeActions(ice.Actions{ + ROUTE: {Name: "route space:text cmds:text auto spide cmds build travel monitor prunes", Icon: "usr/icons/Podcasts.png", Help: "路由表", Actions: ice.MergeActions(ice.Actions{ ice.MAIN: {Help: "首页", Hand: func(m *ice.Message, arg ...string) { ctx.ProcessField(m, CHAT_IFRAME, m.MergePod(""), arg...) }}, diff --git a/base/web/serve.go b/base/web/serve.go index 358aced1..cb1886d6 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -58,7 +58,7 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool { r.Header.Set(ice.MSG_USERIP, strings.Split(r.RemoteAddr, nfs.DF)[0]) } if m.Logs(r.Header.Get(ice.MSG_USERIP), r.Method, r.URL.String()); r.Method == http.MethodGet { - ispod := kit.Contains(r.Header.Get("Referer"), "/chat/pod/", "pod=") + ispod := kit.Contains(r.Header.Get("Referer"), "/chat/pod/", "pod=") || kit.Contains(r.URL.String(), "/chat/pod/", "pod=") if msg := m.Spawn(w, r).Options(ice.MSG_USERUA, r.UserAgent()); path.Join(r.URL.Path) == nfs.PS { if !msg.IsCliUA() { if r.URL.Path = kit.Select(nfs.PS, mdb.Config(m, ice.MAIN)); path.Join(r.URL.Path) != nfs.PS { diff --git a/base/web/share.go b/base/web/share.go index 5a33d71b..d0fe1def 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -44,6 +44,12 @@ func _share_proxy(m *ice.Message) { case http.MethodGet: m.RenderDownload(p, m.Option(mdb.TYPE), m.Option(mdb.NAME)) case http.MethodPost: + msg := m.Cmd(SHARE, m.Option(SHARE)) + defer m.Cmd(SHARE, mdb.REMOVE, mdb.HASH, m.Option(SHARE)) + if m.Warn(msg.Append(mdb.TEXT) == "") { + break + } + p := path.Join(ice.VAR_PROXY, msg.Append(mdb.TEXT), msg.Append(mdb.NAME)) if _, _, e := m.R.FormFile(UPLOAD); e == nil { m.Cmdy(CACHE, UPLOAD).Cmdy(CACHE, WATCH, m.Option(mdb.HASH), p) } @@ -157,11 +163,16 @@ func ShareLocalFile(m *ice.Message, arg ...string) { return } pp := path.Join(ice.VAR_PROXY, m.Option(ice.POD), p) - cache, size := time.Now().Add(-time.Hour*24), int64(0) + size, cache := int64(0), time.Now().Add(-time.Hour*24) if s, e := file.StatFile(pp); e == nil { - cache, size = s.ModTime(), s.Size() + size, cache = s.Size(), s.ModTime() + } else if s, e := file.StatFile(p); e == nil { + size, cache = s.Size(), s.ModTime() } kit.If(p == ice.BIN_ICE_BIN, func() { m.Option(ice.MSG_USERROLE, aaa.TECH) }) - m.Cmd(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, http.MethodPost, MergeLink(m, PP(SHARE, PROXY)), SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, mdb.AT+p) + share := m.Cmdx(SHARE, mdb.CREATE, mdb.TYPE, PROXY, mdb.NAME, p, mdb.TEXT, m.Option(ice.POD)) + defer m.Cmd(SHARE, mdb.REMOVE, mdb.HASH, share) + url := tcp.PublishLocalhost(m, MergeLink(m, PP(SHARE, PROXY), SHARE, share)) + m.Cmd(SPACE, m.Option(ice.POD), SPIDE, PROXY, "url", url, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, mdb.AT+p) m.RenderDownload(kit.Select(p, pp, file.ExistsFile(pp))) } diff --git a/base/web/space.go b/base/web/space.go index d075ad4b..ddf20bd2 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -186,6 +186,18 @@ func init() { kit.If(mdb.Config(m, ice.MAIN), func(cmd string) { RenderPodCmd(m, "", cmd) }, func() { RenderMain(m) }) m.Optionv(ice.MSG_ARGS, kit.Simple(m.Optionv(ice.MSG_ARGS))) }}, + mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { + if mdb.IsSearchPreview(m, arg) { + m.Cmds("", func(value ice.Maps) { + switch value[mdb.TYPE] { + case MASTER: + m.PushSearch(mdb.TEXT, m.Cmdv(SPIDE, value[mdb.NAME], CLIENT_ORIGIN), value) + case SERVER: + m.PushSearch(mdb.TEXT, m.MergePod(value[mdb.NAME]), value) + } + }) + } + }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { switch arg[0] { case SPACE: @@ -207,18 +219,6 @@ func init() { m.Cmd("", m.Option(mdb.NAME), ice.EXIT) m.Sleep("1s") }}, - mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { - if mdb.IsSearchPreview(m, arg) { - m.Cmds("", func(value ice.Maps) { - switch value[mdb.TYPE] { - case MASTER: - m.PushSearch(mdb.TEXT, m.Cmdv(SPIDE, value[mdb.NAME], CLIENT_ORIGIN), value) - case SERVER: - m.PushSearch(mdb.TEXT, m.MergePod(value[mdb.NAME]), value) - } - }) - } - }}, DOMAIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(_space_domain(m)) }}, LOGIN: {Help: "授权", Hand: func(m *ice.Message, arg ...string) { m.Option(ice.MSG_USERUA, m.Cmdv("", kit.Select(m.Option(mdb.NAME), arg, 0), ice.MSG_USERUA)) @@ -233,7 +233,7 @@ func init() { } }}, nfs.PS: {Hand: func(m *ice.Message, arg ...string) { _space_fork(m) }}, - }, mdb.HashAction(mdb.LIMIT, 1000, mdb.LEAST, 1000, mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text,module,version", ctx.ACTION, OPEN, REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000)), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) { + }, mdb.HashAction(mdb.LIMIT, 1000, mdb.LEAST, 500, mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text,module,version", ctx.ACTION, OPEN, REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000)), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) < 2 { defer m.StatusTimeCount(ice.MAIN, mdb.Config(m, ice.MAIN)) m.Option(ice.MSG_USERWEB, tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB))) diff --git a/base/web/spide.go b/base/web/spide.go index 1b164379..fed06c39 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -42,6 +42,9 @@ func _spide_show(m *ice.Message, name string, arg ...string) { method = kit.Select(http.MethodGet, msg.Append(CLIENT_METHOD), method) uri, arg := arg[0], arg[1:] body, head, arg := _spide_body(m, method, arg...) + if m.Option("_break") == ice.TRUE { + return + } if c, ok := body.(io.Closer); ok { defer c.Close() } @@ -141,15 +144,20 @@ func _spide_part(m *ice.Message, arg ...string) (string, io.Reader) { cache = t } } else if strings.HasPrefix(arg[i+1], mdb.AT) { - if s, e := nfs.StatFile(m, arg[i+1][1:]); !m.Warn(e, ice.ErrNotValid) { + p := arg[i+1][1:] + if s, e := nfs.StatFile(m, p); !m.Warn(e, ice.ErrNotValid) { if s.Size() == size && s.ModTime().Before(cache) { + m.Option("_break", ice.TRUE) + continue + } else if s.Size() == size && !nfs.Exists(m.Spawn(kit.Dict(ice.MSG_FILES, nfs.DiskFile)), p) { + m.Option("_break", ice.TRUE) continue } m.Logs(nfs.FIND, LOCAL, s.ModTime(), nfs.SIZE, s.Size(), CACHE, cache, nfs.SIZE, size) } - if f, e := nfs.OpenFile(m, arg[i+1][1:]); !m.Warn(e, ice.ErrNotValid, arg[i+1]) { + if f, e := nfs.OpenFile(m, p); !m.Warn(e, ice.ErrNotValid, arg[i+1]) { defer f.Close() - if p, e := mp.CreateFormFile(arg[i], path.Base(arg[i+1][1:])); !m.Warn(e, ice.ErrNotValid, arg[i+1]) { + if p, e := mp.CreateFormFile(arg[i], path.Base(p)); !m.Warn(e, ice.ErrNotValid, arg[i+1]) { if n, e := io.Copy(p, f); !m.Warn(e, ice.ErrNotValid, arg[i+1]) { m.Logs(nfs.LOAD, nfs.FILE, arg[i+1], nfs.SIZE, n) } @@ -271,9 +279,16 @@ func init() { m.Cmd("", mdb.CREATE, ice.DEV, kit.Select(kit.Select("https://contexts.com.cn", ice.Info.Make.Domain), conf[cli.CTX_DEV])) m.Cmd("", mdb.CREATE, ice.COM, kit.Select("https://contexts.com.cn", conf[cli.CTX_COM])) m.Cmd("", mdb.CREATE, ice.HUB, kit.Select("https://repos.shylinux.com", conf[cli.CTX_HUB])) - m.Cmd("", mdb.CREATE, "repos", kit.Select("https://repos.shylinux.com", conf[cli.CTX_HUB])) + m.Cmd("", mdb.CREATE, nfs.REPOS, kit.Select("https://repos.shylinux.com", conf[cli.CTX_HUB])) m.Cmd("", mdb.CREATE, ice.SHY, kit.Select(kit.Select("https://shylinux.com", ice.Info.Make.Remote), conf[cli.CTX_SHY])) }}, + mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { + if mdb.IsSearchPreview(m, arg) { + mdb.HashSelectValue(m.Spawn(), func(value ice.Map) { + m.PushSearch(mdb.TYPE, LINK, mdb.NAME, kit.Value(value, CLIENT_NAME), mdb.TEXT, kit.Value(value, CLIENT_ORIGIN), value) + }) + } + }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { switch m.Option(ctx.ACTION) { case COOKIE: @@ -290,23 +305,19 @@ func init() { mdb.HashSelectValue(m.Spawn(), func(value ice.Map) { m.Push(kit.Select(ORIGIN, arg, 0), kit.Value(value, CLIENT_ORIGIN)) }) } }}, + mdb.CREATE: {Name: "create name link", Hand: func(m *ice.Message, arg ...string) { _spide_create(m, m.Option(mdb.NAME), m.Option(LINK)) }}, HEADER: {Name: "header key* value", Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, m.OptionSimple(CLIENT_NAME), kit.Keys(HEADER, m.Option(mdb.KEY)), m.Option(mdb.VALUE)) }}, COOKIE: {Name: "cookie key* value", Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, m.OptionSimple(CLIENT_NAME), kit.Keys(COOKIE, m.Option(mdb.KEY)), m.Option(mdb.VALUE)) }}, - mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { - if mdb.IsSearchPreview(m, arg) { - mdb.HashSelectValue(m.Spawn(), func(value ice.Map) { - m.PushSearch(mdb.TYPE, LINK, mdb.NAME, kit.Value(value, CLIENT_NAME), mdb.TEXT, kit.Value(value, CLIENT_ORIGIN), value) - }) - } - }}, - mdb.CREATE: {Name: "create name link", Hand: func(m *ice.Message, arg ...string) { _spide_create(m, m.Option(mdb.NAME), m.Option(LINK)) }}, MERGE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(kit.MergeURL2(m.Cmdv("", arg[0], CLIENT_URL), arg[1], arg[2:])) }}, + PROXY: {Name: "proxy url size cache upload", Hand: func(m *ice.Message, arg ...string) { + m.Cmdy(SPIDE, ice.DEV, SPIDE_RAW, http.MethodPost, m.Option("url"), SPIDE_PART, arg[2:]) + }}, }, mdb.HashAction(mdb.SHORT, CLIENT_NAME, mdb.FIELD, "time,client.name,client.url")), Hand: func(m *ice.Message, arg ...string) { if len(arg) < 2 || arg[0] == "" || (len(arg) > 3 && arg[3] == "") { mdb.HashSelect(m, kit.Slice(arg, 0, 1)...).Sort(CLIENT_NAME) diff --git a/core/chat/flows.go b/core/chat/flows.go index 37afb823..bf152006 100644 --- a/core/chat/flows.go +++ b/core/chat/flows.go @@ -11,7 +11,7 @@ const FLOWS = "flows" func init() { Index.MergeCommands(ice.Commands{ - FLOWS: {Name: "flows zone hash auto", Icon: "usr/icons/flows.png", Help: "工作流", Actions: ice.MergeActions(ice.Actions{ + FLOWS: {Name: "flows zone hash auto", Icon: "usr/icons/Automator.png", Help: "工作流", Actions: ice.MergeActions(ice.Actions{ mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { if mdb.IsSearchPreview(m, arg) { mdb.HashSelect(m.Spawn(ice.OptionFields(""))).Table(func(value ice.Maps) { diff --git a/core/chat/iframe.go b/core/chat/iframe.go index 58fc8e26..c76f4f08 100644 --- a/core/chat/iframe.go +++ b/core/chat/iframe.go @@ -24,7 +24,7 @@ func init() { }) } }}, - mdb.CREATE: {Hand: func(m *ice.Message, arg ...string) { + mdb.CREATE: {Name: "create type name link", Hand: func(m *ice.Message, arg ...string) { m.ProcessRewrite(mdb.HASH, mdb.HashCreate(m, mdb.TYPE, web.LINK, mdb.NAME, kit.ParseURL(m.Option(web.LINK)).Host, m.OptionSimple())) }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { diff --git a/core/chat/macos/applications.go b/core/chat/macos/applications.go index 84377806..a2419785 100644 --- a/core/chat/macos/applications.go +++ b/core/chat/macos/applications.go @@ -21,12 +21,9 @@ func init() { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { FinderAppend(m, "Applications", m.PrefixKey()) m.Travel(func(p *ice.Context, c *ice.Context, key string, cmd *ice.Command) { - kit.If(cmd.Icon, func() { - m.Debug("what %v", cmd.Icon) - AppInstall(m, cmd.Icon, m.PrefixKey()) - }) + kit.If(cmd.Icon, func() { AppInstall(m, cmd.Icon, m.PrefixKey()) }) }) - Notify(m, cli.RUNTIME, "系统启动成功", ctx.INDEX, cli.RUNTIME) + Notify(m, "usr/icons/Infomation.png", cli.RUNTIME, "系统启动成功", ctx.INDEX, cli.RUNTIME) }}, ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { mdb.Conf(m, m.PrefixKey(), mdb.HASH, "") }}, code.INSTALL: {Hand: func(m *ice.Message, arg ...string) { AppInstall(m, arg[0], arg[1]) }}, diff --git a/core/chat/macos/desktop.css b/core/chat/macos/desktop.css index 4735ad69..e7c8841a 100644 --- a/core/chat/macos/desktop.css +++ b/core/chat/macos/desktop.css @@ -10,9 +10,11 @@ fieldset.macos.desktop>div.output>fieldset.macos.dock { border:var(--box-border) fieldset.macos.desktop>div.output>fieldset.macos.searchs { position:absolute; z-index:100; } fieldset.macos.desktop>div.output>fieldset.macos.searchs>form.option>div.item.keyword input { background-color:transparent; width:320px; } fieldset.macos.desktop>div.output>fieldset.macos.notifications { border-radius:0; height:calc(100% - 125px); width:250px; overflow:auto; position:absolute; top:25px; left:800px; } -fieldset.macos.desktop>div.output>fieldset.macos.notifications>div.output>div.item { margin-top:10px; min-height:60px; clear:both; } -fieldset.macos.desktop>div.output>fieldset.macos.notifications div.item div.title { margin-top:10px; width:132px; overflow:hidden; } -fieldset.macos.desktop>div.output>fieldset.macos.notifications div.item div.time { font-size:var(--code-font-size); margin-top:10px; width:48px; } +fieldset.macos.desktop>div.output>fieldset.macos.notifications>div.output>div.item { min-height:60px; clear:both; } +fieldset.macos.desktop>div.output>fieldset.macos.notifications>div.output>div.item.read { color:var(--disable-fg-color); } +fieldset.macos.desktop>div.output>fieldset.macos.notifications div.item div.icon img { height:50px; margin:5px; } +fieldset.macos.desktop>div.output>fieldset.macos.notifications div.item div.title { padding-top:10px; width:132px; overflow:hidden; } +fieldset.macos.desktop>div.output>fieldset.macos.notifications div.item div.time { font-size:var(--code-font-size); text-align:right; padding-top:10px; width:48px; } fieldset.macos.desktop>div.output>fieldset.macos.notifications div.item div.content { width:180px; } fieldset.macos.desktop>div.output>div.desktop:not(.select) { display:none; } fieldset.macos.desktop>div.output>div.desktop>div.item { color:silver; position:absolute; text-align:center; } diff --git a/core/chat/macos/macos.go b/core/chat/macos/macos.go index 9c844b25..b24c1e44 100644 --- a/core/chat/macos/macos.go +++ b/core/chat/macos/macos.go @@ -55,5 +55,5 @@ func CmdHashAction(arg ...string) ice.Actions { mdb.SELECT: {Name: "list hash auto create", Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...).Sort(mdb.NAME).Display(ctx.FileURI(file)) }}, - }, ctx.CmdAction(), mdb.HashAction(mdb.SHORT, kit.Select("", arg, 0), mdb.FIELD, kit.Select("time,hash,name,icon,text,space,index,args", arg, 1), kit.Slice(arg, 2))) + }, ctx.CmdAction(), mdb.HashAction(mdb.SHORT, kit.Select("", arg, 0), mdb.FIELD, kit.Select("time,hash,icon,name,text,space,index,args", arg, 1), kit.Slice(arg, 2))) } diff --git a/core/chat/macos/notifications.go b/core/chat/macos/notifications.go index eb3c2b21..5afd3f0a 100644 --- a/core/chat/macos/notifications.go +++ b/core/chat/macos/notifications.go @@ -3,9 +3,9 @@ package macos import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/ctx" + "shylinux.com/x/icebergs/base/gdb" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/web" - kit "shylinux.com/x/toolkits" ) const NOTIFICATIONS = "notifications" @@ -13,13 +13,17 @@ const NOTIFICATIONS = "notifications" func init() { Index.MergeCommands(ice.Commands{ NOTIFICATIONS: {Name: "notifications list", Actions: ice.MergeActions(ice.Actions{ - mdb.PRUNES: {Name: "prunes", Hand: func(m *ice.Message, arg ...string) { m.Conf("", kit.Keys(mdb.HASH), "") }}, web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) { - m.Cmd("", mdb.CREATE, m.OptionSimple(mdb.NAME), mdb.TEXT, "空间创建成功", ctx.INDEX, web.CHAT_IFRAME, ctx.ARGS, m.MergePod(m.Option(mdb.NAME))) + Notify(m, "usr/icons/Launchpad.png", m.Option(mdb.NAME), "空间创建成功", ctx.INDEX, web.CHAT_IFRAME, ctx.ARGS, m.MergePod(m.Option(mdb.NAME))) }}, - }, CmdHashAction()), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...).SortStrR(mdb.TIME).Display("") }}, + "read": {Hand: func(m *ice.Message, arg ...string) { + m.Cmd(mdb.MODIFY, m.PrefixKey(), "", mdb.LIST, mdb.ID, m.Option(mdb.ID), mdb.STATUS, "read") + }}, + }, gdb.EventAction(web.DREAM_CREATE), mdb.ListAction(mdb.FIELD, "time,id,status,icon,name,text,space,index,args")), Hand: func(m *ice.Message, arg ...string) { + mdb.ListSelect(m, arg...).Display("") + }}, }) } -func Notify(m *ice.Message, name, text string, arg ...string) { - m.Cmd(NOTIFICATIONS, mdb.CREATE, mdb.NAME, name, mdb.TEXT, text, arg) +func Notify(m *ice.Message, icon, name, text string, arg ...string) { + m.Cmd(NOTIFICATIONS, mdb.INSERT, mdb.ICON, icon, mdb.NAME, name, mdb.TEXT, text, arg) } diff --git a/core/chat/macos/notifications.js b/core/chat/macos/notifications.js index af167c4c..26de1c86 100644 --- a/core/chat/macos/notifications.js +++ b/core/chat/macos/notifications.js @@ -1,12 +1,18 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) { - can.page.Appends(can, can._output, msg.Table(function(item) { return {view: html.ITEM, _init: function(target) { + can.page.Appends(can, can._output, msg.Table(function(item) { return {view: [[html.ITEM, item.status]], _init: function(target) { var ui = can.onappend.layout(can, [html.ICON, [[wiki.TITLE, mdb.TIME], wiki.CONTENT]], "", target) can.page.Append(can, ui.icon, [{img: can.misc.PathJoin(item.icon||can.page.drawText(can, item.name||item.index, 60))}]) ui.title.innerHTML = item.name||"", ui.content.innerHTML = item.text||"", ui.time.innerHTML = item.time.split(lex.SP).pop().split(nfs.DF).slice(0, 2).join(nfs.DF) - target.onclick = function(event) { can.sup.onexport.record(can.sup, item.index, ctx.INDEX, item), can.runAction(event, mdb.REMOVE, [item.hash], function() { can.page.Remove(can, target) }) } + target.onclick = function(event) { can.sup.onexport.record(can.sup, item.index, ctx.INDEX, item), + can.runAction(can.request(event, item), "read", [], function() { + can.onappend.style(can, "read", target) + return + can.page.Remove(can, target) }) } }} })), msg.Length() == 0 && can.onmotion.hidden(can, can._fields), can.onappend._action(can), can.page.style(can, can._action, html.DISPLAY, html.BLOCK) }}) -Volcanos(chat.ONACTION, {list: [web.UPDATE, mdb.PRUNES, web.TOGGLE], _trans: {update: "刷新", toggle: "隐藏"}, - update: function(event, can, button) { can.Update(event) }, +Volcanos(chat.ONACTION, { + list: [web.REFRESH, mdb.PRUNES, html.TOGGLE], + _trans: {refresh: "刷新", toggle: "隐藏"}, + refresh: function(event, can, button) { can.Update(event) }, toggle: function(event, can, button) { can.onmotion.hidden(can, can._fields) }, }) diff --git a/core/code/py.go b/core/code/py.go index c0676f62..7c9a3379 100644 --- a/core/code/py.go +++ b/core/code/py.go @@ -25,8 +25,7 @@ func init() { Index.MergeCommands(ice.Commands{ PY: {Name: "py path auto", Help: "脚本", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { - cli.IsAlpine(m, "python", "python2") - cli.IsAlpine(m, "python2") + cli.IsAlpine(m, "python", "python3") cli.IsAlpine(m, "python3") cli.IsCentos(m, "python", "python2") cli.IsCentos(m, "python2") diff --git a/core/code/vimer.go b/core/code/vimer.go index 36b9a5b1..298197c8 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -118,7 +118,7 @@ func init() { nfs.DirDeepAll(m.Spawn(), nfs.PWD, p, func(value ice.Maps) { push("", value[nfs.PATH]) }, nfs.PATH) } m.Cmd(XTERM).Table(func(value ice.Maps) { - push(ctx.INDEX, kit.Join([]string{"web.code.xterm", value[mdb.HASH], kit.Select(value[mdb.TYPE], value[mdb.NAME])})) + push(ctx.INDEX, kit.Join([]string{web.CODE_XTERM, value[mdb.HASH], kit.Select(value[mdb.TYPE], value[mdb.NAME])})) }) m.Cmd(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND, ice.OptionFields(ctx.INDEX)).Table(func(value ice.Maps) { push(ctx.INDEX, value[ctx.INDEX]) }) m.Cmd(mdb.SEARCH, cli.SYSTEM, cli.OPENS, ice.OptionFields("type,name,text")).Sort("type,name,text").Table(func(value ice.Maps) { push(cli.OPENS, value[nfs.NAME]) }) diff --git a/info.go b/info.go index 45d49e8c..70e1316e 100644 --- a/info.go +++ b/info.go @@ -69,12 +69,14 @@ var Info = struct { Index Map Stack map[string]func(m *Message, key string, arg ...Any) Any - merges []Any - render map[string]func(*Message, ...Any) string - OpenFile func(m *Message, p string) (io.ReadCloser, error) - Load func(m *Message, key ...string) *Message - Save func(m *Message, key ...string) *Message - Log func(m *Message, p, l, s string) + merges []Any + render map[string]func(*Message, ...Any) string + OpenFile func(m *Message, p string) (io.ReadCloser, error) + PushStream func(m *Message) + PushNotice func(m *Message, arg ...Any) + Load func(m *Message, key ...string) *Message + Save func(m *Message, key ...string) *Message + Log func(m *Message, p, l, s string) }{ Localhost: true, @@ -84,11 +86,13 @@ var Info = struct { Index: Map{}, Stack: map[string]func(m *Message, key string, arg ...Any) Any{}, - render: map[string]func(*Message, ...Any) string{}, - OpenFile: func(m *Message, p string) (io.ReadCloser, error) { return miss.OpenFile(p) }, - Load: func(m *Message, key ...string) *Message { return m }, - Save: func(m *Message, key ...string) *Message { return m }, - Log: func(m *Message, p, l, s string) {}, + render: map[string]func(*Message, ...Any) string{}, + OpenFile: func(m *Message, p string) (io.ReadCloser, error) { return miss.OpenFile(p) }, + PushStream: func(m *Message) {}, + PushNotice: func(m *Message, arg ...Any) {}, + Load: func(m *Message, key ...string) *Message { return m }, + Save: func(m *Message, key ...string) *Message { return m }, + Log: func(m *Message, p, l, s string) {}, } func AddMergeAction(h ...Any) { Info.merges = append(Info.merges, h...) }