From 7355064173ed9e93a04eaf0e567acfd5679b1b00 Mon Sep 17 00:00:00 2001 From: bergyu Date: Wed, 29 Dec 2021 17:23:10 +0800 Subject: [PATCH] opt chrome --- base/mdb/mdb.go | 1 + go.sum | 2 ++ misc/chrome/change.go | 44 ++++++++++++++++++++++++++++++++++++++++++ misc/chrome/chrome.shy | 1 + misc/chrome/spide.go | 5 ++++- 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 misc/chrome/change.go diff --git a/base/mdb/mdb.go b/base/mdb/mdb.go index 4f99a10b..5e85f4ee 100644 --- a/base/mdb/mdb.go +++ b/base/mdb/mdb.go @@ -8,6 +8,7 @@ import ( ) func _file_name(m *ice.Message, arg ...string) string { + return path.Join(ice.USR_LOCAL_EXPORT, m.Option(ice.MSG_DOMAIN), path.Join(arg[:2]...), arg[2]) return kit.Select(path.Join(ice.USR_LOCAL_EXPORT, m.Option(ice.MSG_DOMAIN), path.Join(arg[:2]...), arg[2]), arg, 3) } func _domain_chain(m *ice.Message, chain string) string { diff --git a/go.sum b/go.sum index 02e7f1a1..88f75a3c 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,6 @@ +shylinux.com/x/go-qrcode v0.0.1 h1:/eOGqMj1qtgs9Ymd12zTUa1gcJZs9S92kj2lb0QzKsE= shylinux.com/x/go-qrcode v0.0.1/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po= shylinux.com/x/toolkits v0.4.3 h1:eDCYnfsU5JCRU3qG9e3n15K+37TNCtje8/tyfRWauV4= shylinux.com/x/toolkits v0.4.3/go.mod h1:8LbYHe7oxBIqb6s4MSOD+4d28QvPdvkyCVtwB/JW7AA= +shylinux.com/x/websocket v0.0.1 h1:OBc21DxqsGlQ2+Pz76xqLyDNo1LV+PUUqfWi+1PZPDE= shylinux.com/x/websocket v0.0.1/go.mod h1:AaSpMToOxbMULKQytzczeHPuqb708vK1vrAzCxLo/XE= diff --git a/misc/chrome/change.go b/misc/chrome/change.go new file mode 100644 index 00000000..9632bbce --- /dev/null +++ b/misc/chrome/change.go @@ -0,0 +1,44 @@ +package chrome + +import ( + ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/mdb" + "shylinux.com/x/icebergs/base/web" + kit "shylinux.com/x/toolkits" +) + +const ( + SELECTOR = "selector" + PROPERTY = "property" +) +const CHANGE = "change" + +func init() { + Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + CHANGE: {Name: "change", Help: "编辑", Value: kit.Data(kit.MDB_SHORT, PROPERTY)}, + }, Commands: map[string]*ice.Command{ + CHANGE: {Name: "change wid tid selector:text@key property:textarea@key auto export import", Help: "编辑", Action: ice.MergeAction(map[string]*ice.Action{ + mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { + switch arg[0] { + case SELECTOR: + m.Push(arg[0], "video") + default: + m.Cmdy(mdb.INPUTS, m.PrefixKey(), "", mdb.HASH, arg) + } + }}, + }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + if len(arg) < 2 || arg[2] == "" { + m.Cmdy(web.SPACE, CHROME, CHROME, kit.Slice(arg, 0, 2)) + return + } + if len(arg) > 3 { + m.Cmd(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, SELECTOR, arg[2], PROPERTY, arg[3]) + } + + msg := m.Cmd(web.SPACE, CHROME, CHROME, kit.Slice(arg, 0, 2), CHANGE, kit.Slice(arg, 2)) + msg.Table(func(index int, value map[string]string, head []string) { + m.Push(kit.MDB_TEXT, kit.ReplaceAll(value[kit.MDB_TEXT], "<", "<", ">", ">")) + }) + }}, + }}) +} diff --git a/misc/chrome/chrome.shy b/misc/chrome/chrome.shy index e8ed2ebc..0b05dbb6 100644 --- a/misc/chrome/chrome.shy +++ b/misc/chrome/chrome.shy @@ -15,6 +15,7 @@ field "收藏夹" web.code.chrome.favor field "样式表" web.code.chrome.style field "工具箱" web.code.chrome.field field "蜘蛛侠" web.code.chrome.spide +field "编辑器" web.code.chrome.change field "缓存池" web.code.chrome.cache field "相册簿" web.wiki.feel diff --git a/misc/chrome/spide.go b/misc/chrome/spide.go index af66f350..cbebde81 100644 --- a/misc/chrome/spide.go +++ b/misc/chrome/spide.go @@ -11,11 +11,14 @@ const SPIDE = "spide" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - SPIDE: {Name: "spide wid tid cmd auto", Help: "网页爬虫", Action: map[string]*ice.Action{ + SPIDE: {Name: "spide wid tid cmd auto modify", Help: "网页爬虫", Action: map[string]*ice.Action{ web.DOWNLOAD: {Name: "download", Help: "下载", Hand: func(m *ice.Message, arg ...string) { m.Cmd(CACHE, mdb.CREATE, arg) m.ProcessHold() }}, + mdb.MODIFY: {Name: "modify selector property:textarea", Help: "编辑", Hand: func(m *ice.Message, arg ...string) { + m.Cmd(web.SPACE, CHROME, CHROME, m.Option("wid"), m.Option("tid"), mdb.MODIFY, m.Option("selector"), m.Option("property")) + }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { switch msg := m.Cmd(web.SPACE, CHROME, CHROME, arg); kit.Select(SPIDE, arg, 2) { case SPIDE: