1
0
forked from x/icebergs

opt chrome

This commit is contained in:
bergyu 2021-11-08 18:58:14 +08:00
parent 272255aecc
commit 564c5a4f68
25 changed files with 71 additions and 59 deletions

View File

@ -68,7 +68,6 @@ func init() {
mdb.CREATE: {Name: "create username", Help: "创建"},
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
mdb.HashSelect(m, arg...)
m.PushAction(mdb.REMOVE)
}},
}})
}

View File

@ -84,7 +84,6 @@ func init() {
m.Echo(_totp_get(value[SECRET], kit.Int(value[NUMBER]), kit.Int64(value[PERIOD])))
}
})
m.PushAction(mdb.REMOVE)
}},
}})
}

View File

@ -132,7 +132,6 @@ func init() {
mdb.HashSelect(m, arg...).Table(func(index int, value map[string]string, head []string) {
m.Push(USERROLE, UserRole(m, value[USERNAME]))
})
m.PushAction(mdb.REMOVE)
}},
}})
}

View File

@ -190,6 +190,8 @@ func HashActionStatus(fields ...string) map[string]*ice.Action {
func HashSelect(m *ice.Message, arg ...string) *ice.Message {
m.Fields(len(arg), m.Config(kit.MDB_FIELD))
m.Cmdy(SELECT, m.PrefixKey(), "", HASH, m.Config(kit.MDB_SHORT), arg)
m.PushAction(REMOVE)
m.StatusTimeCount()
return m
}
func HashPrunes(m *ice.Message, cb func(map[string]string) bool) *ice.Message {

View File

@ -92,7 +92,8 @@ func _cache_download(m *ice.Message, r *http.Response) (file, size string) {
f.Write(buf[0:n])
s := size * 100 / total
switch cb := m.Optionv(kit.Keycb(DOWNLOAD)).(type) {
m.Debug("what %v", kit.FileLine(m.OptionCB(SPIDE), 3))
switch cb := m.OptionCB(SPIDE).(type) {
case func(int, int):
cb(size, total)
case []string:

View File

@ -145,10 +145,14 @@ func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.Respon
r.ParseMultipartForm(kit.Int64(kit.Select("4096", r.Header.Get(ContentLength))))
if r.ParseForm(); len(r.PostForm) > 0 {
for k, v := range r.PostForm {
if len(v) > 1 {
msg.Logs("form", k, len(v), v)
} else {
msg.Logs("form", k, v)
}
}
}
}
// 请求参数
for k, v := range r.Form {

View File

@ -346,7 +346,6 @@ func init() {
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) < 2 || arg[0] == "" || (len(arg) > 3 && arg[3] == "") {
mdb.HashSelect(m, kit.Slice(arg, 0, 1)...)
m.PushAction(mdb.REMOVE)
return
}
_spide_list(m, arg...)

View File

@ -32,7 +32,6 @@ func init() {
m.PushImages(kit.MDB_IMAGE, link)
}
})
m.PushAction(mdb.REMOVE)
}},
}})
}

View File

@ -26,7 +26,6 @@ func init() {
m.PushScript(ssh.SCRIPT, m.Append(kit.MDB_TEXT))
m.PushQRCode(cli.QRCODE, m.Append(kit.MDB_TEXT))
}
m.PushAction(mdb.REMOVE)
}},
}})
}

View File

@ -27,7 +27,6 @@ func init() {
m.PushScript(ssh.SCRIPT, m.Append(kit.MDB_TEXT))
m.PushQRCode(cli.QRCODE, m.Append(kit.MDB_TEXT))
}
m.PushAction(mdb.REMOVE)
}},
}})
}

View File

@ -35,7 +35,7 @@ func _install_download(m *ice.Message) {
value = kit.GetMeta(value)
p := 0
m.Optionv(kit.Keycb(web.DOWNLOAD), func(size int, total int) {
m.OptionCB(web.SPIDE, func(size int, total int) {
if n := size * 100 / total; p != n {
value[kit.MDB_STEP], value[kit.MDB_SIZE], value[kit.MDB_TOTAL] = n, size, total
toast(name, size, total)

View File

@ -390,7 +390,7 @@ func (m *Message) Appendv(key string, arg ...interface{}) []string {
return m.meta[key]
}
if m.FieldsIsDetail() {
if m.FieldsIsDetail() && key != kit.MDB_KEY {
for i, k := range m.meta[kit.MDB_KEY] {
if k == key {
if len(arg) > 0 {

12
misc.go
View File

@ -87,6 +87,12 @@ func (m *Message) FieldsIsDetail() bool {
}
return false
}
func (m *Message) OptionCB(key string, cb ...interface{}) interface{} {
if len(cb) > 0 {
return m.Optionv(kit.Keycb(key), cb)
}
return m.Optionv(kit.Keycb(key))
}
func (m *Message) OptionUserWeb() *url.URL {
return kit.ParseURL(m.Option(MSG_USERWEB))
}
@ -101,8 +107,12 @@ func (m *Message) RenameAppend(from, to string) {
}
func (m *Message) AppendSimple(key ...string) (res []string) {
if len(key) == 0 {
if m.FieldsIsDetail() {
key = append(key, m.Appendv(kit.MDB_KEY)...)
} else {
key = append(key, m.Appendv(MSG_APPEND)...)
}
}
for _, k := range key {
res = append(res, k, m.Append(k))
}
@ -164,7 +174,7 @@ func (m *Message) cmd(arg ...interface{}) *Message {
ok := false
run := func(msg *Message, ctx *Context, cmd *Command, key string, arg ...string) {
if ok = true; cbs != nil {
msg.Option(kit.Keycb(list[0]), cbs)
msg.Option(kit.Keycb(kit.Slice(kit.Split(list[0], PT), -1)[0]), cbs)
}
for k, v := range opts {
msg.Option(k, v)

View File

@ -25,8 +25,13 @@ func _alpha_find(m *ice.Message, method, word string) {
}
// 搜索词汇
msg := m.Cmd(cli.SYSTEM, "grep", "-rh", word, m.Config(kit.MDB_STORE))
msg := m.Cmd(cli.SYSTEM, "grep", "-rih", word, m.Config(kit.MDB_STORE))
msg.CSV(msg.Result(), kit.Split(m.Config(kit.MDB_FIELD))...).Table(func(index int, value map[string]string, head []string) {
if m.FieldsIsDetail() {
m.Push(mdb.DETAIL, value, kit.Split(m.Config(kit.MDB_FIELD)))
m.Push(kit.MDB_TIME, m.Time())
return
}
m.PushSearch(ice.CMD, ALPHA, kit.MDB_TYPE, method, kit.MDB_NAME, value[WORD], kit.MDB_TEXT, value["translation"], value)
})
}
@ -79,10 +84,13 @@ var Index = &ice.Context{Name: ALPHA, Help: "英汉词典", Configs: map[string]
m.Copy(msg)
return
}
}
m.OptionFields(mdb.DETAIL)
} else {
m.OptionFields(m.Config(kit.MDB_FIELD))
}
if _alpha_find(m, arg[0], arg[1]); arg[0] == WORD && m.Length() > 0 {
m.Cmd(CACHE, mdb.CREATE, m.AppendSimple())
m.Sort(kit.MDB_KEY)
}
}},
}}

View File

@ -70,8 +70,6 @@ func init() {
}},
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
mdb.HashSelect(m, arg...)
m.PushAction(mdb.REMOVE)
m.StatusTimeCount()
}},
}})
}

View File

@ -13,42 +13,33 @@ import (
const CACHE = "cache"
func init() {
Index.Merge(&ice.Context{
Configs: map[string]*ice.Config{
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
CACHE: {Name: CACHE, Help: "爬虫缓存", Value: kit.Data(
kit.MDB_SHORT, kit.MDB_LINK, kit.MDB_FIELD, "time,hash,step,size,total,type,name,text,link",
kit.MDB_PATH, ice.USR_LOCAL_IMAGE,
)},
},
Commands: map[string]*ice.Command{
CACHE: {Name: "cache hash auto create prunes", Help: "爬虫缓存", Action: map[string]*ice.Action{
}, Commands: map[string]*ice.Command{
CACHE: {Name: "cache hash auto prunes", Help: "爬虫缓存", Action: ice.MergeAction(map[string]*ice.Action{
mdb.CREATE: {Name: "create", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
if m.Cmdy(mdb.SELECT, m.Prefix(CACHE), "", mdb.HASH, m.OptionSimple(kit.MDB_LINK)); len(m.Appendv(kit.MDB_TOTAL)) > 0 {
if m.Cmdy(mdb.SELECT, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(kit.MDB_LINK)); m.Length() > 0 {
return // 已经下载
}
h := m.Cmdx(mdb.INSERT, m.Prefix(CACHE), "", mdb.HASH, m.OptionSimple("type,name,text,link"))
value := kit.GetMeta(m.Confm(CACHE, kit.Keys(kit.MDB_HASH, h)))
m.Option(kit.Keycb(web.DOWNLOAD), func(size, total int) {
h := m.Cmdx(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, m.OptionSimple("type,name,text,link"))
value := kit.GetMeta(m.Confm(m.PrefixKey(), kit.Keys(kit.MDB_HASH, h)))
msg := m.Cmd("web.spide", ice.DEV, web.SPIDE_CACHE, web.SPIDE_GET, m.Option(kit.MDB_LINK), func(size, total int) {
value[kit.MDB_TOTAL], value[kit.MDB_SIZE], value[kit.MDB_STEP] = total, size, kit.Format(size*100/total)
})
msg := m.Cmd("web.spide", ice.DEV, web.SPIDE_CACHE, web.SPIDE_GET, m.Option(kit.MDB_LINK))
p := path.Join(m.Conf(CACHE, kit.META_PATH), m.Option(kit.MDB_NAME))
p := path.Join(m.Config(kit.MDB_PATH), m.Option(kit.MDB_NAME))
m.Cmdy(nfs.LINK, p, msg.Append(kit.MDB_FILE))
m.Toast("下载成功")
}},
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(mdb.DELETE, m.Prefix(CACHE), "", mdb.HASH, kit.MDB_HASH, m.Option(kit.MDB_HASH))
}},
mdb.PRUNES: {Name: "prunes", Help: "清理", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(mdb.PRUNES, m.Prefix(CACHE), "", mdb.HASH, kit.MDB_STEP, "100")
m.Cmdy(mdb.PRUNES, m.PrefixKey(), "", mdb.HASH, kit.MDB_STEP, "100")
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Fields(len(arg), m.Conf(CACHE, kit.META_FIELD))
m.Cmdy(mdb.SELECT, m.Prefix(CACHE), "", mdb.HASH, kit.MDB_HASH, arg)
m.PushAction(mdb.REMOVE)
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
mdb.HashSelect(m, arg...)
}},
},
})
}})
}

View File

@ -13,12 +13,13 @@ func init() {
Page: {Name: "page", Help: "网页", Value: kit.Data()},
}, Commands: map[string]*ice.Command{
"/page": {Name: "/page", Help: "网页", Action: map[string]*ice.Action{
FIELD: {Name: "field", Help: "工具"},
ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(STYLE, ctx.ACTION, ctx.COMMAND, arg)
m.Cmdy(FIELD, ctx.ACTION, ctx.COMMAND, arg)
}},
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(FIELD, ice.RUN, arg)
m.Cmdy(FIELD, ctx.ACTION, ice.RUN, arg)
}},
}},
}})

View File

@ -14,6 +14,7 @@ func init() {
SPIDE: {Name: "spide wid tid cmd auto", 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()
}},
}, 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) {

View File

@ -22,6 +22,8 @@ func init() {
switch arg[0] {
case kit.MDB_ZONE:
m.Cmdy(CHROME, mdb.INPUTS)
default:
m.Cmdy(mdb.INPUTS, m.PrefixKey(), "", mdb.ZONE, m.Option(m.Config(kit.MDB_SHORT)), arg)
}
}},
mdb.INSERT: {Name: "insert zone=golang.google.cn target=. style:textarea", Help: "添加"},

View File

@ -99,7 +99,9 @@ func init() {
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) == 0 { // 通道列表
m.Action(mdb.PRUNES)
mdb.HashSelect(m, arg...).Table(func(index int, value map[string]string, head []string) {
mdb.HashSelect(m, arg...)
m.Set(ice.MSG_APPEND, ctx.ACTION)
m.Table(func(index int, value map[string]string, head []string) {
m.PushButton(kit.Select("", ctx.COMMAND, value[kit.MDB_STATUS] == tcp.OPEN), mdb.REMOVE)
})
return

View File

@ -84,7 +84,9 @@ func init() {
}, mdb.HashActionStatus()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) == 0 {
m.Action(mdb.PRUNES)
mdb.HashSelect(m, arg...).Table(func(index int, value map[string]string, head []string) {
mdb.HashSelect(m, arg...)
m.Set(ice.MSG_APPEND, ctx.ACTION)
m.Table(func(index int, value map[string]string, head []string) {
m.PushButton(kit.Select("", ctx.COMMAND, value[kit.MDB_STATUS] == tcp.OPEN), mdb.REMOVE)
})
return

View File

@ -18,7 +18,6 @@ func init() {
mdb.CREATE: {Name: "create type=shell,tmux,vim name=hi text:textarea=pwd", Help: "添加"},
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
mdb.HashSelect(m, arg...)
m.PushAction(mdb.REMOVE)
}},
}})
}

View File

@ -70,8 +70,6 @@ func init() {
}},
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
mdb.HashSelect(m, arg...)
m.PushAction(mdb.REMOVE)
m.StatusTimeCount()
}},
}})
}

View File

@ -21,7 +21,6 @@ func init() {
mdb.HashSelect(m, arg...).Table(func(index int, value map[string]string, head []string) {
m.PushQRCode(kit.MDB_SCAN, kit.MergeURL("https://open.weixin.qq.com/qr/code", aaa.USERNAME, value[kit.MDB_TEXT]))
})
m.PushAction(mdb.REMOVE)
}},
}})
}

View File

@ -140,6 +140,7 @@ func (m *Message) PushDownload(key string, arg ...interface{}) { // [name] file
}
func (m *Message) PushAction(list ...interface{}) {
m.Set(MSG_APPEND, "action")
m.Table(func(index int, value map[string]string, head []string) {
m.PushButton(list...)
})