mirror of
https://shylinux.com/x/icebergs
synced 2025-04-27 17:58:29 +08:00
add chat.message
This commit is contained in:
parent
ac04d6abd3
commit
5666ec8f1f
@ -272,6 +272,8 @@ func init() {
|
|||||||
switch kit.TrimPrefix(arg[0], "extra.") {
|
switch kit.TrimPrefix(arg[0], "extra.") {
|
||||||
case DREAM:
|
case DREAM:
|
||||||
m.SplitIndex(m.Cmdx(SPIDE, ice.OPS, SPIDE_RAW, http.MethodGet, C(DREAM))).CutTo(mdb.NAME, DREAM)
|
m.SplitIndex(m.Cmdx(SPIDE, ice.OPS, SPIDE_RAW, http.MethodGet, C(DREAM))).CutTo(mdb.NAME, DREAM)
|
||||||
|
case "message":
|
||||||
|
m.Cmdy("web.chat.message").Cut(mdb.HASH, mdb.NAME, mdb.ICONS)
|
||||||
case SPACE:
|
case SPACE:
|
||||||
m.Cmd(SPACE, func(value ice.Maps) {
|
m.Cmd(SPACE, func(value ice.Maps) {
|
||||||
kit.If(kit.IsIn(value[mdb.TYPE], WORKER, SERVER), func() { m.Push(arg[0], value[mdb.NAME]) })
|
kit.If(kit.IsIn(value[mdb.TYPE], WORKER, SERVER), func() { m.Push(arg[0], value[mdb.NAME]) })
|
||||||
|
@ -92,8 +92,12 @@ func init() {
|
|||||||
aaa.SendEmail(m, aaa.ADMIN, m.Option(aaa.TO), "")
|
aaa.SendEmail(m, aaa.ADMIN, m.Option(aaa.TO), "")
|
||||||
}},
|
}},
|
||||||
MESSAGE: {Hand: func(m *ice.Message, arg ...string) {
|
MESSAGE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(MESSAGE, mdb.INSERT, arg)
|
if arg[0] == mdb.INPUTS || arg[0] == mdb.ACTION && arg[1] == mdb.INPUTS {
|
||||||
web.ToastSuccess(m)
|
m.Cmdy(MESSAGE, arg)
|
||||||
|
} else {
|
||||||
|
m.Cmdy(MESSAGE, mdb.INSERT, arg)
|
||||||
|
web.ToastSuccess(m)
|
||||||
|
}
|
||||||
}},
|
}},
|
||||||
aaa.LOGOUT: {Hand: aaa.SessLogout},
|
aaa.LOGOUT: {Hand: aaa.SessLogout},
|
||||||
cli.QRCODE: {Hand: func(m *ice.Message, arg ...string) {
|
cli.QRCODE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
body.light fieldset.web.chat.message>div.output { background-color:white; }
|
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 { 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; }
|
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:10; }
|
||||||
|
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 { height:58px; padding: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 img { height:var(--header-height); width:var(--header-height); display:block; float:left; }
|
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 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 { 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)); 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 { display:flex; justify-content:space-between; }
|
||||||
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.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 { 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:10; }
|
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:10; }
|
||||||
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 i:hover { background-color:var(--hover-bg-color); cursor:pointer; }
|
||||||
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:10; }
|
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.project>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.list>div.item { padding:var(--input-padding); min-height:fit-content; display:flex; }
|
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; }
|
||||||
fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item:hover { background-color:unset; }
|
fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item:hover { background-color:unset; }
|
||||||
fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.time { color:var(--disable-fg-color); font-size:var(--status-font-size); padding:0; height:fit-content; justify-content:center; }
|
fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.time { color:var(--disable-fg-color); font-size:var(--status-font-size); padding:0; height:fit-content; justify-content:center; }
|
||||||
|
@ -33,25 +33,22 @@ func init() {
|
|||||||
mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,type,name,icons", mdb.FIELDS, "time,id,avatar,usernick,username,type,name,text,space,index,args",
|
mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,type,name,icons", mdb.FIELDS, "time,id,avatar,usernick,username,type,name,text,space,index,args",
|
||||||
)), Hand: func(m *ice.Message, arg ...string) {
|
)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
mdb.ZoneSelect(m.Spawn(), arg...).Table(func(value ice.Maps) {
|
mdb.ZoneSelect(m.Display("").Spawn(), arg...).Table(func(value ice.Maps) {
|
||||||
if kit.IsIn(m.Option(ice.MSG_USERROLE), value[mdb.TYPE], aaa.TECH, aaa.ROOT) {
|
if kit.IsIn(m.Option(ice.MSG_USERROLE), value[mdb.TYPE], aaa.TECH, aaa.ROOT) {
|
||||||
m.PushRecord(value, mdb.Config(m, mdb.FIELD))
|
m.PushRecord(value, mdb.Config(m, mdb.FIELD))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
mdb.ZoneSelect(m, arg...)
|
mdb.ZoneSelect(m, arg...).Sort(mdb.ID, ice.INT)
|
||||||
m.Sort(mdb.ID, ice.INT)
|
|
||||||
}
|
}
|
||||||
m.Display("")
|
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func messageCreate(m *ice.Message, name, icon string) {
|
func messageCreate(m *ice.Message, name, icon string) {
|
||||||
kit.Value(m.Target().Configs[m.CommandKey()].Value, kit.Keys(mdb.HASH, name, "meta.time"), m.Time())
|
kit.Value(m.Target().Configs[m.CommandKey()].Value, kit.Keys(mdb.HASH, name, mdb.META), kit.Dict(
|
||||||
kit.Value(m.Target().Configs[m.CommandKey()].Value, kit.Keys(mdb.HASH, name, "meta.type"), aaa.TECH)
|
mdb.TIME, m.Time(), mdb.TYPE, aaa.TECH, mdb.NAME, name, mdb.ICONS, icon,
|
||||||
kit.Value(m.Target().Configs[m.CommandKey()].Value, kit.Keys(mdb.HASH, name, "meta.name"), name)
|
))
|
||||||
kit.Value(m.Target().Configs[m.CommandKey()].Value, kit.Keys(mdb.HASH, name, "meta.icons"), icon)
|
|
||||||
}
|
}
|
||||||
func messageInsert(m *ice.Message, zone string, arg ...string) {
|
func messageInsert(m *ice.Message, zone string, arg ...string) {
|
||||||
m.Cmd("", mdb.INSERT, zone, arg, ice.Maps{ice.MSG_USERNAME: zone})
|
m.Cmd("", mdb.INSERT, zone, arg, ice.Maps{ice.MSG_USERNICK: zone, ice.MSG_USERNAME: zone})
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
Volcanos(chat.ONIMPORT, {
|
Volcanos(chat.ONIMPORT, {
|
||||||
_init: function(can, msg) {
|
_init: function(can, msg) { delete(can._status._cache), delete(can._status._cache_key)
|
||||||
delete(can._status._cache), delete(can._status._cache_key)
|
|
||||||
if (can.isCmdMode()) { can.onappend.style(can, html.OUTPUT) }
|
if (can.isCmdMode()) { can.onappend.style(can, html.OUTPUT) }
|
||||||
can.ui = can.onappend.layout(can), can.onimport._project(can, msg)
|
can.ui = can.onappend.layout(can), can.onimport._project(can, msg)
|
||||||
},
|
},
|
||||||
@ -18,8 +17,11 @@ Volcanos(chat.ONIMPORT, {
|
|||||||
]},
|
]},
|
||||||
], onclick: function(event) { can.isCmdMode() && can.misc.SearchHash(can, value.name), can.onimport._switch(can, false)
|
], onclick: function(event) { can.isCmdMode() && can.misc.SearchHash(can, value.name), 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)
|
can.db.zone = value, can.db.hash = value.hash, can.onmotion.select(can, can.ui.project, html.DIV_ITEM, _target)
|
||||||
if (can.onmotion.cache(can, function() {
|
if (can.onmotion.cache(can, function(save, load) {
|
||||||
return value.name
|
can.ui.message && save({title: can.ui.title, message: can.ui.message, scroll: can.ui.message.scrollTop})
|
||||||
|
return load(value.name, function(bak) { can.ui.title = bak.title, can.ui.message = bak.message
|
||||||
|
can.onmotion.delay(can, function() { can.ui.message.scrollTop = bak.scroll })
|
||||||
|
})
|
||||||
}, can.ui.content, can.ui.profile, can.ui.display, can._status)) { return can.onimport.layout(can) }
|
}, can.ui.content, can.ui.profile, can.ui.display, can._status)) { return can.onimport.layout(can) }
|
||||||
can.run(can.request(event, {"cache.limit": 10}), [value.hash], function(msg) {
|
can.run(can.request(event, {"cache.limit": 10}), [value.hash], function(msg) {
|
||||||
can.onimport._display(can), can.onimport._content(can, msg)
|
can.onimport._display(can), can.onimport._content(can, msg)
|
||||||
@ -43,10 +45,12 @@ Volcanos(chat.ONIMPORT, {
|
|||||||
} }},
|
} }},
|
||||||
]), can.onmotion.toggle(can, can.ui.display, true)
|
]), can.onmotion.toggle(can, can.ui.display, true)
|
||||||
},
|
},
|
||||||
_message: function(can, msg) {
|
_message: function(can, msg) { var now = new Date(), last = ""
|
||||||
var last = ""; msg.Table(function(value) { can.db.zone.id = value.id
|
msg.Table(function(value) { can.db.zone.id = value.id
|
||||||
var myself = value.username == can.user.info.username, time = can.base.TimeTrim(value.time)
|
var myself = value.username == can.user.info.username, time = can.base.TimeTrim(value.time)
|
||||||
if (time != last) { can.page.Append(can, can.ui.message, [{view: [[html.ITEM, mdb.TIME], "", time]}]) } last = time
|
var t = new Date(value.time); if (!last || (t - last > 3*60*1000)) { last = t
|
||||||
|
can.page.Append(can, can.ui.message, [{view: [[html.ITEM, mdb.TIME], "", time]}])
|
||||||
|
}
|
||||||
can.page.Append(can, can.ui.message, [{view: [[html.ITEM, value.type, myself? "myself": ""]], list: [
|
can.page.Append(can, can.ui.message, [{view: [[html.ITEM, value.type, myself? "myself": ""]], list: [
|
||||||
{img: can.misc.Resource(can, (value.avatar == can.db.zone.name? "": value.avatar)||can.db.zone.icons||"usr/icons/Messages.png")},
|
{img: can.misc.Resource(can, (value.avatar == can.db.zone.name? "": value.avatar)||can.db.zone.icons||"usr/icons/Messages.png")},
|
||||||
{view: html.CONTAINER, list: [{text: [value.usernick, "", nfs.FROM]}, can.onfigure[value.type](can, value)]},
|
{view: html.CONTAINER, list: [{text: [value.usernick, "", nfs.FROM]}, can.onfigure[value.type](can, value)]},
|
||||||
@ -100,7 +104,7 @@ Volcanos(chat.ONFIGURE, {
|
|||||||
plug: function(can, value) { var height = can.base.Min(can.ui.content.offsetHeight-210, 240)
|
plug: function(can, value) { var height = can.base.Min(can.ui.content.offsetHeight-210, 240)
|
||||||
var height = can.base.Max(320, height, height/(can.base.isIn(value.index, html.IFRAME)? 1: 2)), width = can.ui.content.offsetWidth-(can.user.isMobile? 60: 180)
|
var height = can.base.Max(320, 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
|
return {view: wiki.CONTENT, style: {height: height, width: width}, _init: function(target) { value.type = chat.STORY
|
||||||
can.onappend._plugin(can, value, {height: height, width: width}, function(sub) {
|
can.onappend.plugin(can, value, function(sub) {
|
||||||
sub.onexport.output = function() { sub.onimport.size(sub, height, width)
|
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, html.WIDTH, sub._target.offsetWidth)
|
||||||
}
|
}
|
||||||
@ -108,3 +112,22 @@ Volcanos(chat.ONFIGURE, {
|
|||||||
}}
|
}}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Volcanos(chat.ONINPUTS, {
|
||||||
|
_show: function(event, can, msg, target, name) {
|
||||||
|
function show(value) {
|
||||||
|
if (target == target.parentNode.firstChild) { can.ui = can.ui||{}
|
||||||
|
can.ui.img = can.page.insertBefore(can, [{type: html.IMG}], target)
|
||||||
|
can.ui.span = can.page.insertBefore(can, [{type: html.SPAN}], target)
|
||||||
|
can.onappend.style(can, mdb.ICONS, can.page.parentNode(can, target, html.TR))
|
||||||
|
can.page.style(can, target, html.COLOR, html.TRANSPARENT)
|
||||||
|
}
|
||||||
|
can.ui.img.src = can.misc.Resource(can, value.icons), can.ui.span.innerText = value.name
|
||||||
|
target.value = value.hash, can.onmotion.hidden(can, can._target)
|
||||||
|
}
|
||||||
|
can.page.Appends(can, can._output, msg.Table(function(value) {
|
||||||
|
return value.name && {view: html.ITEM, list: [
|
||||||
|
{img: can.misc.Resource(can, value.icons)}, {text: value.name},
|
||||||
|
], onclick: function(event) { show(value) }}
|
||||||
|
}))
|
||||||
|
},
|
||||||
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user