forked from x/icebergs
add wifi
This commit is contained in:
parent
1d88096d83
commit
593c5a3313
@ -211,8 +211,11 @@ func Pipe(m *ice.Message, cb ice.Any) io.WriteCloser {
|
||||
return w
|
||||
}
|
||||
|
||||
func TempName(m *ice.Message) string {
|
||||
return m.Cmdx(SAVE, path.Join(ice.VAR_TMP, kit.Hashs(mdb.UNIQ)), "")
|
||||
}
|
||||
func Temp(m *ice.Message, cb func(p string)) {
|
||||
p := path.Join(ice.VAR_TMP, kit.Hashs(mdb.UNIQ))
|
||||
p := TempName(m)
|
||||
defer os.Remove(p)
|
||||
cb(p)
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response
|
||||
m.Cost(kit.Format("%s: %s %v", r.Method, r.URL.String(), m.FormatSize()))
|
||||
}()
|
||||
m.Option(ice.MSG_OPTS, kit.Simple(m.Optionv(ice.MSG_OPTION), func(k string) bool { return !strings.HasPrefix(k, ice.MSG_SESSID) }))
|
||||
if m.Detailv(m.PrefixKey(), cmds); len(cmds) > 1 && cmds[0] == ctx.ACTION {
|
||||
if m.Detailv(m.PrefixKey(), cmds); len(cmds) > 1 && cmds[0] == ctx.ACTION && cmds[1] != ctx.ACTION {
|
||||
if !kit.IsIn(cmds[1], aaa.LOGIN, ctx.RUN, ctx.COMMAND) && m.Warn(r.Method == http.MethodGet, ice.ErrNotAllow) {
|
||||
return
|
||||
}
|
||||
|
@ -162,6 +162,7 @@ func _space_send(m *ice.Message, name string, arg ...string) (h string) {
|
||||
}
|
||||
|
||||
const (
|
||||
WEIXIN = "weixin"
|
||||
PORTAL = "portal"
|
||||
WORKER = "worker"
|
||||
SERVER = "server"
|
||||
@ -278,14 +279,14 @@ func init() {
|
||||
}
|
||||
if kit.IsIn(value[mdb.TYPE], WORKER, SERVER) {
|
||||
m.Push(mdb.LINK, m.MergePod(value[mdb.NAME]))
|
||||
} else if value[mdb.TYPE] == PORTAL && value[mdb.NAME] != html.CHROME {
|
||||
} else if kit.IsIn(value[mdb.TYPE], PORTAL, WEIXIN) && value[mdb.NAME] != html.CHROME {
|
||||
m.Push(mdb.LINK, MergeURL2(m, value[mdb.TEXT]))
|
||||
} else {
|
||||
m.Push(mdb.LINK, "")
|
||||
}
|
||||
m.PushButton(kit.Select(OPEN, LOGIN, value[mdb.TYPE] == LOGIN), mdb.REMOVE)
|
||||
})
|
||||
// kit.If(len(arg) == 1, func() { m.EchoIFrame(m.MergePod(arg[0])) }, func() { m.Action(ice.MAIN) })
|
||||
m.Sort("type,name,text")
|
||||
} else {
|
||||
_space_send(m, arg[0], kit.Simple(kit.Split(arg[1]), arg[2:])...)
|
||||
}
|
||||
|
@ -65,5 +65,8 @@ func StatsAction() ice.Actions {
|
||||
}, gdb.EventsAction(STATS_TABLES))
|
||||
}
|
||||
func PushStats(m *ice.Message, name string, value ice.Any, units string) {
|
||||
kit.If(value != 0, func() { m.Push(mdb.NAME, name).Push(mdb.VALUE, value).Push(mdb.UNITS, units) })
|
||||
kit.If(value != 0, func() {
|
||||
m.Push(mdb.NAME, name).Push(mdb.VALUE, value).Push(mdb.UNITS, units)
|
||||
m.Push(ctx.INDEX, m.PrefixKey())
|
||||
})
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/log"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
@ -17,12 +18,16 @@ import (
|
||||
)
|
||||
|
||||
func _ide_args(m *ice.Message) []string {
|
||||
return append(kit.Split(m.Option(ctx.ARGS), "=&"), kit.Simple(kit.Dict(m.OptionSimple(web.SPACE, ctx.INDEX, log.DEBUG)))...)
|
||||
}
|
||||
func _ide_args_cli(m *ice.Message) []string {
|
||||
return []string{"--project", kit.Path(mdb.Config(m, PROJECT)), "--compile-condition", kit.Format(kit.Dict(
|
||||
"pathName", m.Option(nfs.PATH), "query", kit.JoinKV("=", "&", append(kit.Split(m.Option(ctx.ARGS), "=&"), kit.Simple(kit.Dict(
|
||||
web.SERVE, url.QueryEscape(web.UserHost(m)), m.OptionSimple(web.SPACE, ctx.INDEX, log.DEBUG),
|
||||
))...)...),
|
||||
"pathName", m.Option(nfs.PATH), "query", kit.JoinKV("=", "&", kit.Simple(kit.Dict(web.SERVE, url.QueryEscape(web.UserHost(m)), _ide_args(m)))...),
|
||||
))}
|
||||
}
|
||||
func _ide_args_qrcode(m *ice.Message, p string) []string {
|
||||
return []string{"--qr-format", nfs.IMAGE, "--qr-output", kit.Path(p)}
|
||||
}
|
||||
|
||||
const (
|
||||
PROJECT = "project"
|
||||
@ -33,31 +38,31 @@ func init() {
|
||||
const (
|
||||
PREVIEW = "preview"
|
||||
AUTO_PREVIEW = "auto-preview"
|
||||
CMDS_PREVIEW = "cmds-preview"
|
||||
)
|
||||
Index.MergeCommands(ice.Commands{
|
||||
IDE: {Name: "ide hash auto app login", Help: "集成开发环境", Actions: ice.MergeActions(ice.Actions{
|
||||
IDE: {Name: "ide hash auto", Help: "集成开发环境", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.APP: {Help: "应用", Hand: func(m *ice.Message, arg ...string) {
|
||||
IdeCli(m, "open", "--project", kit.Path(mdb.Config(m, PROJECT)))
|
||||
IdeCli(m, cli.OPEN, "--project", kit.Path(mdb.Config(m, PROJECT)))
|
||||
}},
|
||||
aaa.LOGIN: {Help: "登录", Hand: func(m *ice.Message, arg ...string) {
|
||||
p := m.Cmdx(nfs.SAVE, path.Join(ice.VAR_TMP, kit.Hashs(mdb.UNIQ)), "")
|
||||
m.Go(func() { IdeCli(m, "", "--qr-format", nfs.IMAGE, "--qr-output", kit.Path(p), _ide_args(m)) }).Sleep("1s")
|
||||
m.EchoImages(web.SHARE_LOCAL + p).ProcessInner()
|
||||
}},
|
||||
CMDS_PREVIEW: {Name: "cmds-preview space index*=web.dream args='debug=true'", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd("", AUTO_PREVIEW)
|
||||
}},
|
||||
AUTO_PREVIEW: {Help: "自动", Hand: func(m *ice.Message, arg ...string) {
|
||||
IdeCli(m, "", _ide_args(m)).ProcessInner()
|
||||
p := nfs.TempName(m)
|
||||
m.Go(func() { web.PushNoticeGrow(m.Sleep("1s"), ice.Render(m, ice.RENDER_IMAGES, web.SHARE_LOCAL+p)) })
|
||||
IdeCli(m, "", _ide_args_cli(m), _ide_args_qrcode(m, p)).ProcessRefresh()
|
||||
}},
|
||||
AUTO_PREVIEW: {Help: "自动", Hand: func(m *ice.Message, arg ...string) { IdeCli(m, "", _ide_args_cli(m)).ProcessInner() }},
|
||||
PREVIEW: {Help: "预览", Hand: func(m *ice.Message, arg ...string) {
|
||||
p := m.Cmdx(nfs.SAVE, path.Join(ice.VAR_TMP, kit.Hashs(mdb.UNIQ)), "")
|
||||
IdeCli(m, "", "--qr-format", nfs.IMAGE, "--qr-output", kit.Path(p), _ide_args(m))
|
||||
p := nfs.TempName(m)
|
||||
IdeCli(m, "", _ide_args_cli(m), _ide_args_qrcode(m, p))
|
||||
m.EchoImages(web.SHARE_LOCAL + p).ProcessInner()
|
||||
}},
|
||||
}, mdb.ExportHashAction(mdb.FIELD, "time,hash,name,path,args", cli.DARWIN, "/Applications/wechatwebdevtools.app/Contents/MacOS/cli", PROJECT, "usr/volcanos/publish/client/mp/")), Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.HashSelect(m, arg...).PushAction(CMDS_PREVIEW, AUTO_PREVIEW, PREVIEW, mdb.REMOVE)
|
||||
}, mdb.ExportHashAction(mdb.FIELD, "time,hash,name,path,space,index,args", cli.DARWIN, "/Applications/wechatwebdevtools.app/Contents/MacOS/cli", PROJECT, "usr/volcanos/publish/client/mp/")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if kit.Value(kit.UnMarshal(IdeCli(m.Spawn(), "islogin").Append(cli.CMD_OUT)), aaa.LOGIN) != true {
|
||||
m.EchoInfoButton("请登录: ", aaa.LOGIN)
|
||||
} else if mdb.HashSelect(m, arg...).PushAction(AUTO_PREVIEW, PREVIEW, mdb.REMOVE).Action(mdb.CREATE, ice.APP); len(arg) > 0 {
|
||||
m.Options(m.AppendSimple(web.SPACE, ctx.INDEX, ctx.ARGS))
|
||||
p := kit.MergeURL2(web.UserHost(m), path.Join(nfs.PS+m.Append(nfs.PATH)), _ide_args(m))
|
||||
m.EchoQRCode(p).Echo(lex.NL).EchoAnchor(p)
|
||||
}
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -74,9 +74,11 @@ func init() {
|
||||
const (
|
||||
AUTH_CODE = "/sns/jscode2session?grant_type=authorization_code"
|
||||
)
|
||||
web.Index.MergeCommands(ice.Commands{
|
||||
"/MP_verify_0xp0zkW3fIzIq2Bo.txt": {Actions: aaa.WhiteAction(), Hand: func(m *ice.Message, arg ...string) { m.RenderResult("0xp0zkW3fIzIq2Bo") }},
|
||||
})
|
||||
if false {
|
||||
web.Index.MergeCommands(ice.Commands{
|
||||
"/MP_verify_0xp0zkW3fIzIq2Bo.txt": {Actions: aaa.WhiteAction(), Hand: func(m *ice.Message, arg ...string) { m.RenderResult("0xp0zkW3fIzIq2Bo") }},
|
||||
})
|
||||
}
|
||||
Index.MergeCommands(ice.Commands{
|
||||
web.PP(LOGIN): {Actions: ice.MergeActions(ice.Actions{
|
||||
aaa.SESS: {Name: "sess code", Help: "会话", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
24
misc/wx/pages.go
Normal file
24
misc/wx/pages.go
Normal file
@ -0,0 +1,24 @@
|
||||
package wx
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/core/chat"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func init() {
|
||||
web.Index.MergeCommands(ice.Commands{
|
||||
"/pages/": {Actions: aaa.WhiteAction(ctx.ACTION), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg[0]) == 0 || arg[0] == "" || arg[0] == chat.RIVER {
|
||||
web.RenderMain(m)
|
||||
} else {
|
||||
if m.IsWeixinUA() {
|
||||
}
|
||||
web.RenderCmd(m, kit.Select(m.Option(ctx.INDEX), m.Option(ice.CMD)))
|
||||
}
|
||||
}},
|
||||
})
|
||||
}
|
@ -203,6 +203,9 @@ func (m *Message) EchoFields(cmd string, arg ...string) *Message {
|
||||
</fieldset>
|
||||
`, cmd, kit.Join(arg))
|
||||
}
|
||||
func (m *Message) EchoInfoButton(info string, arg ...Any) *Message {
|
||||
return m.Echo(info).EchoButton(arg...).Echo(NL).Action(arg...)
|
||||
}
|
||||
func (m *Message) EchoButton(arg ...Any) *Message { return m.Echo(Render(m, RENDER_BUTTON, arg...)) }
|
||||
func (m *Message) EchoAnchor(arg ...string) *Message { return m.Echo(Render(m, RENDER_ANCHOR, arg)) }
|
||||
func (m *Message) EchoQRCode(src string) *Message { return m.Echo(Render(m, RENDER_QRCODE, src)) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user