1
0
forked from x/icebergs

opt trans

This commit is contained in:
shylinux 2021-11-20 14:13:42 +08:00
parent 3c7a731381
commit ee1a9a432c
7 changed files with 31 additions and 17 deletions

View File

@ -213,6 +213,9 @@ func init() {
TRASH: {Name: "trash", Help: "删除", Hand: func(m *ice.Message, arg ...string) { TRASH: {Name: "trash", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(TRASH, m.Option(kit.MDB_PATH)) m.Cmdy(TRASH, m.Option(kit.MDB_PATH))
}}, }},
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
os.Remove(m.Option(kit.MDB_PATH))
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if m.Option(DIR_ROOT) != "" { if m.Option(DIR_ROOT) != "" {
m.Info("dir_root: %v", m.Option(DIR_ROOT)) m.Info("dir_root: %v", m.Option(DIR_ROOT))

View File

@ -210,6 +210,8 @@ func _serve_login(msg *ice.Message, key string, cmds []string, w http.ResponseWr
if msg.Option(ice.MSG_USERNAME) == "" && msg.Option(SHARE) != "" { if msg.Option(ice.MSG_USERNAME) == "" && msg.Option(SHARE) != "" {
switch share := msg.Cmd(SHARE, msg.Option(SHARE)); share.Append(kit.MDB_TYPE) { switch share := msg.Cmd(SHARE, msg.Option(SHARE)); share.Append(kit.MDB_TYPE) {
case LOGIN: case LOGIN:
msg.Option(ice.MSG_USERNAME, share.Append(aaa.USERNAME))
msg.Option(ice.MSG_USERROLE, share.Append(aaa.USERROLE))
// Render(msg, aaa.SessCreate(msg, share.Append(aaa.USERNAME))) // Render(msg, aaa.SessCreate(msg, share.Append(aaa.USERNAME)))
case FIELD: case FIELD:
msg.Option(ice.MSG_USERNAME, share.Append(aaa.USERNAME)) msg.Option(ice.MSG_USERNAME, share.Append(aaa.USERNAME))

View File

@ -28,7 +28,7 @@ func _share_repos(m *ice.Message, repos string, arg ...string) {
} }
m.RenderDownload(path.Join(prefix, repos, path.Join(arg...))) m.RenderDownload(path.Join(prefix, repos, path.Join(arg...)))
} }
func _share_proxy(m *ice.Message, arg ...string) { func _share_proxy(m *ice.Message) {
switch p := path.Join(ice.VAR_PROXY, m.Option(ice.POD), m.Option(kit.MDB_PATH)); m.R.Method { switch p := path.Join(ice.VAR_PROXY, m.Option(ice.POD), m.Option(kit.MDB_PATH)); m.R.Method {
case http.MethodGet: // 下发文件 case http.MethodGet: // 下发文件
m.RenderDownload(path.Join(p, m.Option(kit.MDB_NAME))) m.RenderDownload(path.Join(p, m.Option(kit.MDB_NAME)))
@ -75,7 +75,7 @@ func _share_local(m *ice.Message, arg ...string) {
} }
// 上传文件 // 上传文件
m.Cmdy(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, kit.MergeURL2(m.Option(ice.MSG_USERWEB), "/share/proxy/"), m.Cmdy(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, kit.MergeURL2(m.Option(ice.MSG_USERWEB), "/share/proxy"),
SPIDE_PART, m.OptionSimple(ice.POD), kit.MDB_PATH, p, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p) SPIDE_PART, m.OptionSimple(ice.POD), kit.MDB_PATH, p, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p)
if s, e := os.Stat(pp); e == nil && !s.IsDir() { if s, e := os.Stat(pp); e == nil && !s.IsDir() {
@ -134,8 +134,10 @@ func init() {
}}, }},
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if m.PodCmd(SHARE, arg) { if m.PodCmd(SHARE, arg) {
if m.Length() > 0 {
return return
} }
}
if mdb.HashSelect(m, arg...); len(arg) > 0 { if mdb.HashSelect(m, arg...); len(arg) > 0 {
link := _share_link(m, "/share/"+arg[0]) link := _share_link(m, "/share/"+arg[0])
m.PushQRCode(cli.QRCODE, link) m.PushQRCode(cli.QRCODE, link)
@ -159,8 +161,8 @@ func init() {
"/share/repos/": {Name: "/share/repos/", Help: "代码库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { "/share/repos/": {Name: "/share/repos/", Help: "代码库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
_share_repos(m, path.Join(arg[0], arg[1], arg[2]), arg[3:]...) _share_repos(m, path.Join(arg[0], arg[1], arg[2]), arg[3:]...)
}}, }},
"/share/proxy/": {Name: "/share/proxy/", Help: "文件流", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { "/share/proxy": {Name: "/share/proxy", Help: "文件流", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
_share_proxy(m, arg...) _share_proxy(m)
}}, }},
"/share/cache/": {Name: "/share/cache/", Help: "缓存池", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { "/share/cache/": {Name: "/share/cache/", Help: "缓存池", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
_share_cache(m, arg...) _share_cache(m, arg...)

View File

@ -41,7 +41,7 @@ func _plan_scope(m *ice.Message, tz int, arg ...string) (time.Time, time.Time) {
} }
func _plan_list(m *ice.Message, begin_time, end_time time.Time) *ice.Message { func _plan_list(m *ice.Message, begin_time, end_time time.Time) *ice.Message {
m.Option(ice.CACHE_LIMIT, "100") m.Option(ice.CACHE_LIMIT, "100")
m.Fields(0, "begin_time,close_time,zone,id,level,status,score,type,name,text,extra") m.Fields(0, "begin_time,close_time,zone,id,level,status,score,type,name,text,pod,extra")
m.Option(kit.Keycb(mdb.SELECT), func(key string, fields []string, value, val map[string]interface{}) { m.Option(kit.Keycb(mdb.SELECT), func(key string, fields []string, value, val map[string]interface{}) {
begin, _ := time.ParseInLocation(ice.MOD_TIME, kit.Format(value[BEGIN_TIME]), time.Local) begin, _ := time.ParseInLocation(ice.MOD_TIME, kit.Format(value[BEGIN_TIME]), time.Local)
if begin_time.After(begin) || begin.After(end_time) { if begin_time.After(begin) || begin.After(end_time) {
@ -86,9 +86,6 @@ func init() {
m.Option(ice.POD, pod) m.Option(ice.POD, pod)
} }
m.Debug(msg.FormatMeta()) m.Debug(msg.FormatMeta())
m.Debug("what %v", kit.KeyExtra(ice.CTX))
m.Debug("what %v", msg.Append(kit.KeyExtra(ice.CTX)))
m.Debug("what %v", msg.Append(kit.KeyExtra(ice.CMD)))
args := kit.Simple(kit.Keys(msg.Append(kit.KeyExtra(ice.CTX)), msg.Append(kit.KeyExtra(ice.CMD))), arg[2:]) args := kit.Simple(kit.Keys(msg.Append(kit.KeyExtra(ice.CTX)), msg.Append(kit.KeyExtra(ice.CMD))), arg[2:])
if !m.PodCmd(args) { if !m.PodCmd(args) {
m.Cmdy(args) m.Cmdy(args)

14
misc.go
View File

@ -78,8 +78,18 @@ func (m *Message) Split(str string, field string, sp string, nl string) *Message
return m return m
} }
func (m *Message) Display(plugin string) *Message { func (m *Message) Display(file string) *Message {
m.Option(MSG_DISPLAY, Display0(2, plugin)["display"]) m.Option(MSG_DISPLAY, Display0(2, file)["display"])
return m
}
func (m *Message) DisplayLocal(file string) *Message {
if file == "" {
file = path.Join(kit.PathName(2), kit.FileName(2)+".js")
}
if !strings.HasPrefix(file, "/") {
file = path.Join("/plugin/local", file)
}
m.Option(MSG_DISPLAY, Display0(2, file)["display"])
return m return m
} }
func (m *Message) FieldsIsDetail() bool { func (m *Message) FieldsIsDetail() bool {

View File

@ -42,7 +42,7 @@ func init() {
home = kit.MergeURL(home, kit.MDB_BACK, back) home = kit.MergeURL(home, kit.MDB_BACK, back)
} }
// 登录页面 // 登录页面
m.RenderRedirect(kit.MergeURL2(m.Conf(APP, kit.Keym(LARK)), "/open-apis/authen/v1/index"), m.RenderRedirect(kit.MergeURL2(m.Cmd(web.SPIDE, LARK).Append("client.url"), "/open-apis/authen/v1/index"),
"redirect_uri", home, APP_ID, m.Cmd(APP).Append(APPID)) "redirect_uri", home, APP_ID, m.Cmd(APP).Append(APPID))
}}, }},
}}) }})

View File

@ -146,11 +146,10 @@ func (m *Message) PushAction(list ...interface{}) {
}) })
} }
func (m *Message) PushPodCmd(cmd string, arg ...string) { func (m *Message) PushPodCmd(cmd string, arg ...string) {
if strings.Contains(m.OptionFields(), POD) {
m.Table(func(index int, value map[string]string, head []string) { m.Table(func(index int, value map[string]string, head []string) {
m.Push(POD, m.Option(MSG_USERPOD)) m.Push(POD, m.Option(MSG_USERPOD))
}) })
} m.Debug(m.FormatMeta())
m.Cmd("space").Table(func(index int, value map[string]string, head []string) { m.Cmd("space").Table(func(index int, value map[string]string, head []string) {
switch value[kit.MDB_TYPE] { switch value[kit.MDB_TYPE] {
@ -162,6 +161,7 @@ func (m *Message) PushPodCmd(cmd string, arg ...string) {
val[POD] = kit.Keys(value[kit.MDB_NAME], val[POD]) val[POD] = kit.Keys(value[kit.MDB_NAME], val[POD])
m.Push("", val, head) m.Push("", val, head)
}) })
m.Debug(m.FormatMeta())
} }
}) })
} }