From aa7fcaf4725a9a2a5fed6269109ca0db367d74c7 Mon Sep 17 00:00:00 2001 From: shylinux Date: Sun, 7 May 2023 22:23:51 +0800 Subject: [PATCH] opt some --- base/aaa/sess.go | 2 +- base/aaa/user.go | 2 +- base/mdb/hash.go | 6 ++- base/mdb/list.go | 2 + base/mdb/mdb.go | 26 ++++++++-- base/mdb/zone.go | 9 +++- core/chat/favor.go | 2 +- core/chat/macos/applications.go | 16 ------ core/chat/macos/desktop.css | 87 +++++++++++++++----------------- core/chat/macos/desktop.go | 26 +++++++++- core/chat/macos/desktop.js | 49 +++++++++++------- core/chat/macos/dock.go | 18 ++++++- core/chat/macos/dock.js | 2 +- core/chat/macos/menu.go | 19 ++++++- core/chat/macos/menu.js | 9 ++-- core/chat/macos/notifications.js | 2 +- core/chat/macos/searchs.go | 2 +- core/chat/macos/session.go | 8 ++- core/chat/river.go | 2 +- core/team/plan.go | 5 +- core/team/task.go | 3 +- core/wiki/draw.go | 5 +- core/wiki/word.go | 5 +- misc/git/repos.go | 26 +++++++++- misc/git/status.go | 2 +- type.go | 4 +- 26 files changed, 231 insertions(+), 108 deletions(-) diff --git a/base/aaa/sess.go b/base/aaa/sess.go index 5ca970a4..32d0e1fb 100644 --- a/base/aaa/sess.go +++ b/base/aaa/sess.go @@ -38,7 +38,7 @@ func init() { _sess_create(m, m.Option(USERNAME), UA, m.Option(ice.MSG_USERUA), IP, m.Option(ice.MSG_USERIP)) }}, CHECK: {Name: "check sessid*", Hand: func(m *ice.Message, arg ...string) { _sess_check(m, m.Option(ice.MSG_SESSID)) }}, - }, mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,usernick,username,userrole,ua,ip"), mdb.ImportantDataAction())}, + }, mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,usernick,username,userrole,ua,ip"), mdb.ImportantHashAction())}, }) } diff --git a/base/aaa/user.go b/base/aaa/user.go index 4849f563..e1b2721a 100644 --- a/base/aaa/user.go +++ b/base/aaa/user.go @@ -48,7 +48,7 @@ func init() { mdb.CREATE: {Name: "create usernick username* userrole=void,tech userzone", Hand: func(m *ice.Message, arg ...string) { _user_create(m, m.Option(USERNAME), m.OptionSimple(USERNICK, USERROLE, USERZONE)...) }}, - }, mdb.HashAction(mdb.SHORT, USERNAME, mdb.FIELD, "time,usernick,username,userrole,userzone"), mdb.ImportantDataAction())}, + }, mdb.HashAction(mdb.SHORT, USERNAME, mdb.FIELD, "time,usernick,username,userrole,userzone"), mdb.ImportantHashAction())}, }) } diff --git a/base/mdb/hash.go b/base/mdb/hash.go index 67bf5c96..8db8ab97 100644 --- a/base/mdb/hash.go +++ b/base/mdb/hash.go @@ -89,11 +89,15 @@ func _hash_prunes(m *ice.Message, prefix, chain string, arg ...string) { } func _hash_export(m *ice.Message, prefix, chain, file string) { defer Lock(m, prefix, chain)() + count := len(Confm(m, prefix, kit.Keys(chain, HASH))) + if count == 0 { + return + } f, p, e := miss.CreateFile(kit.Keys(file, JSON)) m.Assert(e) defer f.Close() defer m.Echo(p) - m.Logs(EXPORT, KEY, path.Join(prefix, chain), FILE, p, COUNT, len(Confm(m, prefix, kit.Keys(chain, HASH)))) + m.Logs(EXPORT, KEY, path.Join(prefix, chain), FILE, p, COUNT, count) en := json.NewEncoder(f) if en.SetIndent("", " "); !m.Warn(en.Encode(m.Confv(prefix, kit.Keys(chain, HASH))), EXPORT, prefix) { m.Conf(prefix, kit.Keys(chain, HASH), "") diff --git a/base/mdb/list.go b/base/mdb/list.go index 4c507938..24288e31 100644 --- a/base/mdb/list.go +++ b/base/mdb/list.go @@ -29,11 +29,13 @@ func _list_inputs(m *ice.Message, prefix, chain string, field, value string) { func _list_insert(m *ice.Message, prefix, chain string, arg ...string) { m.Logs(INSERT, KEY, path.Join(prefix, chain), arg) defer Lock(m, prefix, chain)() + saveImportant(m, prefix, chain, kit.Simple(INSERT, prefix, chain, LIST, TIME, m.Time(), arg)...) m.Echo("%d", Grow(m, prefix, chain, kit.Dict(arg, TARGET, m.Optionv(TARGET)))) } func _list_modify(m *ice.Message, prefix, chain string, field, value string, arg ...string) { m.Logs(MODIFY, KEY, path.Join(prefix, chain), field, value, arg) defer Lock(m, prefix, chain)() + saveImportant(m, prefix, chain, kit.Simple(MODIFY, prefix, chain, LIST, field, value, arg)...) Grows(m, prefix, chain, field, value, func(index int, val ice.Map) { _mdb_modify(m, val, field, arg...) }) } func _list_select(m *ice.Message, prefix, chain, field, value string) { diff --git a/base/mdb/mdb.go b/base/mdb/mdb.go index 7a632bb2..773439f8 100644 --- a/base/mdb/mdb.go +++ b/base/mdb/mdb.go @@ -253,11 +253,31 @@ func AutoConfig(arg ...Any) *ice.Action { } }} } -func ImportantDataAction() ice.Actions { - return ice.Actions{ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { Config(m, "important", ice.TRUE) }}} +func ImportantZoneAction() ice.Actions { + return ice.Actions{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + Config(m, "important", ice.TRUE) + ZoneImport(m) + }}, + ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { + m.OptionFields("") + ZoneExport(m) + }}, + } +} +func ImportantHashAction() ice.Actions { + return ice.Actions{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + Config(m, "important", ice.TRUE) + HashImport(m) + }}, + ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { + HashExport(m) + }}, + } } func saveImportant(m *ice.Message, key, sub string, arg ...string) { - kit.If(m.Conf(key, kit.Keys(sub, 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 { res := Maps{} diff --git a/base/mdb/zone.go b/base/mdb/zone.go index e70a2730..3c9d4608 100644 --- a/base/mdb/zone.go +++ b/base/mdb/zone.go @@ -2,6 +2,7 @@ package mdb import ( "encoding/csv" + "os" "path" ice "shylinux.com/x/icebergs" @@ -84,13 +85,19 @@ func _zone_export(m *ice.Message, prefix, chain, file string) { }) }) } + if count == 0 { + os.Remove(p) + return + } m.Logs(EXPORT, KEY, path.Join(prefix, chain), FILE, p, COUNT, count) m.Conf(prefix, kit.Keys(chain, HASH), "") } func _zone_import(m *ice.Message, prefix, chain, file string) { defer Lock(m, prefix, chain)() f, e := miss.OpenFile(kit.Keys(file, CSV)) - m.Assert(e) + if m.Warn(e) { + return + } defer f.Close() r := csv.NewReader(f) head, _ := r.Read() diff --git a/core/chat/favor.go b/core/chat/favor.go index 1d4998fd..1faad09e 100644 --- a/core/chat/favor.go +++ b/core/chat/favor.go @@ -101,7 +101,7 @@ func init() { m.Option(mdb.TYPE, mdb.HashSelects(m.Spawn(), m.Option(mdb.HASH)).Append(mdb.TYPE)) ctx.Run(m, arg...) }}, - }, ctx.CmdAction(), mdb.HashAction(), mdb.ImportantDataAction()), Hand: func(m *ice.Message, arg ...string) { + }, ctx.CmdAction(), mdb.ImportantHashAction(), mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && arg[0] == ctx.ACTION { m.Option(mdb.TYPE, mdb.HashSelects(m.Spawn(), m.Option(mdb.HASH)).Append(mdb.TYPE)) gdb.Event(m, FAVOR_ACTION, arg) diff --git a/core/chat/macos/applications.go b/core/chat/macos/applications.go index d233645d..9139902a 100644 --- a/core/chat/macos/applications.go +++ b/core/chat/macos/applications.go @@ -30,22 +30,6 @@ func init() { AppInstall(m, "", web.CODE_VIMER) AppInstall(m, "", web.CHAT_FAVOR) AppInstall(m, "", web.DREAM) - if m.Cmd(DESKTOP).Length() == 0 { - DeskAppend(m, "Books", web.WIKI_WORD) - DeskAppend(m, "Photos", web.WIKI_FEEL) - DeskAppend(m, "Grapher", web.WIKI_DRAW) - DeskAppend(m, "Calendar", web.TEAM_PLAN, ctx.ARGS, team.MONTH) - DeskAppend(m, "", web.CHAT_FAVOR) - } - if m.Cmd(DOCK).Length() == 0 { - DockAppend(m, "Finder", Prefix(FINDER)) - DockAppend(m, "Safari", web.CHAT_IFRAME) - DockAppend(m, "Terminal", web.CODE_XTERM) - DockAppend(m, "", web.CODE_GIT_REPOS, mdb.ICON, "usr/icons/git.jpg") - DockAppend(m, "", web.CODE_COMPILE, mdb.ICON, "usr/icons/go.png") - DockAppend(m, "", web.CODE_VIMER) - DockAppend(m, "", web.DREAM) - } }}, code.INSTALL: {Hand: func(m *ice.Message, arg ...string) { AppInstall(m, arg[0], arg[1], arg[2:]...) }}, }, CmdHashAction("index,args"))}, diff --git a/core/chat/macos/desktop.css b/core/chat/macos/desktop.css index 45330504..d6398af0 100644 --- a/core/chat/macos/desktop.css +++ b/core/chat/macos/desktop.css @@ -1,7 +1,7 @@ fieldset.macos.desktop { background-size:cover; background-position:center; } fieldset.macos.desktop>div.output>fieldset.macos { background-color:transparent; } fieldset.macos.desktop>div.output>fieldset.macos>div.output { background-color:transparent; } -fieldset.macos.desktop>div.output>fieldset.macos.menu { font-family:monospace; line-height:25px; border-radius:0; height:25px; width:100%; position:absolute; top:0; } +fieldset.macos.desktop>div.output>fieldset.macos.menu { font-family:monospace; line-height:25px; border-radius:0; height:25px; width:100%; position:absolute; top:0; overflow:hidden; } fieldset.macos.desktop>div.output>fieldset.macos.searchs { position:absolute; } fieldset.macos.desktop>div.output>fieldset.macos.searchs>form.option>div.item.icon.delete { display:none; } fieldset.macos.desktop>div.output>fieldset.macos.searchs>form.option>div.item.keyword input { width:320px; background-color:transparent; border:#404141 solid 1px; } @@ -11,10 +11,9 @@ fieldset.macos.desktop>div.output>fieldset.macos.notifications>div.action>div.it fieldset.macos.desktop>div.output>fieldset.macos.notifications>div.action>div.item input { background-color:transparent; } fieldset.macos.desktop>div.output>fieldset.macos.notifications>div.output>div.item { margin-top:10px; margin-right: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 { color:gray; font-size:12px; margin-top:10px; width:48px; } +fieldset.macos.desktop>div.output>fieldset.macos.notifications div.item div.time { font-size:12px; margin-top:10px; width:48px; } fieldset.macos.desktop>div.output>fieldset.macos.notifications div.item div.content { width:180px; } fieldset.macos.desktop>div.output>fieldset.macos.dock { border:#ffffff3d solid 1px; border-radius:20px; position:absolute; bottom:10px; z-index:11; transition:margin-left 0.3s; } -fieldset.macos.desktop>div.output>fieldset.macos.dock:hover { margin-left:-40px; transition:margin-left 0.3s; } fieldset.macos.desktop>div.output>div.desktop { padding-top:25px; } fieldset.macos.desktop>div.output>div.desktop:not(.select) { display:none; } fieldset.macos.desktop>div.output>div.desktop>div.item { position:absolute; text-align:center; } @@ -22,36 +21,36 @@ fieldset.macos.desktop>div.output>div.desktop>div.item:hover { background-color: fieldset.macos.desktop>div.output>div.desktop>div.item img { width:80px; border-radius:80px; } fieldset.macos.desktop>div.output>div.desktop>div.item>div.name { font-size:12px; width:80px; overflow:hidden; } fieldset.macos.desktop>div.output>div.desktop>fieldset { border-radius:10px; position:absolute; } -fieldset.macos.desktop>div.output>div.desktop>fieldset>div.item.button { border-radius:20px; height:20px; width:20px; scale:0.7; position:absolute; top:15px; right:10px; } +fieldset.macos.desktop>div.output>div.desktop>fieldset>div.item.button { border-radius:20px; height:20px; width:20px; scale:0.7; position:absolute; top:17px; right:10px; } fieldset.macos.desktop>div.output>div.desktop>fieldset>legend { background-color:unset; padding-right:10px; margin:10px 0; } fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>*:not(.textarea) { margin:10px 0px 10px 10px; } fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.icon { margin-left:0; margin-top:12px; margin-bottom:8px; } fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.item.icons { margin-left:0; } fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.item:last-child { margin-right:20px; } +fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.item:last-child { margin-right:80px; } fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>* { margin:10px 0px 10px 10px; } fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>div.item.icons>span.icon { margin-top:12px; } fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>div.item:last-child { margin-right:80px; } -fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.item:last-child { margin-right:80px; } +fieldset.macos.desktop>div.output>div.desktop>fieldset.web.wiki.feel>div.status { display:none; } +fieldset.macos.desktop>div.output>div.desktop>fieldset.web.code.vimer>div.status { display:none; } fieldset.macos.desktop>div.output>div.desktop>fieldset.web.code.xterm>div.status { display:none; } fieldset.macos.desktop>div.output>div.desktop>fieldset.web.code.xterm>div.action>div.tabs:only-child { display:none; } -fieldset.macos.desktop>div.output>div.desktop>fieldset.web.code.vimer>div.status { display:none; } -fieldset.macos.desktop>div.output>div.desktop>fieldset.web.wiki.feel>div.status { display:none; } -fieldset.macos.desktop>div.output>div.desktop>fieldset.web.chat.iframe>div.status { display:none; } -fieldset.macos.desktop>div.output>div.desktop>fieldset.web.chat.macos.finder>div.status { display:none; } fieldset.macos.desktop>div.output>div.desktop>fieldset.web.code.compile>form.option>div.item:last-child { margin-right:80px; } +fieldset.macos.desktop>div.output>div.desktop>fieldset.web.chat.iframe>div.status { display:none; } +fieldset.macos.desktop>div.output>div.desktop>fieldset.web.chat.iframe>form.option>div.item.hash>input { width:360px; } +fieldset.macos.desktop>div.output>div.desktop>fieldset.web.chat.macos.finder>div.status { display:none; } fieldset.macos.desktop>div.output>div.desktop>fieldset>div.output>fieldset>form.option>div.item { margin-right:0px; } fieldset.macos.desktop>div.output>div.desktop>fieldset>div.output>fieldset>div.action>div.item { margin-right:0px; } fieldset.macos.menu>div.output>div.item { padding:0 5px; float:right; cursor:pointer; } +fieldset.macos.menu>div.output>div.item.avatar>img { height:25px; } fieldset.macos.menu>div.output>div.menu { float:left; padding:0 20px; cursor:pointer; } fieldset.macos.menu>div.output>div.tabs { float:left; } fieldset.macos.menu>div.output>div.tabs.select { background-color:transparent; color:white; } -fieldset.macos.dock>div.output { height:80px; overflow:visible; display:flex; } +fieldset.macos.dock>div.output { height:80px; display:flex; overflow:auto; } fieldset.macos.dock>div.output>div.space { background-color:#ececec36; margin:10px; height:calc(100% - 20px); width:2px; } fieldset.macos.dock>div.output>div.item { text-align:center; align-self:baseline; transition:margin-top 0.3s; } -fieldset.macos.dock>div.output>div.item:hover { background-color:unset; margin-top:-80px; transition:margin-top 0.3s; } fieldset.macos.dock>div.output>div.item>div.name { display:none; } fieldset.macos.dock>div.output>div.item img { border-radius:80px; width:80px; transition:width 0.3s; } -fieldset.macos.dock>div.output>div.item img:hover { width:160px; transition:width 0.3s; } fieldset.macos.finder>div.output>div.project>div.item input { width:100%; } fieldset.macos.finder>div.output div.content>div.item { float:left; text-align:center; } fieldset.macos.finder>div.output div.content>div.item img { width:80px; border-radius:80px; } @@ -60,43 +59,41 @@ div.carte.macos.float { font-size:14px; padding:10px; border:#ffffff5e solid 1px div.carte.macos.float div.item { background:transparent; } div.carte.macos.float hr { border-bottom:gray solid 1px; } div.carte.macos.float { background-color:#e1e5ea; } -fieldset.macos.desktop>div.output { color:black; } -fieldset.macos.desktop>div.output>fieldset.macos.menu { background-color:#daefff99; color:black; } -fieldset.macos.desktop>div.output>fieldset.macos.dock { background-color:#e9f1f594; } -fieldset.macos.desktop>div.output>fieldset.macos.searchs { background-color:#daefff99; } -fieldset.macos.desktop>div.output>fieldset.macos.notifications div.item { background-color:#daefff99; color:black; } -fieldset.macos.desktop>div.output>div.desktop>fieldset { background-color:#dee1e6; } -fieldset.macos.desktop>div.output>div.desktop>fieldset>div.output { background-color:white; } -fieldset.macos.desktop>div.output>div.desktop>fieldset>div.status { border-top:#dddede solid 1px; } -fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(odd) { background-color:#f4f5f5; color:black; } -fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(even) { background-color:white; color:black; } -fieldset.macos.desktop>div.output>div.desktop fieldset input { background-color:white; border:#e4e5e5 solid 1px; color:black; caret-color:black; } -fieldset.macos.desktop>div.output>div.desktop fieldset>div.output.card>div.item { border:#d3d4d4 solid 1px; } -fieldset.macos.desktop>div.output>div.desktop fieldset>div.output.card>div.item>div.title { border-bottom:#d3d4d4 solid 1px; } -body.dark fieldset.macos.desktop input { color:#e8eaed; } -body.dark fieldset.macos.desktop input[type=button] { background-color:#5e5f5f; } -body.dark fieldset.macos.desktop>div.output { background-color:unset; color:white; } -body.dark fieldset.macos.desktop>div.output>fieldset.macos.menu { background-color:#08234ad1; color:#e8eaed; } -body.dark fieldset.macos.desktop>div.output>fieldset.macos.dock { background-color:#0e202e70; } -body.dark fieldset.macos.desktop>div.output>fieldset.macos.searchs { background-color:#0e202e70; } -body.dark fieldset.macos.desktop>div.output>fieldset.macos.searchs a { color:white; } -body.dark fieldset.macos.desktop>div.output>fieldset.macos.notifications div.item { background-color:#08234ad1; color:white; } +body.light fieldset.macos.desktop>div.output { background-color:unset; } +body.light fieldset.macos.desktop>div.output>fieldset.macos { background-color:#daefff99; } +body.light fieldset.macos.desktop>div.output>fieldset.macos.notifications { background-color:transparent; } +body.light fieldset.macos.desktop>div.output>fieldset.macos.notifications div.item { background-color:#daefff99; } +body.light fieldset.macos.desktop>div.output>div.desktop>fieldset { background-color:#dee1e6; } +body.light fieldset.macos.desktop>div.output>div.desktop fieldset input { background-color:white; border:#e4e5e5 solid 1px; } +body.light fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(odd) { background-color:#f4f5f5; } +body.light fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(even) { background-color:white; } +body.light fieldset.macos.desktop>div.output>div.desktop fieldset>div.output.card>div.item { border:#d3d4d4 solid 1px; } +body.light fieldset.macos.desktop>div.output>div.desktop fieldset>div.output.card>div.item>div.title { border-bottom:#d3d4d4 solid 1px; } +body.light fieldset.macos.desktop>div.output>div.desktop>fieldset>div.status { border-top:#dddede solid 1px; } +body.dark fieldset.macos.desktop>div.output { background-color:unset; } +body.dark fieldset.macos.desktop>div.output>fieldset.macos { background-color:#08234ad1; } +body.dark fieldset.macos.desktop>div.output>fieldset.macos.notifications { background-color:transparent; } +body.dark fieldset.macos.desktop>div.output>fieldset.macos.notifications div.item { background-color:#08234ad1; } +body.dark fieldset.macos.desktop>div.output>fieldset.macos.searchs a { color:silver; } body.dark fieldset.macos.desktop>div.output>div.desktop>fieldset { background-color:#333434; } -body.dark fieldset.macos.desktop>div.output>div.desktop>fieldset>div.output { background-color:#1a1d1d; } -body.dark fieldset.macos.desktop>div.output>div.desktop>fieldset>div.status { border-top:#3e4040 solid 1px; } -body.dark fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(odd) { background-color:#1a1d1e; color:white; } -body.dark fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(even) { background-color:#282B2F; color:white; } -body.dark fieldset.macos.desktop>div.output>div.desktop fieldset input { background-color:#333434; border:#404141 solid 1px; color:white; caret-color:white; } +body.dark fieldset.macos.desktop>div.output>div.desktop fieldset input { background-color:#333434; border:#404141 solid 1px; } +body.dark fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(odd) { background-color:#1a1d1e; } +body.dark fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(even) { background-color:#282B2F; } body.dark fieldset.macos.desktop>div.output>div.desktop fieldset>div.output.card>div.item { border:#3e4040 solid 1px; } body.dark fieldset.macos.desktop>div.output>div.desktop fieldset>div.output.card>div.item>div.title { border-bottom:#3e4040 solid 1px; } -body.dark div.carte.macos.float { background-color:#29323beb; color:#e8eaed; } -body.light fieldset.macos.desktop>div.output { background-color:unset; } +body.dark fieldset.macos.desktop>div.output>div.desktop>fieldset>div.status { border-top:#3e4040 solid 1px; } +body.dark div.carte.macos.float { background-color:#29323beb; } +body.black fieldset.macos.desktop>div.output>fieldset.macos.searchs a { color:cyan; } body.black fieldset.macos.desktop>div.output>div.desktop>fieldset { background-color:#3433337a; } +body.black fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(odd) { background-color:#1a1d1ee0; } +body.black fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(even) { background-color:#282b2fc7; } body.black fieldset.macos.desktop>div.output>div.desktop>fieldset>div.output { background-color:#1a1d1d9c; } -body.black fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(odd) { background-color:#1a1d1ee0; color:white; } -body.black fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(even) { background-color:#282b2fc7; color:white; } +body.white fieldset.macos.desktop>div.output>fieldset.macos.searchs a { color:black; } body.white fieldset.macos.desktop>div.output>div.desktop>fieldset { background-color:#f5f5f594; } -body.white fieldset.macos.desktop>div.output>div.desktop>fieldset>legend { color:black; } +body.white fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(odd) { background-color:#a5afbdb5; } +body.white fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(even) { background-color:#d4dddfd4; } body.white fieldset.macos.desktop>div.output>div.desktop>fieldset>div.output { background-color:#ffffff94; } -body.white fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(odd) { background-color:#a5afbdb5; color:black; } -body.white fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(even) { background-color:#d4dddfd4; color:black; } +body:not(.mobile) fieldset.macos.dock>div.output { overflow:visible; } +body:not(.mobile) fieldset.macos.dock>div.output>div.item:hover { background-color:unset; margin-top:-80px; transition:margin-top 0.3s; } +body:not(.mobile) fieldset.macos.dock>div.output>div.item img:hover { width:160px; transition:width 0.3s; } +body:not(.mobile) fieldset.macos.desktop>div.output>fieldset.macos.dock:hover { margin-left:-40px; transition:margin-left 0.3s; } diff --git a/core/chat/macos/desktop.go b/core/chat/macos/desktop.go index ce829009..c1838e14 100644 --- a/core/chat/macos/desktop.go +++ b/core/chat/macos/desktop.go @@ -1,10 +1,32 @@ package macos -import ice "shylinux.com/x/icebergs" +import ( + ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/ctx" + "shylinux.com/x/icebergs/base/mdb" + "shylinux.com/x/icebergs/base/web" + "shylinux.com/x/icebergs/core/team" + kit "shylinux.com/x/toolkits" +) const DESKTOP = "desktop" -func init() { Index.MergeCommands(ice.Commands{DESKTOP: {Actions: CmdHashAction()}}) } +func init() { + Index.MergeCommands(ice.Commands{DESKTOP: {Actions: ice.MergeActions(ice.Actions{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + if m.Cmd(DESKTOP).Length() == 0 { + DeskAppend(m, "Books", web.WIKI_WORD) + DeskAppend(m, "Photos", web.WIKI_FEEL) + DeskAppend(m, "Grapher", web.WIKI_DRAW) + DeskAppend(m, "Calendar", web.TEAM_PLAN, ctx.ARGS, team.MONTH) + DeskAppend(m, "", web.CHAT_FAVOR) + } + }}, + web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { + kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "桌面")) }) + }}, + }, web.DreamAction(), mdb.ImportantHashAction(), CmdHashAction())}}) +} func DeskAppend(m *ice.Message, name, index string, arg ...string) { install(m, DESKTOP, name, index, arg...) diff --git a/core/chat/macos/desktop.js b/core/chat/macos/desktop.js index 91453673..e2b3ede1 100644 --- a/core/chat/macos/desktop.js +++ b/core/chat/macos/desktop.js @@ -1,7 +1,7 @@ Volcanos(chat.ONIMPORT, { - _init: function(can, msg, cb) { if (can.isCmdMode()) { can.onappend.style(can, html.OUTPUT), can.ConfHeight(can.page.height()) } can.onimport.layout(can) + _init: function(can, msg, cb) { if (can.isCmdMode()) { can.onappend.style(can, html.OUTPUT), can.ConfHeight(can.page.height()) } can.ui = {}, can.base.isFunc(cb) && cb(msg), can.onmotion.clear(can), can.onlayout.background(can, can.user.info.background||"/require/usr/icons/background.jpg", can._fields) - can.onimport._menu(can), can.onimport._dock(can), can.onimport._searchs(can), can.onimport._notifications(can) + can.onimport._menu(can), can.onimport._dock(can), can.onimport._searchs(can), can.onimport._notifications(can), can.onimport.layout(can) }, _menu: function(can) { can.onappend.plugin(can, {index: "web.chat.macos.menu", style: html.OUTPUT}, function(sub) { can.ui.menu = sub sub.onexport.record = function(_, value, key, item) { delete(can.onfigure._path) @@ -10,22 +10,28 @@ Volcanos(chat.ONIMPORT, { case "desktop": var carte = can.user.carte(event, can, {}, can.core.Item(can.onfigure), function(event, button, meta, carte) { can.onfigure[button](event, can, carte) }); break case "searchs": can.onmotion.toggle(can, can.ui.searchs._target); break case "notifications": can.ui.notifications._output.innerHTML && can.onmotion.toggle(can, can.ui.notifications._target); break + default: can.onimport._window(can, value) } } - sub.onexport.output = function() { can.onimport._desktop(can, can._msg) } + sub.onexport.output = function() { can.onimport._desktop(can, can._msg) + can.Conf("session") && can.runActionCommand(event, "session", [can.Conf("session")], function(msg) { var item = msg.TableDetail() + can.onimport.session(can, can.base.Obj(item.args)) + }) + } }) }, _searchs: function(can) { can.onappend.plugin(can, {index: "web.chat.macos.searchs"}, function(sub) { can.ui.searchs = sub can.page.style(can, sub._target, html.LEFT, can.ConfWidth()/4, html.TOP, can.ConfHeight()/4), sub.onimport.size(sub, can.ConfHeight()/2, can.ConfWidth()/2, true) sub.onexport.record = function(sub, value, key, item) { if (item.cmd == ctx.COMMAND) { can.onimport._window(can, {index: can.core.Keys(item.type, item.name.split(lex.SP)[0])}) } if (item.type == nfs.FILE) { can.onimport._window(can, {index: web.CODE_VIMER, args: can.misc.SplitPath(can, item.text) }) } - } + }, can.ConfHeight() < 800 && can.onmotion.delay(can, function() { can.onmotion.hidden(can, sub._target) }) }) }, _notifications: function(can) { can.onappend.plugin(can, {index: "web.chat.macos.notifications", style: html.OUTPUT}, function(sub) { can.ui.notifications = sub sub.onexport.record = function(sub, value, key, item) { can.onimport._window(can, item) } + can.ConfHeight() < 800 && can.onmotion.delay(can, function() { can.onmotion.hidden(can, sub._target) }) }) }, _dock: function(can) { can.onappend.plugin(can, {index: "web.chat.macos.dock", style: html.OUTPUT}, function(sub) { can.ui.dock = sub - sub.onexport.output = function(sub, msg) { can.page.style(can, sub._target, html.LEFT, (can.ConfWidth()-msg.Length()*80)/2) } + sub.onexport.output = function(sub, msg) { can.page.style(can, sub._target, html.LEFT, can.base.Min((can.ConfWidth()-msg.Length()*80)/2, 0)) } sub.onexport.record = function(sub, value, key, item) { can.onimport._window(can, item) } }) }, _item: function(can, item) { can.runAction(can.request(event, item), mdb.CREATE, [], function() { can.run(event, [], function(msg) { @@ -37,13 +43,14 @@ Volcanos(chat.ONIMPORT, { remove: function() { can.runAction(event, mdb.REMOVE, [item.hash]) }, }); can.page.style(can, carte._target, html.TOP, event.y) }, }) }) }, - _desktop: function(can, msg) { var target = can.page.Append(can, can._output, [{view: html.DESKTOP}])._target; can.onimport.__item(can, msg, target), can.ui.desktop = target - target._tabs = can.onimport.tabs(can, [{name: "Desktop"+(can.page.Select(can, can._output, html.DIV_DESKTOP).length-1)}], function() { can.onmotion.select(can, can._output, "div.desktop", target), can.ui.desktop = target }, function() { can.page.Remove(can, target) }, can.ui.menu._output), target._tabs._desktop = target + _desktop: function(can, msg, name) { var target = can.page.Append(can, can._output, [{view: html.DESKTOP}])._target; can.onimport.__item(can, msg, target), can.ui.desktop = target + target._tabs = can.onimport.tabs(can, [{name: name||"Desktop"+(can.page.Select(can, can._output, html.DIV_DESKTOP).length-1)}], function() { can.onmotion.select(can, can._output, "div.desktop", target), can.ui.desktop = target }, function() { can.page.Remove(can, target) }, can.ui.menu._output), target._tabs._desktop = target target.ondragend = function() { can.onimport._item(can, window._drag_item) } }, - _window: function(can, item) { - item.top = 125, item.height = can.base.Min(can.ConfHeight()-400, 480, 800), item.width = can.base.Min(can.ConfWidth()-400, 640, 1000) + _window: function(can, item) { if (!item.index) { return } + item.left = 100, item.top = 125, item.height = can.base.Min(can.ConfHeight()-400, 480, 800), item.width = can.base.Min(can.ConfWidth()-400, 640, 1000) if (can.ConfHeight() < 800) { item.top = 25, item.height = can.ConfHeight()-165 } + if (can.user.isMobile) { item.left = 0, item.top = 25 } can.onappend.plugin(can, item, function(sub) { can.ondetail.select(can, sub._target) var index = 0; can.core.Item({ "#f95f57": function(event) { sub.onaction.close(event, sub) }, @@ -54,7 +61,7 @@ Volcanos(chat.ONIMPORT, { }, "#32c840": function(event) { sub.onaction.full(event, sub) }, }, function(color, cb) { can.page.insertBefore(can, [{view: [[html.ITEM, html.BUTTON]], style: {"background-color": color, right: 10+20*index++}, onclick: cb}], sub._output) }) - sub.onimport.size(sub, item.height, item.width, true), can.onmotion.move(can, sub._target, {"z-index": 10, top: item.top, left: 100}) + sub.onimport.size(sub, item.height, item.width, true), can.onmotion.move(can, sub._target, {"z-index": 10, top: item.top, left: item.left}) sub.onimport._open = function(sub, msg, arg) { can.onimport._window(can, {index: "web.chat.iframe", args: [arg]}) } sub.onmotion.resize(can, sub._target, function(height, width) { sub.onimport.size(sub, height, width) }, 25) sub.onexport.record = function(sub, value, key, item) { can.onimport._window(can, item) } @@ -63,13 +70,18 @@ Volcanos(chat.ONIMPORT, { sub.onappend.desktop = function(item) { can.onimport._item(can, item) } sub.onappend.dock = function(item) { can.ui.dock.runAction(can.request(event, item), mdb.CREATE, [], function() { can.ui.dock.Update() }) } sub.onexport.output = function() { if (item.index == "web.chat.macos.opens") { can.page.Remove(can, sub._target) } } + sub._target.onclick = function(event) { can.page.Select(can, sub._target.parentNode, html.FIELDSET, function(target) { can.page.style(can, target, "z-index", target == sub._target? "10": "9") }) } }, can.ui.desktop) }, - session: function(can, list) { can.page.Select(can, can._output, html.DIV_DESKTOP, function(target) { can.page.Remove(can, target) }), can.onmotion.clear(can, can._action) - can.core.List(list, function(item) { can.onimport._desktop(can), can.core.List(item.list, function(item) { can.onimport._window(can, item) }) }) + session: function(can, list) { can.page.Select(can, can._output, html.DIV_DESKTOP, function(target) { can.page.Remove(can, target) }) + can.page.Select(can, can.ui.menu._output, html.DIV_TABS, function(target) { can.page.Remove(can, target) }) + can.core.List(list, function(item) { can.onimport._desktop(can, null, item.name), can.core.List(item.list, function(item) { can.onimport._window(can, item) }) }) + }, + layout: function(can) { + can.page.style(can, can._output, html.HEIGHT, can.ConfHeight(), html.WIDTH, can.ConfWidth()) + can.ui.dock && can.page.style(can, can.ui.dock._target, html.LEFT, can.base.Min((can.ConfWidth()-can.ui.dock._target.offsetWidth)/2, 0)) }, - layout: function(can) { can.page.styleHeight(can, can._output, can.ConfHeight()) }, }, [""]) Volcanos(chat.ONACTION, {list: ["full"], create: function(event, can, button) { can.onimport._desktop(can) }, @@ -85,8 +97,8 @@ Volcanos(chat.ONFIGURE, { var _carte = can.user.carteRight(event, can, {}, [{view: [html.ITEM, "", mdb.CREATE], onclick: function(event) { can.user.input(event, can, [mdb.NAME], function(list) { var args = can.page.SelectChild(can, can._output, html.DIV_DESKTOP, function(target) { - return {name: can.page.Select(can, target._tabs, html.SPAN_NAME).innerText, list: can.page.SelectChild(can, target, html.FIELDSET, function(target) { - return {index: target._can._index, args: target._can.onexport.args(target._can), style: {left: target.offsetLeft, top: target.offsetTop}} + return {name: can.page.SelectOne(can, target._tabs, html.SPAN_NAME).innerText, list: can.page.SelectChild(can, target, html.FIELDSET, function(target) { + return {index: target._can._index, args: target._can.onexport.args(target._can), style: {left: target.offsetLeft||100, top: target.offsetTop||25}} })} }) can.runActionCommand(event, "session", [ctx.ACTION, mdb.CREATE, mdb.NAME, list[0], ctx.ARGS, JSON.stringify(args)], function(msg) { @@ -97,6 +109,9 @@ Volcanos(chat.ONFIGURE, { return {view: [html.ITEM, "", value.name], onclick: function() { can.onimport.session(can, can.base.Obj(value.args, [])) }, oncontextmenu: function(event) { can.user.carteRight(event, can, { + open: function() { + can.user.open(can.misc.MergePodCmd(can, {cmd: "desktop", session: value.name})) + }, remove: function() { can.runActionCommand(event, "session", [mdb.REMOVE, value.name], function() { can.user.toastSuccess(can, "session removed") }) }, }, [], function() {}, _carte) }, } @@ -116,9 +131,7 @@ Volcanos(chat.ONFIGURE, { }, "window\t>": function(event, can, carte) { can.user.carteRight(event, can, {}, [{view: [html.ITEM, "", mdb.CREATE], onclick: function(event) { - can.user.input(event, can, [ctx.INDEX, ctx.ARGS], function(data) { - can.onimport._window(can, data) - }) + can.user.input(event, can, [ctx.INDEX, ctx.ARGS], function(data) { can.onimport._window(can, data) }) }}, ""].concat(can.page.Select(can, can.ui.desktop, "fieldset>legend", function(legend) { return {view: [html.ITEM, "", legend.innerText+(legend.parentNode.style["z-index"] == "10"? " *": "")], onclick: function(event) { can.ondetail.select(can, legend.parentNode) diff --git a/core/chat/macos/dock.go b/core/chat/macos/dock.go index 18c19e16..ab802ef6 100644 --- a/core/chat/macos/dock.go +++ b/core/chat/macos/dock.go @@ -2,11 +2,27 @@ package macos import ( ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/mdb" + "shylinux.com/x/icebergs/base/web" ) const DOCK = "dock" -func init() { Index.MergeCommands(ice.Commands{DOCK: {Actions: CmdHashAction()}}) } +func init() { + Index.MergeCommands(ice.Commands{DOCK: {Actions: ice.MergeActions(ice.Actions{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + if m.Cmd(DOCK).Length() == 0 { + DockAppend(m, "Finder", Prefix(FINDER)) + DockAppend(m, "Safari", web.CHAT_IFRAME) + DockAppend(m, "Terminal", web.CODE_XTERM) + DockAppend(m, "", web.CODE_GIT_REPOS, mdb.ICON, "usr/icons/git.jpg") + DockAppend(m, "", web.CODE_COMPILE, mdb.ICON, "usr/icons/go.png") + DockAppend(m, "", web.CODE_VIMER) + DockAppend(m, "", web.DREAM) + } + }}, + }, mdb.ImportantHashAction(), CmdHashAction())}}) +} func DockAppend(m *ice.Message, name, index string, arg ...string) { install(m, DOCK, name, index, arg...) diff --git a/core/chat/macos/dock.js b/core/chat/macos/dock.js index 5a48179c..6f72a353 100644 --- a/core/chat/macos/dock.js +++ b/core/chat/macos/dock.js @@ -5,13 +5,13 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) { can.onmotion.clear(can) remove: function() { item.name != "Finder" && can.runAction(event, mdb.REMOVE, [item.hash]) }, }); can.page.style(can, carte._target, html.LEFT, event.x) }, }) }), can.page.Append(can, can._output, [{view: "space"}]) + can.page.style(can, can._output, html.MAX_WIDTH, can.page.width()) return var current = null, before, begin can.page.SelectChild(can, can._output, mdb.FOREACH, function(target) { target.draggable = true target.ondragstart = function() { current = target, can.page.style(can, target, "visibility", html.HIDDEN) } target.ondragenter = function(event) { before = target, begin = {x: event.x, y: event.y} } target.ondragover = function(event) { var offset = event.x - begin.x; can.page.style(can, target, {position: "relative", left: -offset}) } - target.ondragleave = function(event) { } target.ondragend = function(event) { before && can.page.insertBefore(can, current, before) can.page.SelectChild(can, can._output, mdb.FOREACH, function(target) { can.page.style(can, target, {position: "", left: "", visibility: html.VISIBLE}) }) } diff --git a/core/chat/macos/menu.go b/core/chat/macos/menu.go index ae0d587e..abb2d9f5 100644 --- a/core/chat/macos/menu.go +++ b/core/chat/macos/menu.go @@ -1,7 +1,22 @@ package macos -import ice "shylinux.com/x/icebergs" +import ( + ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/mdb" +) const MENU = "menu" -func init() { Index.MergeCommands(ice.Commands{MENU: {Actions: CmdHashAction()}}) } +func init() { + Index.MergeCommands(ice.Commands{MENU: {Actions: ice.MergeActions(ice.Actions{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + if m.Cmd(MENU).Length() == 0 { + MenuAppend(m, "", Prefix(NOTIFICATIONS)) + MenuAppend(m, "", Prefix(SEARCHS)) + } + }}, + }, mdb.ImportantHashAction(), CmdHashAction())}}) +} +func MenuAppend(m *ice.Message, name, index string, arg ...string) { + install(m, MENU, name, index, arg...) +} diff --git a/core/chat/macos/menu.js b/core/chat/macos/menu.js index 89930200..05a36a83 100644 --- a/core/chat/macos/menu.js +++ b/core/chat/macos/menu.js @@ -1,6 +1,9 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) { can.page.Append(can, can._output, can.user.header(can)), can.page.Append(can, can._output, [ - {view: [html.ITEM, "", "notifications"], onclick: function(event) { can.sup.onexport.record(can, "notifications") }}, - {view: [html.ITEM, "", "searchs"], onclick: function(event) { can.sup.onexport.record(can, "searchs") }}, + {view: [html.ITEM], list: [{img: can.page.drawText(can, "n", 25, 0, 20)}], onclick: function(event) { can.sup.onexport.record(can, "notifications") }}, + {view: [html.ITEM], list: [{img: can.page.drawText(can, "s", 25, 0, 20)}], onclick: function(event) { can.sup.onexport.record(can, "searchs") }}, +].concat(msg.Table(function(item) { + return {view: [html.ITEM], list: [{img: can.page.drawText(can, item.index, 25, 0, 20)}], onclick: function(event) { can.sup.onexport.record(can, item) }} +}), [ {view: [html.MENU, "", location.hostname], onclick: function(event) { can.sup.onexport.record(can, html.DESKTOP) }}, {view: [html.MENU, "", "+"], onclick: function(event) { can.sup.onexport.record(can, mdb.CREATE) }}, -]) }}) +])) }}) diff --git a/core/chat/macos/notifications.js b/core/chat/macos/notifications.js index 917f8664..977ae987 100644 --- a/core/chat/macos/notifications.js +++ b/core/chat/macos/notifications.js @@ -6,7 +6,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) { 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) }} })), 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: [mdb.PRUNES, web.UPDATE, "toggle"], +Volcanos(chat.ONACTION, {list: [web.UPDATE, mdb.PRUNES, web.TOGGLE], _trans: {update: "刷新", toggle: "隐藏"}, update: function(event, can, button) { can.Update(event) }, toggle: function(event, can, button) { can.onmotion.hidden(can, can._fields) }, }) diff --git a/core/chat/macos/searchs.go b/core/chat/macos/searchs.go index ee19c119..5f702ecc 100644 --- a/core/chat/macos/searchs.go +++ b/core/chat/macos/searchs.go @@ -9,7 +9,7 @@ import ( const SEARCHS = "searchs" func init() { - Index.MergeCommands(ice.Commands{SEARCHS: {Name: "search keyword list", Hand: func(m *ice.Message, arg ...string) { + Index.MergeCommands(ice.Commands{SEARCHS: {Name: "searchs keyword list", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.SEARCH, mdb.FOREACH, kit.Select("", arg, 0), "ctx,cmd,type,name,text") }}}) } diff --git a/core/chat/macos/session.go b/core/chat/macos/session.go index fea047a2..9f8afba7 100644 --- a/core/chat/macos/session.go +++ b/core/chat/macos/session.go @@ -7,4 +7,10 @@ import ( const SESSION = "session" -func init() { Index.MergeCommands(ice.Commands{SESSION: {Actions: CmdHashAction(mdb.NAME)}}) } +func init() { + Index.MergeCommands(ice.Commands{SESSION: {Actions: ice.MergeActions(mdb.ImportantHashAction(), CmdHashAction(mdb.NAME)), Hand: func(m *ice.Message, arg ...string) { + if mdb.HashSelect(m, arg...); len(arg) > 0 { + m.EchoIFrame(m.MergePodCmd("", DESKTOP, SESSION, arg[0])) + } + }}}) +} diff --git a/core/chat/river.go b/core/chat/river.go index 56145222..b066f9ae 100644 --- a/core/chat/river.go +++ b/core/chat/river.go @@ -55,7 +55,7 @@ func init() { } gdb.Event(m, RIVER_CREATE, RIVER, m.Option(ice.MSG_RIVER, h), arg) }}, - }, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,template"), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) { + }, mdb.ImportantHashAction(), mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,template"), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) { if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || !aaa.Right(m, RIVER, arg) { return } else if len(arg) == 0 { diff --git a/core/team/plan.go b/core/team/plan.go index 77d24231..7c185739 100644 --- a/core/team/plan.go +++ b/core/team/plan.go @@ -74,7 +74,10 @@ func init() { m.Cmdy(arg) } }}, - }, TASK, ctx.CmdAction(), aaa.RoleAction(ctx.COMMAND)), Hand: func(m *ice.Message, arg ...string) { + web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { + kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "计划")) }) + }}, + }, TASK, web.DreamAction(), ctx.CmdAction(), aaa.RoleAction(ctx.COMMAND)), Hand: func(m *ice.Message, arg ...string) { begin_time, end_time := _plan_scope(m, kit.Slice(arg, 0, 2)...) _plan_list(m, begin_time.Format(ice.MOD_TIME), end_time.Format(ice.MOD_TIME)) web.PushPodCmd(m, "", arg...) diff --git a/core/team/task.go b/core/team/task.go index 803e00aa..53b878c0 100644 --- a/core/team/task.go +++ b/core/team/task.go @@ -73,7 +73,6 @@ func init() { m.Option(ctx.INDEX, m.Option("extra.index")) ctx.CmdInputs(m, arg...) default: - m.Debug("what %v", arg) mdb.ZoneInputs(m, arg) } }}, @@ -84,7 +83,7 @@ func init() { CANCEL: {Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, CANCEL) }}, BEGIN: {Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, PROCESS) }}, END: {Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, FINISH) }}, - }, mdb.ZoneAction(mdb.FIELD, "begin_time,close_time,id,status,level,score,type,name,text")), Hand: func(m *ice.Message, arg ...string) { + }, mdb.ImportantZoneAction(), mdb.ZoneAction(mdb.FIELD, "begin_time,close_time,id,status,level,score,type,name,text")), Hand: func(m *ice.Message, arg ...string) { if mdb.ZoneSelect(m, arg...); len(arg) > 0 && arg[0] != "" { status := map[string]int{} m.Table(func(value ice.Maps) { m.PushButton(_task_action(m, value[STATUS])) }) diff --git a/core/wiki/draw.go b/core/wiki/draw.go index 7fc7a3a0..800aa8e9 100644 --- a/core/wiki/draw.go +++ b/core/wiki/draw.go @@ -26,7 +26,10 @@ func init() { defer m.Echo("").Echo("") m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1])) }}, - }, WikiAction("", nfs.SVG), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { + kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "导图")) }) + }}, + }, web.DreamAction(), WikiAction("", nfs.SVG), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { kit.If(!_wiki_list(m, arg...), func() { _wiki_show(m, arg[0]) kit.If(m.IsErr(), func() { m.Option(ice.MSG_OUTPUT, "") }) diff --git a/core/wiki/word.go b/core/wiki/word.go index bb877f60..a1e6f2ee 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -52,7 +52,10 @@ func init() { ls := kit.Split(m.Option(mdb.TEXT)) kit.If(kit.IsIn(ls[0], IMAGE, VIDEO, AUDIO), func() { m.Cmdy(FEEL).CutTo(nfs.PATH, mdb.NAME) }) }}, - }, WikiAction("", nfs.SHY), ctx.CmdAction(), aaa.RoleAction("story.field")), Hand: func(m *ice.Message, arg ...string) { + web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { + kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "文档")) }) + }}, + }, web.DreamAction(), WikiAction("", nfs.SHY), ctx.CmdAction(), aaa.RoleAction("story.field")), Hand: func(m *ice.Message, arg ...string) { if m.Option(nfs.DIR_DEEP, ice.TRUE); len(arg) == 0 { arg = append(arg, nfs.SRC) } diff --git a/misc/git/repos.go b/misc/git/repos.go index e0e6f56b..136a9f07 100644 --- a/misc/git/repos.go +++ b/misc/git/repos.go @@ -161,7 +161,7 @@ func _repos_status(m *ice.Message, p string, repos *git.Repository) error { for k, v := range status { if kit.IsIn(k, ice.SRC_VERSION_GO, ice.SRC_BINPACK_GO, ice.ETC_LOCAL_SHY) { continue - } else if kit.IsIn(kit.Ext(k), "swp", "swo") || kit.IsIn(kit.Split(k, nfs.PS)[0], ice.BIN, ice.VAR, ice.USR) { + } else if kit.IsIn(kit.Ext(k), "swp", "swo") || kit.IsIn(kit.Split(k, nfs.PS)[0], ice.BIN, ice.VAR, ice.USR) && !strings.HasPrefix(k, ice.USR_LOCAL_EXPORT) { continue } if m.Push(REPOS, p).Push(STATUS, string(v.Worktree)+string(v.Staging)).Push(nfs.FILE, k); m.Option(ice.MSG_MODE) == mdb.ZONE { @@ -177,6 +177,29 @@ func _repos_status(m *ice.Message, p string, repos *git.Repository) error { m.PushButton(COMMIT) } } + if p == path.Base(kit.Path("")) { + var tree *object.Tree + if refer, err := repos.Head(); err == nil { + if commit, err := repos.CommitObject(refer.Hash()); err == nil { + tree, err = commit.Tree() + } + } + m.Cmd(nfs.DIR, ice.USR_LOCAL_EXPORT, kit.Dict(nfs.DIR_DEEP, ice.TRUE, nfs.DIR_TYPE, nfs.TYPE_CAT), func(value ice.Maps) { + if _, ok := status[value[nfs.PATH]]; ok { + return + } else if tree != nil { + if file, err := tree.File(value[nfs.PATH]); err == nil { + if content, err := file.Contents(); err == nil && strings.TrimSpace(content) == strings.TrimSpace(m.Cmdx(nfs.CAT, value[nfs.PATH])) { + return + } else { + m.Push(REPOS, p).Push(STATUS, "M").Push(nfs.FILE, value[nfs.PATH]).PushButton(ADD) + return + } + } + } + m.Push(REPOS, p).Push(STATUS, "??").Push(nfs.FILE, value[nfs.PATH]).PushButton(ADD) + }) + } return nil } func _repos_total(m *ice.Message, p string, repos *git.Repository, stats map[string]int) *time.Time { @@ -444,6 +467,7 @@ func init() { if commit, err := repos.CommitObject(refer.Hash()); err == nil { _last := commit.Author.When.Format(ice.MOD_TIME) kit.If(_last > last, func() { last = _last }) + } } if _remote, err := repos.Remote(ORIGIN); err == nil && (remote == "" || remote == path.Base(kit.Path(""))) { diff --git a/misc/git/status.go b/misc/git/status.go index 07b85494..874f231b 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -154,7 +154,7 @@ func init() { } m.Push(mdb.TEXT, strings.Join(text, ", ")) }}, - }, aaa.RoleAction(), gdb.EventAction(web.DREAM_TABLES), Prefix(REPOS), mdb.ImportantDataAction()), Hand: func(m *ice.Message, arg ...string) { + }, aaa.RoleAction(), gdb.EventAction(web.DREAM_TABLES), Prefix(REPOS), mdb.ImportantHashAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && arg[0] == ctx.ACTION { m.Cmdy(REPOS, arg) } else if config, err := config.LoadConfig(config.GlobalScope); err == nil && config.User.Email == "" && mdb.Config(m, aaa.EMAIL) == "" { diff --git a/type.go b/type.go index 8df9f5d7..dd038008 100644 --- a/type.go +++ b/type.go @@ -144,7 +144,6 @@ func (c *Context) Merge(s *Context) *Context { } c.Commands[key] = cmd kit.If(cmd.Meta == nil, func() { cmd.Meta = kit.Dict() }) - kit.If(cmd.List == nil, func() { cmd.List = SplitCmd(cmd.Name, cmd.Actions) }) for sub, action := range cmd.Actions { if pre, ok := c.Commands[sub]; ok && s == c { kit.Switch(sub, @@ -162,6 +161,7 @@ func (c *Context) Merge(s *Context) *Context { } } } + kit.If(sub == SELECT, func() { cmd.Name = kit.Select(action.Name, cmd.Name) }) if help := kit.Split(action.Help, " ::"); len(help) > 0 { if kit.Value(cmd.Meta, kit.Keys("_trans", strings.TrimPrefix(sub, "_")), help[0]); len(help) > 1 { kit.Value(cmd.Meta, kit.Keys("_title", sub), help[1]) @@ -173,6 +173,8 @@ func (c *Context) Merge(s *Context) *Context { kit.If(action.List == nil, func() { action.List = SplitCmd(action.Name, nil) }) kit.If(len(action.List) > 0, func() { cmd.Meta[sub] = action.List }) } + kit.If(strings.HasPrefix(cmd.Name, "list"), func() { cmd.Name = strings.Replace(cmd.Name, "list", key, 1) }) + kit.If(cmd.List == nil, func() { cmd.List = SplitCmd(cmd.Name, cmd.Actions) }) } kit.If(c.Configs == nil, func() { c.Configs = Configs{} }) for k, v := range s.Configs {