From 7f7a0429519df9919bc48e3af49bb1f512a98008 Mon Sep 17 00:00:00 2001 From: shy Date: Tue, 27 Feb 2024 22:02:19 +0800 Subject: [PATCH] add some --- base/web/cache.go | 7 ++++--- base/web/dream.go | 4 ++-- base/web/matrix.go | 4 ++-- base/web/render.go | 1 + base/web/space.go | 8 ++++++++ core/chat/macos/desktop.go | 1 + core/chat/message.css | 24 +++++++++++++++++------- core/chat/message.go | 10 ++++++---- core/chat/message.js | 33 +++++++++++++++++++++++++-------- 9 files changed, 66 insertions(+), 26 deletions(-) diff --git a/base/web/cache.go b/base/web/cache.go index 45832e4f..717e5e5f 100644 --- a/base/web/cache.go +++ b/base/web/cache.go @@ -152,9 +152,10 @@ func init() { } }}, }, mdb.HashAction(mdb.SHORT, mdb.TEXT, mdb.FIELD, "time,hash,size,type,name,text,file"), ice.RenderAction(ice.RENDER_DOWNLOAD)), Hand: func(m *ice.Message, arg ...string) { - if mdb.HashSelect(m, arg...); len(arg) == 0 || m.R != nil && m.R.Method == http.MethodGet { - m.Option(ice.MSG_ACTION, "") - } else if m.Length() == 0 { + if mdb.HashSelect(m, arg...); len(arg) == 0 { + return + } + if m.Length() == 0 { return } else if m.Append(nfs.FILE) == "" { m.PushScript(mdb.TEXT, m.Append(mdb.TEXT)) diff --git a/base/web/dream.go b/base/web/dream.go index f0d4472b..9c60acf5 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -418,7 +418,7 @@ func init() { case WORKER: m.PushButton(cli.RUNTIME, tcp.SEND, OPEN) default: - m.PushButton(cli.RUNTIME, OPEN) + m.PushButton(cli.RUNTIME, DREAM, OPEN) } }}, STATS_TABLES: {Hand: func(m *ice.Message, arg ...string) { @@ -432,7 +432,7 @@ func init() { }}, }, StatsAction(), DreamAction(), DreamTablesAction(), mdb.ImportantHashAction( mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icons,repos,binary,template,restart", - html.BUTTON, kit.JoinWord(PORTAL, DESKTOP, ADMIN, WORD, STATUS, VIMER, COMPILE, XTERM, DREAM), + html.BUTTON, kit.JoinWord(PORTAL, DESKTOP, ADMIN, MESSAGE, WORD, STATUS, VIMER, COMPILE, XTERM, DREAM), ctx.TOOLS, kit.Simple(SPIDE, STORE, MATRIX, ROUTE), )), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { diff --git a/base/web/matrix.go b/base/web/matrix.go index 65243646..7a7eaa65 100644 --- a/base/web/matrix.go +++ b/base/web/matrix.go @@ -29,9 +29,9 @@ func _matrix_list(m *ice.Message, domain, icon, typ string, fields ...string) (s m.PushRecord(value, fields...).PushButton(button...) switch typ { case MYSELF: - button = []ice.Any{PORTAL, WORD, STATUS, VIMER, COMPILE, cli.RUNTIME, XTERM, DESKTOP, ADMIN, OPEN} + button = []ice.Any{PORTAL, WORD, STATUS, VIMER, COMPILE, cli.RUNTIME, MESSAGE, XTERM, DESKTOP, ADMIN, OPEN} case SERVER: - button = []ice.Any{PORTAL, DESKTOP, ADMIN, OPEN, UPGRADE, cli.RUNTIME, WORD, STATUS, VIMER, XTERM} + button = []ice.Any{PORTAL, DESKTOP, ADMIN, OPEN, UPGRADE, cli.RUNTIME, MESSAGE, WORD, STATUS, VIMER, XTERM} default: button = []ice.Any{PORTAL, DESKTOP, ADMIN, OPEN, XTERM, cli.RUNTIME, WORD, STATUS, VIMER} } diff --git a/base/web/render.go b/base/web/render.go index 486fd058..a4138008 100644 --- a/base/web/render.go +++ b/base/web/render.go @@ -184,6 +184,7 @@ const ( WIKI_WORD = "web.wiki.word" WIKI_PORTAL = "web.wiki.portal" CHAT_OAUTH_CLIENT = "web.chat.oauth.client" + CHAT_MESSAGE = "web.chat.message" CHAT_HEADER = "web.chat.header" CHAT_IFRAME = "web.chat.iframe" CHAT_FAVOR = "web.chat.favor" diff --git a/base/web/space.go b/base/web/space.go index 1ed9ae06..e911cad8 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -233,6 +233,14 @@ func _space_send(m *ice.Message, name string, arg ...string) (h string) { } } }) { + if target[0] == ice.OPS { + if ice.Info.NodeType == SERVER { + if name == ice.OPS { + m.Cmdy(arg) + return + } + } + } kit.If(m.IsDebug(), func() { m.WarnNotFound(kit.IndexOf([]string{ice.OPS, ice.DEV}, target[0]) == -1, SPACE, name) }) diff --git a/core/chat/macos/desktop.go b/core/chat/macos/desktop.go index 48139b41..57ef88b5 100644 --- a/core/chat/macos/desktop.go +++ b/core/chat/macos/desktop.go @@ -24,6 +24,7 @@ func init() { DeskAppend(m, "Photos.png", web.WIKI_FEEL) DeskAppend(m, "Grapher.png", web.WIKI_DRAW) DeskAppend(m, "Calendar.png", web.TEAM_PLAN) + DeskAppend(m, "Messages.png", web.CHAT_MESSAGE) } if m.Cmd(DOCK).Length() == 0 { DockAppend(m, "Finder.png", Prefix(FINDER)) diff --git a/core/chat/message.css b/core/chat/message.css index e1faaebf..c8aff202 100644 --- a/core/chat/message.css +++ b/core/chat/message.css @@ -1,18 +1,20 @@ body.light fieldset.web.chat.message>div.output { background-color:white; } body.light fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list { background-color:#e3e3e2; } body.light fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item:not(.plug).myself div.content { background-color:#94ec69; } -fieldset.web.chat.message>div.output>div.project>div.title { padding:var(--button-padding); display:flex; justify-content:space-between; position:sticky; top:0; z-index:2; } +fieldset.web.chat.message>div.output>div.project>div.title { background-color:var(--plugin-bg-color); padding:var(--button-padding); display:flex; justify-content:space-between; position:sticky; top:0; z-index:2; } fieldset.web.chat.message>div.output>div.project>div.title i:hover { background-color:var(--hover-bg-color); cursor:pointer; } fieldset.web.chat.message>div.output>div.project>div.title span:hover { background-color:var(--hover-bg-color); cursor:pointer; } fieldset.web.chat.message>div.output>div.project>div.item.text.filter>i { left:var(--input-padding); } -fieldset.web.chat.message>div.output>div.project>div.item { height:58px; padding:var(--input-padding); } +fieldset.web.chat.message>div.output>div.project>div.item:not(.filter) { height:58px; padding:var(--input-padding); } +fieldset.web.chat.message>div.output>div.project>div.item.select { border-right:unset; } fieldset.web.chat.message>div.output>div.project>div.item img { height:var(--header-height); width:var(--header-height); display:block; float:left; } fieldset.web.chat.message>div.output>div.project>div.item span.time { color:var(--disable-fg-color); font-size:var(--status-font-size); } -fieldset.web.chat.message>div.output>div.project>div.item div.container { padding:0 var(--input-padding); width:calc(100% - var(--header-height)); float:left; } +fieldset.web.chat.message>div.output>div.project>div.item div.container { padding:0 var(--input-padding); width:calc(100% - var(--header-height) - 2*var(--input-padding)); float:left; } fieldset.web.chat.message>div.output>div.project>div.item div.title { display:flex; justify-content:space-between; } +fieldset.web.chat.message>div.output>div.project>div.item div.title>span:first-child { margin-right:var(--input-margin); overflow:hidden; flex-shrink:1; } fieldset.web.chat.message>div.output>div.project>div.item div.content { color:var(--disable-fg-color); font-size:var(--status-font-size); } fieldset.web.chat.message>div.output>div.layout>div.layout>div.content { overflow:hidden; } -fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.title { padding:var(--button-padding); display:flex; justify-content:space-between; position:sticky; top:0; z-index:2; } +fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.title { background-color:var(--plugin-bg-color); padding:var(--button-padding); display:flex; justify-content:space-between; position:sticky; top:0; z-index:2; } fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.title i:hover { background-color:var(--hover-bg-color); cursor:pointer; } fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.title span:hover { background-color:var(--hover-bg-color); cursor:pointer; } fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item { padding:var(--input-padding); min-height:fit-content; display:flex; } @@ -24,13 +26,21 @@ fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list> fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item div.container>span.from { color:var(--disable-fg-color); font-size:var(--status-font-size); padding:0 var(--input-padding); } fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.myself div.container>span.from { float:right; } fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.myself div.container { display:flex; flex-direction:column; align-items:flex-end; } -fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.text div.content { padding:var(--input-padding) var(--button-padding); } -fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item>div.container>div.content { display:flex; align-items:center; border-radius:var(--plugin-radius); min-height:var(--header-height); width:fit-content; } +fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.text div.content { white-space:pre; padding:var(--input-padding) var(--button-padding); } +fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.plug>div.container>div.content { + box-shadow:var(--box-shadow); +} +fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.plug>div.container>div.content:hover { + box-shadow:var(--notice-box-shadow); +} +fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item>div.container>div.content { + display:flex; align-items:center; border-radius:var(--plugin-radius); + min-height:var(--header-height); width:fit-content; } fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.plug { height:fit-content; } fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.plug div.content { padding:0; } fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.myself { flex-direction:row-reverse; } fieldset.web.chat.message>div.output>div.layout>div.display { height:120px; overflow:hidden; } -fieldset.web.chat.message>div.output>div.layout>div.display div.toolkit { height:var(--action-height); display:flex; } +fieldset.web.chat.message>div.output>div.layout>div.display div.toolkit { background-color:var(--plugin-bg-color); height:var(--action-height); display:flex; align-items:center; } fieldset.web.chat.message>div.output>div.layout>div.display div.toolkit i { padding:var(--input-padding); } fieldset.web.chat.message>div.output>div.layout>div.display div.toolkit i:hover { background-color:var(--hover-bg-color); } fieldset.web.chat.message>div.output>div.layout>div.display textarea { height:calc(100% - var(--action-height)); } diff --git a/core/chat/message.go b/core/chat/message.go index 3b9e6c6b..e2f84d6b 100644 --- a/core/chat/message.go +++ b/core/chat/message.go @@ -19,7 +19,7 @@ func init() { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { messageCreate(m, web.DREAM, "usr/icons/Launchpad.png") messageCreate(m, cli.SYSTEM, "usr/icons/System Settings.png") - messageInsert(m, cli.SYSTEM, mdb.TYPE, "plug", ctx.INDEX, cli.RUNTIME) + messageInsert(m, cli.SYSTEM, mdb.TYPE, "text", mdb.NAME, cli.RUNTIME, mdb.TEXT, m.Cmdx(cli.RUNTIME), ctx.DISPLAY, "/plugin/story/json.js") }}, mdb.CREATE: {Name: "create type*=tech,void zone* icons* target"}, mdb.INSERT: {Hand: func(m *ice.Message, arg ...string) { @@ -33,10 +33,12 @@ func init() { mdb.HashSelectUpdate(m, m.Option(ice.FROM_SPACE), func(value ice.Map) { kit.Value(value, mdb.TIME, m.Time()) }) }}, web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) { - messageInsert(m, web.DREAM, mdb.TYPE, "plug", ctx.INDEX, IFRAME, ctx.ARGS, web.S(m.Option(mdb.NAME))) + if ice.Info.Important { + messageInsert(m, web.DREAM, mdb.TYPE, "plug", ctx.INDEX, IFRAME, ctx.ARGS, web.S(m.Option(mdb.NAME))) + } }}, - }, web.DreamAction(), mdb.ZoneAction( - mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,hash,type,zone,icons,target", mdb.FIELDS, "time,id,avatar,usernick,username,type,name,text,space,index,args", + }, web.DreamAction(), web.DreamTablesAction(), mdb.ZoneAction( + mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,hash,type,zone,icons,title,count,target", mdb.FIELDS, "time,id,avatar,usernick,username,type,name,text,space,index,args,style,display", )), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { mdb.ZoneSelect(m.Display("").Spawn(), arg...).Table(func(value ice.Maps) { diff --git a/core/chat/message.js b/core/chat/message.js index 7d38814f..3fe3ddde 100644 --- a/core/chat/message.js +++ b/core/chat/message.js @@ -12,8 +12,8 @@ Volcanos(chat.ONIMPORT, { msg.Table(function(value) { var _target = can.page.Append(can, can.ui.project, [{view: html.ITEM, list: [ {img: can.misc.Resource(can, value.icons||"usr/icons/Messages.png")}, {view: html.CONTAINER, list: [ - {view: wiki.TITLE, list: [{text: value.zone||"[未命名]"}, {text: [can.base.TimeTrim(value.time), "", mdb.TIME]}]}, - {view: wiki.CONTENT, list: [{text: value.text||"[未知消息]"}]}, + {view: wiki.TITLE, list: [{text: value.title||value.zone||"[未命名]"}, {text: [can.base.TimeTrim(value.time), "", mdb.TIME]}]}, + {view: wiki.CONTENT, list: [{text: value.target||"[未知消息]"}]}, ]}, ], onclick: function(event) { can.isCmdMode() && can.misc.SearchHash(can, value.zone), can.onimport._switch(can, false) can.db.zone = value, can.db.hash = value.hash, can.onmotion.select(can, can.ui.project, html.DIV_ITEM, _target) @@ -58,7 +58,7 @@ Volcanos(chat.ONIMPORT, { ]}]) }), can.onappend._status(can, msg.Option(ice.MSG_STATUS)), can.onimport.layout(can) if (can.Status(mdb.TOTAL) > can.db.zone.id) { can.onimport._request(can) } - can.onmotion.delay(can, function() { can.ui.message && (can.ui.message.scrollTop += 10000) }) + can.onmotion.delay(can, function() { can.ui.message && (can.ui.message.scrollTop += 10000) }, 300) }, _request: function(can) { can.run(can.request(event, {"cache.begin": parseInt(can.db.zone.id||0)+1, "cache.limit": 10}), [can.db.hash], function(msg) { @@ -82,6 +82,14 @@ Volcanos(chat.ONIMPORT, { can.ui.title && can.page.style(can, can.ui.message, html.HEIGHT, can.ui.content.offsetHeight-can.ui.title.offsetHeight) }, }, [""]) +Volcanos(chat.ONEXPORT, { + plugHeight: function(can, value) { var height = can.base.Min(can.ui.content.offsetHeight-240, 240) + return can.base.Max(html.STORY_HEIGHT, height, height/(can.base.isIn(value.index, html.IFRAME)? 1: 2)) + }, + plugWidth: function(can, value) { + return can.ui.content.offsetWidth-(can.user.isMobile? 60: 180) + }, +}) Volcanos(chat.ONDETAIL, { "bi bi-mic": function(event, can) {}, "bi bi-card-image": function(event, can) { @@ -101,13 +109,22 @@ Volcanos(chat.ONDETAIL, { }) Volcanos(chat.ONFIGURE, { image: function(can, value) { return {view: wiki.CONTENT, list: [{img: can.misc.Resource(can, value.text)}]} }, - text: function(can, value) { return {view: wiki.CONTENT, list: [{text: value.text||"[未知消息]"}]} }, - plug: function(can, value) { var height = can.base.Min(can.ui.content.offsetHeight-210, 240) - var height = can.base.Max(html.PLUG_HEIGHT, height, height/(can.base.isIn(value.index, html.IFRAME)? 1: 2)), width = can.ui.content.offsetWidth-(can.user.isMobile? 60: 180) - return {view: wiki.CONTENT, style: {height: height, width: width}, _init: function(target) { value.type = chat.STORY + text: function(can, value) { + return {view: wiki.CONTENT, list: [{text: value.text||"[未知消息]"}], _init: function(target) { + if (value.display) { var msg = can.request(); msg.Echo(value.text), can.onmotion.clear(can, target) + var height = can.onexport.plugHeight(can, value), width = can.onexport.plugWidth(can, value) + can.onappend.plugin(can, {title: value.name, index: "can._plugin", height: height, display: value.display, msg: msg}, function(sub) { + delete(sub._legend.onclick) + }, target) + } + }} + }, + plug: function(can, value) { + var height = can.onexport.plugHeight(can, value), width = can.onexport.plugWidth(can, value) + return {view: wiki.CONTENT, style: {height: height+2, width: width}, _init: function(target) { value.type = chat.STORY can.onappend.plugin(can, value, function(sub) { sub.onexport.output = function() { sub.onimport.size(sub, height, width) - can.page.style(can, target, html.HEIGHT, sub._target.offsetHeight, html.WIDTH, sub._target.offsetWidth) + can.page.style(can, target, html.HEIGHT, sub._target.offsetHeight+2, html.WIDTH, sub._target.offsetWidth) } }, target) }}