1
0
forked from x/icebergs

add wifi.go

This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-11-19 00:06:55 +08:00
parent 982250df4f
commit 002995b483
5 changed files with 110 additions and 4 deletions

39
base/tcp/wifi.go Normal file
View File

@ -0,0 +1,39 @@
package tcp
import (
"strings"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/lex"
"shylinux.com/x/icebergs/base/mdb"
kit "shylinux.com/x/toolkits"
)
const WIFI = "wifi"
func init() {
const (
SYSTEM = "cli.system"
NETWORKSETUP = "networksetup"
DISCOVER = "discover"
CONNECT = "connect"
)
Index.MergeCommands(ice.Commands{
WIFI: {Help: "无线", Actions: ice.MergeActions(ice.Actions{
DISCOVER: {Help: "查找", Hand: func(m *ice.Message, arg ...string) {
m.Push(mdb.NAME, strings.Split(m.Cmdx(SYSTEM, NETWORKSETUP, "-listpreferredwirelessnetworks", "en0"), lex.NL)[1:])
m.PushAction(CONNECT)
}},
CONNECT: {Help: "连接", Hand: func(m *ice.Message, arg ...string) {
msg := mdb.HashSelect(m.Spawn(), m.Option(mdb.NAME, strings.TrimSpace(m.Option(mdb.NAME))))
m.Cmd(SYSTEM, NETWORKSETUP, "-setairportnetwork", "en0", kit.Select(m.Option(mdb.NAME), msg.Append(mdb.NAME)), msg.Append(aaa.PASSWORD))
m.ProcessHold()
}},
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,password")), Hand: func(m *ice.Message, arg ...string) {
if mdb.HashSelect(m, arg...).PushAction(CONNECT, mdb.REMOVE).Action(mdb.CREATE, DISCOVER); len(arg) > 0 {
m.EchoQRCode(kit.Format("WIFI:T:WPA;S:%s;P:%s;H:false;;", m.Append(mdb.NAME), m.Append(aaa.PASSWORD)))
}
}},
})
}

View File

@ -17,7 +17,7 @@ const STATS = "stats"
func init() { func init() {
Index.MergeCommands(ice.Commands{ Index.MergeCommands(ice.Commands{
STATS: {Name: "stats refresh", Help: "汇总量", Meta: kit.Dict( STATS: {Help: "汇总量", Meta: kit.Dict(
ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict( ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(
"goods.amount", "商品总额", "goods.amount", "商品总额",
"goods.count", "商品数量", "goods.count", "商品数量",

View File

@ -71,6 +71,7 @@ const (
SUFFIX = lex.SUFFIX SUFFIX = lex.SUFFIX
) )
const ( const (
INCLUDE = "include"
COMMENT = "comment" COMMENT = "comment"
KEYWORD = "keyword" KEYWORD = "keyword"
CONSTANT = "constant" CONSTANT = "constant"
@ -125,8 +126,8 @@ func init() {
}}, }},
}) })
} }
func PlugAction() ice.Actions { func PlugAction(arg ...ice.Any) ice.Actions {
return ice.Actions{ return ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
if cmd := m.Target().Commands[m.CommandKey()]; cmd != nil { if cmd := m.Target().Commands[m.CommandKey()]; cmd != nil {
if cmd.Name == "" { if cmd.Name == "" {
@ -149,7 +150,7 @@ func PlugAction() ice.Actions {
m.Cmdy(nfs.DIR, arg, kit.Dict(nfs.DIR_ROOT, ice.SRC, nfs.DIR_DEEP, ice.TRUE, nfs.DIR_REG, kit.ExtReg(m.CommandKey()))) m.Cmdy(nfs.DIR, arg, kit.Dict(nfs.DIR_ROOT, ice.SRC, nfs.DIR_DEEP, ice.TRUE, nfs.DIR_REG, kit.ExtReg(m.CommandKey())))
} }
}}, }},
} }, ctx.ConfAction(arg...))
} }
func LoadPlug(m *ice.Message, lang ...string) { func LoadPlug(m *ice.Message, lang ...string) {
for _, lang := range lang { for _, lang := range lang {

43
misc/wx/wxml.go Normal file
View File

@ -0,0 +1,43 @@
package wx
import (
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/core/code"
kit "shylinux.com/x/toolkits"
)
func init() {
Index.MergeCommands(ice.Commands{
"wxml": {Actions: code.PlugAction(code.PLUG, kit.Dict(
code.INCLUDE, code.HTML,
code.KEYWORD, kit.Dict(
"page", code.KEYWORD,
"view", code.KEYWORD,
"text", code.KEYWORD,
"image", code.KEYWORD,
"picker", code.KEYWORD,
"rich-text", code.KEYWORD,
"template", code.KEYWORD,
"import", code.KEYWORD,
"class", code.FUNCTION,
"size", code.FUNCTION,
"name", code.FUNCTION,
"range", code.FUNCTION,
"value", code.FUNCTION,
"placeholder", code.FUNCTION,
"is", code.FUNCTION,
"data", code.FUNCTION,
"wx:if", code.FUNCTION,
"wx:elif", code.FUNCTION,
"wx:for", code.FUNCTION,
"wx:for-item", code.FUNCTION,
"wx:for-index", code.FUNCTION,
"wx:key", code.FUNCTION,
"bindtap", code.FUNCTION,
"bindinput", code.FUNCTION,
"bindchange", code.FUNCTION,
),
))},
})
}

23
misc/wx/wxss.go Normal file
View File

@ -0,0 +1,23 @@
package wx
import (
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/core/code"
kit "shylinux.com/x/toolkits"
)
func init() {
Index.MergeCommands(ice.Commands{
"wxss": {Actions: code.PlugAction(code.PLUG, kit.Dict(
code.INCLUDE, code.CSS,
code.KEYWORD, kit.Dict(
"page", code.KEYWORD,
"view", code.KEYWORD,
"text", code.KEYWORD,
"image", code.KEYWORD,
"picker", code.KEYWORD,
"rich-text", code.KEYWORD,
),
))},
})
}