forked from x/icebergs
opt wx.ide
This commit is contained in:
parent
a7cc74c80b
commit
3c63abbbe2
@ -7,3 +7,5 @@ const LEX = "lex"
|
||||
var Index = &ice.Context{Name: LEX, Help: "词法模块"}
|
||||
|
||||
func init() { ice.Index.Register(Index, nil, SPLIT) }
|
||||
|
||||
// func init() { ice.Index.Register(Index, nil) }
|
||||
|
@ -98,6 +98,8 @@ const (
|
||||
SOURCE = "_source"
|
||||
TARGET = "_target"
|
||||
IMPORTANT = "important"
|
||||
EXPIRED = "expired"
|
||||
VALID = "valid"
|
||||
)
|
||||
const (
|
||||
INPUTS = "inputs"
|
||||
|
@ -33,7 +33,7 @@ func _cache_save(m *ice.Message, mime, name, text string, arg ...string) {
|
||||
if m.Warn(name == "", ice.ErrNotValid, mdb.NAME) {
|
||||
return
|
||||
} else if len(text) > 512 {
|
||||
p := m.Cmdx(nfs.SAVE, _cache_name(m, kit.Hashs(text)), text)
|
||||
p := m.Cmdx(nfs.SAVE, _cache_name(m, kit.Hashs(text)), kit.Dict(nfs.CONTENT, text))
|
||||
text, arg = p, kit.Simple(p, len(text))
|
||||
}
|
||||
file, size := kit.Select("", arg, 0), kit.Int(kit.Select(kit.Format(len(text)), arg, 1))
|
||||
|
@ -30,6 +30,8 @@ const (
|
||||
LAYOUT = "layout"
|
||||
RESIZE = "resize"
|
||||
FILTER = "filter"
|
||||
HEIGHT = "height"
|
||||
WIDTH = "width"
|
||||
|
||||
COLOR = "color"
|
||||
BACKGROUND_COLOR = "background-color"
|
||||
|
@ -62,6 +62,7 @@ func _space_fork(m *ice.Message) {
|
||||
}
|
||||
}
|
||||
args := kit.Simple(mdb.TYPE, kit.Select(WORKER, m.Option(mdb.TYPE)), mdb.NAME, name, mdb.TEXT, text, m.OptionSimple(nfs.MODULE, nfs.VERSION, cli.DAEMON))
|
||||
args = append(args, aaa.USERNICK, m.Option(ice.MSG_USERNICK), aaa.USERNAME, m.Option(ice.MSG_USERNAME))
|
||||
args = append(args, aaa.UA, m.Option(ice.MSG_USERUA), aaa.IP, m.Option(ice.MSG_USERIP))
|
||||
if c, e := websocket.Upgrade(m.W, m.R); !m.Warn(e) {
|
||||
gdb.Go(m, func() {
|
||||
@ -216,7 +217,7 @@ func init() {
|
||||
return false
|
||||
}
|
||||
Index.MergeCommands(ice.Commands{
|
||||
SPACE: {Help: "空间站", Actions: ice.MergeActions(ice.Actions{
|
||||
SPACE: {Name: "space name cmds auto", Help: "空间站", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, SPACE, ice.MAIN) }},
|
||||
ice.MAIN: {Name: "main index", Help: "首页", Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 0 {
|
||||
@ -266,7 +267,7 @@ func init() {
|
||||
}
|
||||
}},
|
||||
nfs.PS: {Hand: func(m *ice.Message, arg ...string) { _space_fork(m) }},
|
||||
}, mdb.HashAction(mdb.LIMIT, 1000, mdb.LEAST, 500, mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text,module,version", ctx.ACTION, OPEN, REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000)), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, mdb.HashAction(mdb.LIMIT, 1000, mdb.LEAST, 500, mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text,usernick,username,ip,module,version", ctx.ACTION, OPEN, REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000)), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) < 2 {
|
||||
defer m.StatusTimeCount(kit.Dict(ice.MAIN, mdb.Config(m, ice.MAIN)))
|
||||
m.Option(ice.MSG_USERWEB, tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB)))
|
||||
@ -275,7 +276,6 @@ func init() {
|
||||
if m.Push("", value, kit.Split(mdb.Config(m, mdb.FIELD))); len(arg) > 0 && arg[0] != "" {
|
||||
m.Push(mdb.STATUS, value[mdb.STATUS])
|
||||
m.Push(aaa.UA, value[aaa.UA])
|
||||
m.Push(aaa.IP, value[aaa.IP])
|
||||
}
|
||||
if kit.IsIn(value[mdb.TYPE], WORKER, SERVER) {
|
||||
m.Push(mdb.LINK, m.MergePod(value[mdb.NAME]))
|
||||
|
@ -63,10 +63,12 @@ func _spide_show(m *ice.Message, name string, arg ...string) {
|
||||
defer res.Body.Close()
|
||||
m.Cost(cli.STATUS, res.Status, nfs.SIZE, kit.FmtSize(kit.Int64(res.Header.Get(ContentLength))), mdb.TYPE, res.Header.Get(ContentType))
|
||||
m.Push(mdb.TYPE, STATUS).Push(mdb.NAME, res.StatusCode).Push(mdb.VALUE, res.Status)
|
||||
m.Options(STATUS, res.Status)
|
||||
kit.For(res.Header, func(k string, v []string) {
|
||||
if m.Option(log.DEBUG) == ice.TRUE {
|
||||
m.Logs(RESPONSE, k, v)
|
||||
}
|
||||
m.Options(k, v)
|
||||
m.Push(mdb.TYPE, SPIDE_HEADER).Push(mdb.NAME, k).Push(mdb.VALUE, v[0])
|
||||
})
|
||||
mdb.HashSelectUpdate(m, name, func(value ice.Map) {
|
||||
@ -239,6 +241,7 @@ const (
|
||||
ApplicationOctet = "application/octet-stream"
|
||||
ApplicationJSON = "application/json"
|
||||
|
||||
IMAGE_JPEG = "image/jpeg"
|
||||
IMAGE_PNG = "image/png"
|
||||
TEXT_HTML = "text/html"
|
||||
TEXT_CSS = "text/css"
|
||||
|
@ -22,6 +22,7 @@ const (
|
||||
TOKEN_CREDENTIAL = "token?grant_type=client_credential"
|
||||
TICKET_GETTICKET = "ticket/getticket?type=jsapi"
|
||||
QRCODE_CREATE = "qrcode/create"
|
||||
WXACODE_UNLIMIT = "/wxa/getwxacodeunlimit"
|
||||
MENU_CREATE = "menu/create"
|
||||
USER_REMARK = "user/info/updateremark"
|
||||
USER_INFO = "user/info"
|
||||
@ -99,6 +100,9 @@ func init() {
|
||||
}},
|
||||
})
|
||||
}
|
||||
func spidePost(m *ice.Message, api string, arg ...ice.Any) *ice.Message {
|
||||
return m.Cmd(web.SPIDE, WX, web.SPIDE_RAW, http.MethodPost, kit.MergeURL(api, oauth.ACCESS_TOKEN, m.Cmdx(ACCESS, TOKENS)), arg)
|
||||
}
|
||||
func SpidePost(m *ice.Message, api string, arg ...ice.Any) ice.Any {
|
||||
return kit.UnMarshal(m.Cmdx(web.SPIDE, WX, web.SPIDE_RAW, http.MethodPost, kit.MergeURL(api, oauth.ACCESS_TOKEN, m.Cmdx(ACCESS, TOKENS)), arg))
|
||||
}
|
||||
@ -114,5 +118,6 @@ func Meta() ice.Map {
|
||||
SEX, "性别", TAGS, "标签", REMARK, "备注",
|
||||
"subscribe", "订阅", "subscribe_time", "时间",
|
||||
"nickname", "昵称", "headimgurl", "头像",
|
||||
ENV, "环境", PAGES, "页面",
|
||||
)))
|
||||
}
|
||||
|
@ -9,12 +9,12 @@ 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"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/misc/lex"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -25,7 +25,7 @@ func _ide_args(m *ice.Message) (args []string) {
|
||||
}
|
||||
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("=", "&", kit.Simple(kit.Dict(web.SERVE, url.QueryEscape(web.UserHost(m)), _ide_args(m)))...),
|
||||
"pathName", m.Option(PAGES), "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 {
|
||||
@ -34,16 +34,24 @@ func _ide_args_qrcode(m *ice.Message, p string) []string {
|
||||
|
||||
const (
|
||||
PROJECT = "project"
|
||||
PAGES = "pages"
|
||||
ENV = "env"
|
||||
)
|
||||
const IDE = "ide"
|
||||
|
||||
func init() {
|
||||
const (
|
||||
PREVIEW = "preview"
|
||||
AUTO_PREVIEW = "auto-preview"
|
||||
PREVIEW = "preview"
|
||||
PUSH = "push"
|
||||
DOC = "doc"
|
||||
|
||||
APP_JSON = "app.json"
|
||||
CURRENT = "current"
|
||||
ISLOGIN = "islogin"
|
||||
)
|
||||
Index.MergeCommands(ice.Commands{
|
||||
IDE: {Name: "ide hash auto", Help: "集成开发环境", Actions: ice.MergeActions(ice.Actions{
|
||||
IDE: {Name: "ide hash auto", Help: "集成开发环境", Meta: Meta(), Actions: ice.MergeActions(ice.Actions{
|
||||
ice.APP: {Help: "应用", Hand: func(m *ice.Message, arg ...string) {
|
||||
IdeCli(m, cli.OPEN, "--project", kit.Path(mdb.Config(m, PROJECT)))
|
||||
}},
|
||||
@ -52,34 +60,65 @@ func init() {
|
||||
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()
|
||||
}},
|
||||
cli.MAKE: {Help: "调试", Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(m.Option(mdb.HASH), func(p string) { mdb.Config(m, cli.MAKE, p) })
|
||||
msg := m.Cmd("", kit.Select(mdb.Config(m, cli.MAKE), arg, 0))
|
||||
m.Options(msg.AppendSimple()).Cmd("", AUTO_PREVIEW)
|
||||
web.ADMIN: {Help: "后台", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessOpen("https://mp.weixin.qq.com/")
|
||||
}},
|
||||
DOC: {Help: "文档", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessOpen("https://developers.weixin.qq.com/miniprogram/dev/api/")
|
||||
}},
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch mdb.HashInputs(m, arg); arg[0] {
|
||||
case nfs.PATH:
|
||||
m.Push(arg[0], kit.Value(kit.UnMarshal(m.Cmdx(nfs.CAT, path.Join(mdb.Config(m, PROJECT), "app.json"))), "pages"))
|
||||
case PAGES:
|
||||
m.Push(arg[0], kit.Value(kit.UnMarshal(m.Cmdx(nfs.CAT, path.Join(mdb.Config(m, PROJECT), APP_JSON))), PAGES))
|
||||
case tcp.WIFI:
|
||||
m.Cmdy(tcp.WIFI).Cut(tcp.SSID)
|
||||
case web.WEIXIN:
|
||||
m.Cmd(web.SPACE).Table(func(value ice.Maps) {
|
||||
if value[mdb.TYPE] == web.WEIXIN {
|
||||
m.Push(arg[0], value[mdb.NAME])
|
||||
m.Push(aaa.IP, value[aaa.IP])
|
||||
m.Push(aaa.USERNICK, value[aaa.USERNICK])
|
||||
m.Push(aaa.USERNAME, value[aaa.USERNAME])
|
||||
}
|
||||
})
|
||||
}
|
||||
}},
|
||||
AUTO_PREVIEW: {Help: "预览", Hand: func(m *ice.Message, arg ...string) { IdeCli(m, "", _ide_args_cli(m)).ProcessInner() }},
|
||||
cli.MAKE: {Help: "构建", Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(m.Option(mdb.HASH), func(p string) { mdb.Config(m, CURRENT, p) })
|
||||
msg := m.Cmd("", kit.Select(mdb.Config(m, CURRENT), arg, 0))
|
||||
m.Options(msg.AppendSimple()).Cmd("", AUTO_PREVIEW)
|
||||
}},
|
||||
AUTO_PREVIEW: {Help: "预览", Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(m.Option(mdb.HASH), func(p string) { mdb.Config(m, CURRENT, p) })
|
||||
IdeCli(m, "", _ide_args_cli(m)).ProcessInner()
|
||||
}},
|
||||
PREVIEW: {Help: "体验", Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(m.Option(mdb.HASH), func(p string) { mdb.Config(m, CURRENT, p) })
|
||||
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,space,index,args,wifi", 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 {
|
||||
PUSH: {Name: "push weixin", Help: "推送", Hand: func(m *ice.Message, arg ...string) {
|
||||
defer m.ProcessHold()
|
||||
defer web.ToastProcess(m)()
|
||||
m.Cmd(web.SPACE, m.Option(web.WEIXIN), lex.PARSE, m.Cmdx("", m.Option(mdb.HASH)))
|
||||
}},
|
||||
}, mdb.ExportHashAction(
|
||||
mdb.FIELD, "time,hash,name,pages,space,index,args,wifi",
|
||||
cli.DARWIN, "/Applications/wechatwebdevtools.app/Contents/MacOS/cli",
|
||||
PROJECT, "usr/volcanos/publish/client/mp/",
|
||||
)), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 && tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) && 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, cli.MAKE, mdb.REMOVE).Action(mdb.CREATE, ice.APP); len(arg) > 0 {
|
||||
m.Options(m.AppendSimple(web.SPACE, ctx.INDEX, ctx.ARGS, tcp.WIFI))
|
||||
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)
|
||||
return
|
||||
}
|
||||
m.StatusTimeCount(kit.Dict(mdb.ConfigSimple(m, cli.MAKE)))
|
||||
if mdb.HashSelect(m, arg...).PushAction(AUTO_PREVIEW, PREVIEW, PUSH, mdb.REMOVE).Action(mdb.CREATE, ice.APP, aaa.LOGIN, web.ADMIN, DOC); len(arg) > 0 {
|
||||
m.Options(m.AppendSimple(web.SPACE, ctx.INDEX, ctx.ARGS, tcp.WIFI))
|
||||
p := kit.MergeURL2(web.UserHost(m), path.Join(nfs.PS+m.Append(PAGES)), _ide_args(m))
|
||||
m.PushQRCode(cli.QRCODE, p).Push(web.LINK, p).Echo(p)
|
||||
}
|
||||
p := mdb.Config(m, CURRENT)
|
||||
m.Table(func(value ice.Maps) { m.Push(mdb.STATUS, kit.Select("", CURRENT, value[mdb.HASH] == p)) })
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -96,8 +96,9 @@ func init() {
|
||||
m.OptionSimple(aaa.CITY, aaa.COUNTRY, aaa.LANGUAGE, aaa.PROVINCE),
|
||||
)
|
||||
}},
|
||||
SCENE: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(IDE, m.Option(SCENE)) }},
|
||||
SCAN: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(web.CHAT_FAVOR, mdb.CREATE, mdb.TYPE, "", arg) }},
|
||||
}, aaa.WhiteAction(aaa.SESS, aaa.USER)), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, aaa.WhiteAction(aaa.SESS, aaa.USER, SCENE)), Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Cmdx(ACCESS, aaa.CHECK) == "" {
|
||||
return
|
||||
} else if m.Option("echostr") != "" {
|
||||
|
@ -1,12 +1,15 @@
|
||||
package wx
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"net/http"
|
||||
"path"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/base/web/html"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -18,26 +21,62 @@ const (
|
||||
const SCAN = "scan"
|
||||
|
||||
func init() {
|
||||
const (
|
||||
UNLIMIT = "unlimit"
|
||||
IS_HYALINE = "is_hyaline"
|
||||
QR_STR_SCENE = "QR_STR_SCENE"
|
||||
QR_LIMIT_STR_SCENE = "QR_LIMIT_STR_SCENE"
|
||||
)
|
||||
Index.MergeCommands(ice.Commands{
|
||||
SCAN: {Name: "scan access hash auto", Help: "桌牌", Meta: kit.Merge(Meta(), kit.Dict(ice.CTX_TRANS, kit.Dict(html.VALUE, kit.Dict(
|
||||
"QR_LIMIT_STR_SCENE", "永久码", "QR_STR_SCENE", "临时码", "valid", "有效", "expired", "失效",
|
||||
QR_LIMIT_STR_SCENE, "永久码", QR_STR_SCENE, "临时码", mdb.VALID, "有效", mdb.EXPIRED, "失效",
|
||||
"develop", "开发版", "trial", "体验版", "release", "发布版",
|
||||
)))), Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.CREATE: {Name: "create type=QR_STR_SCENE,QR_LIMIT_STR_SCENE name*=1 text icons expire_seconds=3600 space index* args", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case SCENE:
|
||||
m.Cmdy(IDE).Cut(mdb.HASH, mdb.NAME, PAGES, ctx.INDEX).RenameAppend(mdb.HASH, arg[0])
|
||||
}
|
||||
}},
|
||||
mdb.CREATE: {Name: "create type*=QR_STR_SCENE,QR_LIMIT_STR_SCENE name*=1 text icons expire_seconds=3600 space index* args", Hand: func(m *ice.Message, arg ...string) {
|
||||
h := mdb.HashCreate(m.Spawn(), arg)
|
||||
res := SpidePost(m, QRCODE_CREATE, "action_name", m.Option(mdb.TYPE), "action_info.scene.scene_str", h, m.OptionSimple(EXPIRE_SECONDS))
|
||||
mdb.HashModify(m, mdb.HASH, h, mdb.LINK, kit.Value(res, web.URL), mdb.TIME, m.Time(kit.Format("%ss", kit.Select("60", m.Option(EXPIRE_SECONDS)))))
|
||||
m.EchoQRCode(kit.Format(kit.Value(res, web.URL)))
|
||||
}},
|
||||
"unlimit": {Name: "unlimit path scene", Help: "小程序码", Hand: func(m *ice.Message, arg ...string) {
|
||||
msg := m.Cmd(web.SPIDE, WX, web.SPIDE_RAW, http.MethodPost, "/wxa/getwxacodeunlimit?access_token="+m.Cmdx(ACCESS, TOKENS), m.OptionSimple("path,scene"))
|
||||
m.Echo(kit.Format(`<img src="data:image/png;base64,%s" title='%s'>`, base64.StdEncoding.EncodeToString([]byte(msg.Result())), "some")).ProcessInner()
|
||||
UNLIMIT: {Name: "unlimit scene* env*=develop,release,trial,develop is_hyaline=true,false", Help: "小程序码", Hand: func(m *ice.Message, arg ...string) {
|
||||
defer m.ProcessInner()
|
||||
scene := m.Option(SCENE)
|
||||
meta, info := "", m.Cmd(IDE, scene)
|
||||
if u := web.UserWeb(m); u.Scheme == ice.HTTP {
|
||||
if info.Append(tcp.WIFI) != "" {
|
||||
wifi := m.Cmd(tcp.WIFI, info.Append(tcp.WIFI))
|
||||
ls := kit.Split(tcp.PublishLocalhost(m, u.Hostname()), nfs.PT)
|
||||
meta = path.Join("w", kit.Format("%x%x", kit.Int(ls[2]), kit.Int(ls[3])), scene, wifi.Append(tcp.SSID), wifi.Append(aaa.PASSWORD))
|
||||
} else {
|
||||
meta = path.Join("h", tcp.PublishLocalhost(m, u.Host), scene)
|
||||
}
|
||||
} else {
|
||||
meta = path.Join("s", u.Host, scene)
|
||||
}
|
||||
msg := spidePost(m, WXACODE_UNLIMIT, web.SPIDE_DATA, kit.Format(kit.Dict(
|
||||
"env_version", m.Option(ENV), "page", info.Append(PAGES), SCENE, meta, IS_HYALINE, m.Option(IS_HYALINE) == ice.TRUE, html.WIDTH, 370,
|
||||
)))
|
||||
switch kit.Select("", kit.Split(msg.Option(web.ContentType), "; "), 0) {
|
||||
case web.IMAGE_JPEG:
|
||||
image := m.Cmd(web.CACHE, web.WRITE, mdb.TYPE, web.IMAGE_JPEG, mdb.NAME, scene, kit.Dict(mdb.TEXT, msg.Result())).Append(mdb.HASH)
|
||||
mdb.HashSelects(m, mdb.HashCreate(m.Spawn(), mdb.TEXT, meta, nfs.IMAGE, image, ctx.INDEX, m.Prefix(IDE), ctx.ARGS, scene, mdb.TYPE, m.Option(ENV)))
|
||||
default:
|
||||
m.Echo(msg.Result())
|
||||
}
|
||||
}},
|
||||
}, mdb.ExportHashAction(mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,name,text,icons,space,index,args,type,link")), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, mdb.ExportHashAction(mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,name,text,icons,space,index,args,type,image,link")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.Cmdy(ACCESS).PushAction("").Option(ice.MSG_ACTION, "")
|
||||
} else if mdb.HashSelect(m, arg[1:]...); len(arg) == 1 {
|
||||
m.Table(func(value ice.Maps) { m.Push(mdb.STATUS, kit.Select("valid", "expired", value[mdb.TIME] < m.Time())) })
|
||||
m.Action("unlimit")
|
||||
m.Table(func(value ice.Maps) {
|
||||
m.Push(mdb.STATUS, kit.Select(mdb.VALID, mdb.EXPIRED, value[mdb.TYPE] == QR_STR_SCENE && value[mdb.TIME] < m.Time()))
|
||||
}).Action(mdb.CREATE, UNLIMIT)
|
||||
} else {
|
||||
kit.If(m.Time() < m.Append(mdb.TIME), func() { m.PushQRCode(cli.QRCODE, m.Append(mdb.LINK)) })
|
||||
}
|
||||
|
@ -170,8 +170,9 @@ func (m *Message) PushButton(arg ...Any) *Message {
|
||||
func (m *Message) PushAnchor(arg ...string) {
|
||||
kit.If(!m.IsCliUA(), func() { m.Push(LINK, Render(m, RENDER_ANCHOR, arg)) })
|
||||
}
|
||||
func (m *Message) PushQRCode(key, src string) {
|
||||
func (m *Message) PushQRCode(key, src string) *Message {
|
||||
kit.If(!m.IsCliUA(), func() { m.Push(key, Render(m, RENDER_QRCODE, src)) })
|
||||
return m
|
||||
}
|
||||
func (m *Message) PushImages(key, src string, arg ...string) {
|
||||
kit.If(!m.IsCliUA(), func() { m.Push(key, Render(m, RENDER_IMAGES, src, arg)) })
|
||||
|
3
type.go
3
type.go
@ -88,7 +88,8 @@ func (c *Context) ID() int32 { return atomic.AddInt32(&c.id, 1) }
|
||||
func (c *Context) Register(s *Context, x Server, cmd ...string) *Context {
|
||||
kit.For(cmd, func(cmd string) {
|
||||
if s, ok := Info.Index[cmd].(*Context); ok {
|
||||
panic(kit.Format("%s %s registed by %v", ErrWarn, cmd, s.Name))
|
||||
println(kit.Format("%s %s registed by %v", ErrWarn, cmd, s.Name))
|
||||
// panic(kit.Format("%s %s registed by %v", ErrWarn, cmd, s.Name))
|
||||
}
|
||||
Info.Index[cmd] = s
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user