diff --git a/base/web/cache.go b/base/web/cache.go index 9edc780f..a5836fc5 100644 --- a/base/web/cache.go +++ b/base/web/cache.go @@ -31,6 +31,14 @@ func _cache_save(m *ice.Message, kind, name, text string, arg ...string) { // fi text = kit.Select(file, text) h := mdb.HashCreate(m, kit.SimpleKV("", kind, name, text), nfs.FILE, file, nfs.SIZE, size) + if kind == "application/octet-stream" { + if kit.ExtIsImage(name) { + kind = "image/"+kit.Ext(name) + } else if kit.ExtIsVideo(name) { + kind = "video/"+kit.Ext(name) + } + } + // 返回结果 m.Push(mdb.TIME, m.Time()) m.Push(mdb.TYPE, kind) diff --git a/core/chat/chat.shy b/core/chat/chat.shy index 9c3eaccd..fc8a360a 100644 --- a/core/chat/chat.shy +++ b/core/chat/chat.shy @@ -14,13 +14,12 @@ sso.go favor.go iframe.go -media.go +keyboard.go div.go topic.go website.go template.go -keyboard.go location.go location.shy trans.go diff --git a/core/chat/favor.go b/core/chat/favor.go index 3606cc94..0d8874ee 100644 --- a/core/chat/favor.go +++ b/core/chat/favor.go @@ -9,10 +9,21 @@ import ( "shylinux.com/x/icebergs/base/gdb" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/ssh" + "shylinux.com/x/icebergs/base/tcp" "shylinux.com/x/icebergs/base/web" kit "shylinux.com/x/toolkits" ) +func _favor_is_image(m *ice.Message, name, mime string) bool { + return strings.HasPrefix(mime, "image/") || kit.ExtIsImage(name) +} +func _favor_is_video(m *ice.Message, name, mime string) bool { + return strings.HasPrefix(mime, "video/") || kit.ExtIsVideo(name) +} +func _favor_is_audio(m *ice.Message, name, mime string) bool { + return strings.HasPrefix(mime, "audio/") +} + const ( FAVOR_INPUTS = "favor.inputs" FAVOR_TABLES = "favor.tables" @@ -22,7 +33,7 @@ const FAVOR = "favor" func init() { Index.MergeCommands(ice.Commands{ - FAVOR: {Name: "favor hash auto create getClipboardData getLocation scanQRCode upload", Help: "收藏夹", Actions: ice.MergeActions(ice.Actions{ + FAVOR: {Name: "favor hash auto create getClipboardData getLocation scanQRCode record1 record2 upload", Help: "收藏夹", Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { switch mdb.HashInputs(m, arg); arg[0] { case mdb.TYPE: @@ -31,6 +42,7 @@ func init() { switch m.Option(mdb.TYPE) { case ctx.INDEX: m.Copy(m.Cmd(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND, arg[1:], ice.OptionFields(ctx.INDEX)).RenameAppend(ctx.INDEX, arg[0])) + return } } gdb.Event(m, "", arg) @@ -38,6 +50,8 @@ func init() { "getClipboardData": {Name: "favor create", Help: "粘贴"}, "getLocation": {Name: "favor create", Help: "定位"}, "scanQRCode": {Name: "favor create", Help: "扫码"}, + "record1": {Name: "favor upload", Help: "截图"}, + "record2": {Name: "favor upload", Help: "录屏"}, mdb.CREATE: {Hand: func(m *ice.Message, arg ...string) { m.OptionDefault(mdb.TYPE, mdb.LINK, mdb.NAME, kit.ParseURL(m.Option(mdb.TEXT)).Host) mdb.HashCreate(m, m.OptionSimple()) @@ -49,7 +63,14 @@ func init() { ctx.ProcessOpen(m, web.MergeURL2(m, web.SHARE_LOCAL+m.Option(mdb.TEXT), "filename", m.Option(mdb.NAME))) }}, web.DISPLAY: {Help: "预览", Hand: func(m *ice.Message, arg ...string) { - m.EchoImages(web.SHARE_LOCAL + m.Option(mdb.TEXT)).ProcessInner() + if link := web.SHARE_LOCAL+m.Option(mdb.TEXT); _favor_is_image(m, m.Option(mdb.NAME), m.Option(mdb.TYPE)) { + m.EchoImages(link) + } else if _favor_is_video(m, m.Option(mdb.NAME), m.Option(mdb.TYPE)) { + m.EchoVideos(link) + } else { + m.Echo("