1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-28 18:22:02 +08:00
This commit is contained in:
harveyshao 2022-11-02 15:17:32 +08:00
parent 56576f958f
commit e7721f1c6c
8 changed files with 34 additions and 33 deletions

View File

@ -137,7 +137,7 @@ func _hash_export(m *ice.Message, prefix, chain, file string) {
m.Logs(EXPORT, KEY, path.Join(prefix, chain), FILE, p) m.Logs(EXPORT, KEY, path.Join(prefix, chain), FILE, p)
m.Conf(prefix, kit.Keys(chain, HASH), "") m.Conf(prefix, kit.Keys(chain, HASH), "")
m.Echo(p) m.Echo(p).StatusTime(LINK, "/share/local/"+p)
} }
func _hash_import(m *ice.Message, prefix, chain, file string) { func _hash_import(m *ice.Message, prefix, chain, file string) {
defer Lock(m, prefix, chain)() defer Lock(m, prefix, chain)()

View File

@ -96,7 +96,7 @@ func _zone_export(m *ice.Message, prefix, chain, file string) {
m.Logs(EXPORT, KEY, path.Join(prefix, chain), FILE, p, COUNT, count) m.Logs(EXPORT, KEY, path.Join(prefix, chain), FILE, p, COUNT, count)
m.Conf(prefix, kit.Keys(chain, HASH), "") m.Conf(prefix, kit.Keys(chain, HASH), "")
m.Echo(p) m.Echo(p).StatusTime(LINK, "/share/local/"+p)
} }
func _zone_import(m *ice.Message, prefix, chain, file string) { func _zone_import(m *ice.Message, prefix, chain, file string) {
f, e := miss.OpenFile(kit.Keys(file, CSV)) f, e := miss.OpenFile(kit.Keys(file, CSV))
@ -226,11 +226,9 @@ func ZoneSelect(m *ice.Message, arg ...string) *ice.Message {
return m return m
} }
func ZoneExport(m *ice.Message, arg ...Any) { func ZoneExport(m *ice.Message, arg ...Any) {
m.Debug("what %v", m.OptionFields())
if m.OptionFields() == "" { if m.OptionFields() == "" {
m.OptionFields(m.Config(SHORT), m.Config(FIELD)) m.OptionFields(m.Config(SHORT), m.Config(FIELD))
} }
m.Debug("what %v", m.OptionFields())
m.Cmdy(EXPORT, m.PrefixKey(), "", ZONE, arg) m.Cmdy(EXPORT, m.PrefixKey(), "", ZONE, arg)
} }
func ZoneImport(m *ice.Message, arg ...Any) { func ZoneImport(m *ice.Message, arg ...Any) {

View File

@ -254,7 +254,6 @@ func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.Respon
if sessid := msg.Option(CookieName(msg.Option(ice.MSG_USERWEB))); msg.Option(ice.MSG_SESSID) == "" { if sessid := msg.Option(CookieName(msg.Option(ice.MSG_USERWEB))); msg.Option(ice.MSG_SESSID) == "" {
msg.Option(ice.MSG_SESSID, sessid) msg.Option(ice.MSG_SESSID, sessid)
} }
msg.Debug("what %v", msg.FormatMeta())
// 解析命令 // 解析命令
if msg.Optionv(ice.MSG_CMDS) == nil { if msg.Optionv(ice.MSG_CMDS) == nil {

View File

@ -85,7 +85,7 @@ func init() {
m.Push(nfs.PATH, "_open:"+strings.ToLower(value[mdb.NAME])) m.Push(nfs.PATH, "_open:"+strings.ToLower(value[mdb.NAME]))
}) })
case nfs.PATH: case nfs.PATH:
m.Cmdy(nfs.DIR, arg[1:]) m.Cmdy(nfs.DIR, arg[1:]).Cut("path,size,time")
m.ProcessAgain() m.ProcessAgain()
default: default:
} }
@ -95,8 +95,8 @@ func init() {
if m.Option(nfs.CONTENT) == "" { if m.Option(nfs.CONTENT) == "" {
m.Option(nfs.CONTENT, m.Cmdx("", TEMPLATE)) m.Option(nfs.CONTENT, m.Cmdx("", TEMPLATE))
} }
m.Cmdy(nfs.SAVE, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE))) switch m.Cmdy(nfs.SAVE, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE))); m.Option(nfs.FILE) {
if m.Option(nfs.FILE) == "proto.js" { case "proto.js", "page/index.css":
m.Cmd("", DEVPACK) m.Cmd("", DEVPACK)
} }
}}, }},

View File

@ -15,7 +15,7 @@ const EPIC = "epic"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
EPIC: {Name: "epic hash list", Help: "史记", Actions: ice.MergeActions(ice.Actions{ EPIC: {Name: "epic hash list", Help: "史记", Actions: ice.MergeActions(ice.Actions{
mdb.CREATE: {Name: "create time@date zone name"}, mdb.MODIFY: {Name: "modify time@date zone name"}, mdb.CREATE: {Name: "create time zone name"}, mdb.MODIFY: {Name: "modify time zone name"},
}, mdb.HashAction(mdb.FIELD, "time,hash,zone,name")), Hand: func(m *ice.Message, arg ...string) { }, mdb.HashAction(mdb.FIELD, "time,hash,zone,name")), Hand: func(m *ice.Message, arg ...string) {
if mdb.HashSelect(m, arg...).Tables(func(value ice.Maps) { if mdb.HashSelect(m, arg...).Tables(func(value ice.Maps) {
if span := kit.Time(m.Time()) - kit.Time(value[mdb.TIME]); span > 0 { if span := kit.Time(m.Time()) - kit.Time(value[mdb.TIME]); span > 0 {

View File

@ -4,22 +4,15 @@ import (
"time" "time"
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/web" "shylinux.com/x/icebergs/base/web"
"shylinux.com/x/icebergs/base/aaa"
kit "shylinux.com/x/toolkits" kit "shylinux.com/x/toolkits"
) )
func _plan_scope(m *ice.Message, tz int, arg ...string) (begin_time, end_time time.Time) { func _plan_scope(m *ice.Message, arg ...string) (begin_time, end_time time.Time) {
if begin_time = time.Now(); len(arg) > 1 { switch begin_time = kit.DayBegin(kit.Select(m.Time(), arg, 1)); kit.Select(WEEK, arg, 0) {
begin_time, _ = time.ParseInLocation(ice.MOD_TIME, arg[1], time.Local)
}
begin_time = begin_time.Add(time.Duration(tz) * time.Hour)
begin_time = begin_time.Add(-time.Duration(begin_time.UnixNano()) % (24 * time.Hour))
begin_time = begin_time.Add(-time.Duration(tz) * time.Hour)
switch end_time = begin_time; kit.Select(WEEK, arg, 0) {
case DAY: case DAY:
end_time = begin_time.AddDate(0, 0, 1) end_time = begin_time.AddDate(0, 0, 1)
case WEEK: case WEEK:
@ -32,17 +25,17 @@ func _plan_scope(m *ice.Message, tz int, arg ...string) (begin_time, end_time ti
begin_time = begin_time.AddDate(0, 0, -begin_time.YearDay()+1) begin_time = begin_time.AddDate(0, 0, -begin_time.YearDay()+1)
end_time = begin_time.AddDate(1, 0, 0) end_time = begin_time.AddDate(1, 0, 0)
case LONG: case LONG:
begin_time = begin_time.AddDate(0, 0, -begin_time.YearDay()+1) begin_time = begin_time.AddDate(0, 0, -begin_time.YearDay()+1).AddDate(-5, 0, 0)
begin_time = begin_time.AddDate(-30, 0, 0) end_time = begin_time.AddDate(10, 0, 0)
end_time = begin_time.AddDate(60, 0, 0)
} }
m.Logs(mdb.SELECT, "begin_time", begin_time.Format(ice.MOD_TIME), "end_time", end_time.Format(ice.MOD_TIME))
return begin_time, end_time return begin_time, end_time
} }
func _plan_list(m *ice.Message, begin_time, end_time time.Time) { func _plan_list(m *ice.Message, begin_time, end_time string) {
m.Option(mdb.CACHE_LIMIT, "-1") m.Option(mdb.CACHE_LIMIT, "-1")
m.OptionFields("begin_time,close_time,zone,id,level,status,score,type,name,text,pod,extra") m.OptionFields("begin_time,close_time,zone,id,level,status,score,type,name,text,pod,extra")
m.Cmd(mdb.SELECT, m.Prefix(TASK), "", mdb.ZONE, mdb.FOREACH, func(key string, fields []string, value, val ice.Map) { m.Cmd(mdb.SELECT, m.Prefix(TASK), "", mdb.ZONE, mdb.FOREACH, func(key string, fields []string, value, val ice.Map) {
if begin, _ := time.ParseInLocation(ice.MOD_TIME, kit.Format(value[BEGIN_TIME]), time.Local); begin.After(begin_time) && end_time.After(begin) { if begin_time <= kit.Format(value[BEGIN_TIME]) && kit.Format(value[BEGIN_TIME]) < end_time {
m.Push(key, value, fields, val).PushButton(_task_action(m, value[STATUS], mdb.PLUGIN)) m.Push(key, value, fields, val).PushButton(_task_action(m, value[STATUS], mdb.PLUGIN))
} }
}) })
@ -55,6 +48,9 @@ const (
YEAR = "year" YEAR = "year"
LONG = "long" LONG = "long"
) )
const (
TASK_POD = "task.pod"
)
const PLAN = "plan" const PLAN = "plan"
@ -62,10 +58,9 @@ func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
PLAN: {Name: "plan scale=week,day,week,month,year,long begin_time@date list", Help: "计划", Actions: ice.MergeActions(ice.Actions{ PLAN: {Name: "plan scale=week,day,week,month,year,long begin_time@date list", Help: "计划", Actions: ice.MergeActions(ice.Actions{
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TODO, mdb.INPUTS, arg) }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TODO, mdb.INPUTS, arg) }},
mdb.PLUGIN: {Name: "plugin extra.index extra.args", Help: "插件", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.MODIFY, arg) }}, mdb.PLUGIN: {Name: "plugin extra.index extra.args", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.MODIFY, arg) }},
ice.RUN: {Hand: func(m *ice.Message, arg ...string) { ice.RUN: {Hand: func(m *ice.Message, arg ...string) {
m.Option(ice.POD, m.Option("task.pod")) if m.RenameOption(TASK_POD, ice.POD); ctx.PodCmd(m, m.PrefixKey(), ice.RUN, arg) {
if m.Option("task.pod", ""); ctx.PodCmd(m, m.PrefixKey(), ice.RUN, arg) {
return return
} }
if cmd := m.CmdAppend(TASK, kit.Slice(arg, 0, 2), ctx.INDEX); cmd != "" { if cmd := m.CmdAppend(TASK, kit.Slice(arg, 0, 2), ctx.INDEX); cmd != "" {
@ -75,8 +70,8 @@ func init() {
} }
}}, }},
}, TASK, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { }, TASK, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
begin_time, end_time := _plan_scope(m, 8, kit.Slice(arg, 0, 2)...) begin_time, end_time := _plan_scope(m, kit.Slice(arg, 0, 2)...)
_plan_list(m, begin_time, end_time) _plan_list(m, begin_time.Format(ice.MOD_TIME), end_time.Format(ice.MOD_TIME))
web.PushPodCmd(m, "", arg...) web.PushPodCmd(m, "", arg...)
ctx.Toolkit(m, TODO, TASK, EPIC) ctx.Toolkit(m, TODO, TASK, EPIC)
ctx.DisplayLocal(m, "") ctx.DisplayLocal(m, "")

View File

@ -74,9 +74,9 @@ func init() {
mdb.ZoneInsert(m, arg[:2], BEGIN_TIME, m.Time(), STATUS, PREPARE, LEVEL, 3, SCORE, 3, arg[2:]) mdb.ZoneInsert(m, arg[:2], BEGIN_TIME, m.Time(), STATUS, PREPARE, LEVEL, 3, SCORE, 3, arg[2:])
}}, }},
mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) { _task_modify(m, arg[0], arg[1], arg[2:]...) }}, mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) { _task_modify(m, arg[0], arg[1], arg[2:]...) }},
CANCEL: {Name: "cancal", Help: "取消", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, CANCEL) }}, CANCEL: {Name: "cancal", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, CANCEL) }},
BEGIN: {Name: "begin", Help: "开始", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, PROCESS) }}, BEGIN: {Name: "begin", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, PROCESS) }},
END: {Name: "end", Help: "完成", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, FINISH) }}, END: {Name: "end", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, FINISH) }},
}, mdb.ZoneAction(mdb.FIELD, "begin_time,close_time,id,status,level,score,type,name,text")), Hand: func(m *ice.Message, arg ...string) { }, mdb.ZoneAction(mdb.FIELD, "begin_time,close_time,id,status,level,score,type,name,text")), Hand: func(m *ice.Message, arg ...string) {
if mdb.ZoneSelect(m, arg...); len(arg) > 0 && arg[0] != "" { if mdb.ZoneSelect(m, arg...); len(arg) > 0 && arg[0] != "" {
status := map[string]int{} status := map[string]int{}

View File

@ -84,6 +84,11 @@ func (m *Message) ToLowerAppend(arg ...string) *Message {
} }
return m return m
} }
func (m *Message) RenameOption(from, to string) *Message {
m.Option(to, m.Option(from))
m.Option(from, "")
return m
}
func (m *Message) RenameAppend(arg ...string) *Message { // [from to]... func (m *Message) RenameAppend(arg ...string) *Message { // [from to]...
for i := 0; i < len(arg)-1; i += 2 { for i := 0; i < len(arg)-1; i += 2 {
if arg[i] == arg[i+1] { if arg[i] == arg[i+1] {
@ -414,6 +419,10 @@ func SplitCmd(name string, actions Actions) (list []Any) {
item = kit.Dict(TYPE, TEXT, NAME, ls[i], ACTION, "img") item = kit.Dict(TYPE, TEXT, NAME, ls[i], ACTION, "img")
list = append(list, item) list = append(list, item)
case "time":
item = kit.Dict(TYPE, TEXT, NAME, ls[i], ACTION, "date")
list = append(list, item)
case "*": case "*":
item["need"] = "must" item["need"] = "must"
case DF: case DF: