1
0
mirror of https://shylinux.com/x/icebergs synced 2025-06-26 02:17:30 +08:00
This commit is contained in:
IT 老营长 @云轩领航-创始人 2025-06-23 21:48:44 +08:00
parent db926c80e8
commit a9ebeed451
13 changed files with 62 additions and 55 deletions

View File

@ -47,7 +47,7 @@ func _command_search(m *ice.Message, kind, name, text string) {
} }
m.PushSearch(ice.CTX, kit.PathName(1), ice.CMD, kit.FileName(1), m.PushSearch(ice.CTX, kit.PathName(1), ice.CMD, kit.FileName(1),
kit.SimpleKV("", s.Prefix(), kit.Select(key, cmd.Name), cmd.Help), kit.SimpleKV("", s.Prefix(), kit.Select(key, cmd.Name), cmd.Help),
INDEX, kit.Keys(s.Prefix(), key)) INDEX, kit.Keys(s.Prefix(), key), mdb.HELP, cmd.Help)
}).Sort(m.OptionFields()) }).Sort(m.OptionFields())
} }
@ -124,7 +124,7 @@ func init() {
}}, }},
}), Hand: func(m *ice.Message, arg ...string) { }), Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 { if len(arg) == 0 {
m.OptionFields(INDEX) m.OptionFields(INDEX, mdb.HELP)
m.Cmdy("", mdb.SEARCH, COMMAND) m.Cmdy("", mdb.SEARCH, COMMAND)
} else { } else {
kit.For(arg, func(k string) { _command_list(m, k) }) kit.For(arg, func(k string) { _command_list(m, k) })

View File

@ -90,6 +90,7 @@ const (
VIEW = "view" VIEW = "view"
VALUE = "value" VALUE = "value"
INPUT = "input" INPUT = "input"
TITLE = "title"
ICON = "icon" ICON = "icon"
ICONS = "icons" ICONS = "icons"
OUTPUT = "output" OUTPUT = "output"

View File

@ -85,7 +85,7 @@ func Render(m *ice.Message, cmd string, args ...ice.Any) bool {
"$status", fieldset+">div.status", "$status", fieldset+">div.status",
"$fieldset", fieldset, "$fieldset", fieldset,
"$field", fieldset, "$field", fieldset,
"$input", "body>div.input.float."+m.Option(ctx.INDEX), "$input", "div.input.float."+m.Option(ctx.INDEX),
"$body", "body.cmd."+m.Option(ctx.INDEX), "$body", "body.cmd."+m.Option(ctx.INDEX),
"$index", m.Option(ctx.INDEX), "$index", m.Option(ctx.INDEX),
))) )))

View File

@ -155,7 +155,7 @@ func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) {
}() }()
msg := m.Spawn(b) msg := m.Spawn(b)
if safe && msg.Option(ice.MSG_UNSAFE) != ice.TRUE { // 下行权限 if safe && msg.Option(ice.MSG_UNSAFE) != ice.TRUE { // 下行权限
if !aaa.IsTechOrRoot(msg) && msg.Option(ice.MSG_HANDLE) != ice.TRUE { if !aaa.IsTechOrRoot(msg) && msg.Option(ice.MSG_HANDLE) != ice.TRUE && msg.Option(ice.MSG_USERUID) == "" {
msg.Option(ice.MSG_USERROLE, kit.Select(msg.Option(ice.MSG_USERROLE), aaa.UserRole(msg, msg.Option(ice.MSG_USERNAME)))) msg.Option(ice.MSG_USERROLE, kit.Select(msg.Option(ice.MSG_USERROLE), aaa.UserRole(msg, msg.Option(ice.MSG_USERNAME))))
} }
// kit.If(kit.IsIn(msg.Option(ice.MSG_USERROLE), "", aaa.VOID), func() { msg.Option(ice.MSG_USERROLE, aaa.UserRole(msg, msg.Option(ice.MSG_USERNAME))) }) // kit.If(kit.IsIn(msg.Option(ice.MSG_USERROLE), "", aaa.VOID), func() { msg.Option(ice.MSG_USERROLE, aaa.UserRole(msg, msg.Option(ice.MSG_USERNAME))) })
@ -530,7 +530,10 @@ func init() {
}) })
case SPACE: case SPACE:
AdminCmd(m, SPACE).Table(func(value ice.Maps) { AdminCmd(m, SPACE).Table(func(value ice.Maps) {
kit.If(kit.IsIn(value[mdb.TYPE], WORKER, SERVER), func() { m.Push(arg[0], value[mdb.NAME]) }) kit.If(kit.IsIn(value[mdb.TYPE], WORKER, SERVER), func() {
m.Push(arg[0], value[mdb.NAME])
m.Push(mdb.HELP, value[mdb.HELP])
})
}) })
case SERVER: case SERVER:
AdminCmd(m, SPACE).Table(func(value ice.Maps) { AdminCmd(m, SPACE).Table(func(value ice.Maps) {
@ -559,7 +562,8 @@ func init() {
} else { } else {
m.Cmdy(ctx.COMMAND) m.Cmdy(ctx.COMMAND)
} }
m.CutTo(ctx.INDEX, arg[0]) m.Cut(ctx.INDEX, mdb.HELP)
m.RenameAppend(ctx.INDEX, arg[0])
case ctx.ARGS: case ctx.ARGS:
m.OptionDefault(ctx.INDEX, m.Option("extra.index")) m.OptionDefault(ctx.INDEX, m.Option("extra.index"))
if space := m.Option(SPACE); space != "" { if space := m.Option(SPACE); space != "" {

View File

@ -171,6 +171,7 @@ const ( // DIR
SRC_MAIN_CSS = "src/main.css" SRC_MAIN_CSS = "src/main.css"
SRC_MAIN_JS = "src/main.js" SRC_MAIN_JS = "src/main.js"
SRC_MAIN_GO = "src/main.go" SRC_MAIN_GO = "src/main.go"
SRC_OPTION_GO = "src/option.go"
SRC_WEBVIEW_GO = "src/webview.go" SRC_WEBVIEW_GO = "src/webview.go"
SRC_VERSION_GO = "src/version.go" SRC_VERSION_GO = "src/version.go"
SRC_BINPACK_GO = "src/binpack.go" SRC_BINPACK_GO = "src/binpack.go"

View File

@ -111,15 +111,16 @@ func init() {
kit.If(cli.SystemFindGo(m), func() { m.PushButton(kit.Dict(m.CommandKey(), m.Commands("").Help)) }) kit.If(cli.SystemFindGo(m), func() { m.PushButton(kit.Dict(m.CommandKey(), m.Commands("").Help)) })
}) })
}}, }},
}, web.DreamTablesAction(), ctx.ConfAction(cli.ENV, kit.Dict(GOPRIVATE, "shylinux.com,github.com", GOPROXY, "https://goproxy.cn,direct", CGO_ENABLED, "0"))), Hand: func(m *ice.Message, arg ...string) { }, web.DreamTablesAction(), ctx.ConfAction(cli.ENV, kit.Dict(GOPRIVATE, "shylinux.com", GOPROXY, "https://goproxy.cn,direct", CGO_ENABLED, "0"))), Hand: func(m *ice.Message, arg ...string) {
main, file, goos, arch := _compile_target(m, arg...) main, file, goos, arch := _compile_target(m, arg...)
env := kit.Simple(cli.PATH, cli.BinPath(), cli.HOME, kit.Select(kit.Path(""), kit.Env(cli.HOME)), mdb.Configv(m, cli.ENV), m.Optionv(cli.ENV), cli.GOOS, goos, cli.GOARCH, arch) env := kit.Simple(cli.PATH, cli.BinPath(), cli.HOME, kit.Select(kit.Path(""), kit.Env(cli.HOME)), mdb.Configv(m, cli.ENV), m.Optionv(cli.ENV), cli.GOOS, goos, cli.GOARCH, arch)
kit.If(runtime.GOOS == cli.WINDOWS, func() { env = append(env, GOPATH, kit.HomePath(GO), GOCACHE, kit.HomePath("go/go-build")) }) kit.If(runtime.GOOS == cli.WINDOWS, func() { env = append(env, GOPATH, kit.HomePath(GO), GOCACHE, kit.HomePath("go/go-build")) })
m.Options(cli.CMD_ENV, env).Cmd(AUTOGEN, VERSION) m.Options(cli.CMD_ENV, env).Cmd(AUTOGEN, VERSION)
_compile_get(m, main) _compile_get(m, main)
defer m.StatusTime(VERSION, strings.TrimPrefix(GoVersion(m), "go version")) defer m.StatusTime(VERSION, strings.TrimPrefix(GoVersion(m), "go version"))
args := []string{main, ice.SRC_VERSION_GO} args := []string{main}
nfs.Exists(m, "src/option.go", func(p string) { args = append(args, p) }) nfs.Exists(m, ice.SRC_OPTION_GO, func(p string) { args = append(args, p) })
nfs.Exists(m, ice.SRC_VERSION_GO, func(p string) { args = append(args, p) })
kit.If(file != ice.BIN_ICE_BIN, func() { args = append(args, ice.SRC_BINPACK_GO, ice.SRC_BINPACK_USR_GO) }) kit.If(file != ice.BIN_ICE_BIN, func() { args = append(args, ice.SRC_BINPACK_GO, ice.SRC_BINPACK_USR_GO) })
if msg := GoBuild(m.Spawn(), file, args...); !cli.IsSuccess(msg) { if msg := GoBuild(m.Spawn(), file, args...); !cli.IsSuccess(msg) {
m.Copy(msg) m.Copy(msg)

View File

@ -18,20 +18,13 @@ func _css_stat(m *ice.Message, zone string, stats map[string]int) {
m.Copy(msg.SortIntR(mdb.VALUE)) m.Copy(msg.SortIntR(mdb.VALUE))
} }
func _css_show(m *ice.Message, arg ...string) { func _css_show(m *ice.Message, arg ...string) {
if _go_portal(m, arg...) {
return
}
if arg[1] == "main.css" { if arg[1] == "main.css" {
m.EchoIFrame(m.MergePodCmd("", web.ADMIN)) m.EchoIFrame(m.MergePodCmd("", web.ADMIN))
return return
} }
if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
if p := path.Join(arg[2], strings.Split(arg[1], "/")[0], "portal.go"); nfs.Exists(m, p) {
if _cmd := ctx.GetFileCmd(p); _cmd != "" {
if msg := m.Cmd(_cmd, "commandSelect", cmd); msg.Length() > 0 {
ctx.ProcessField(m, _cmd, kit.Simple())
return
}
}
}
}
cmd := kit.Select(ice.CAN_PLUGIN, ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO))) cmd := kit.Select(ice.CAN_PLUGIN, ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO)))
ctx.DisplayBaseCSS(m, require(arg[2], arg[1]), "render", "replace", ctx.INDEX, cmd, ice.POD, m.Option(ice.MSG_USERPOD)) ctx.DisplayBaseCSS(m, require(arg[2], arg[1]), "render", "replace", ctx.INDEX, cmd, ice.POD, m.Option(ice.MSG_USERPOD))
ctx.DisplayBase(m, require(arg[2], arg[1])) ctx.DisplayBase(m, require(arg[2], arg[1]))
@ -72,6 +65,9 @@ func _css_show(m *ice.Message, arg ...string) {
_css_stat(m, "stats.value", stats_value) _css_stat(m, "stats.value", stats_value)
} }
func _css_exec(m *ice.Message, arg ...string) { func _css_exec(m *ice.Message, arg ...string) {
if _go_portal(m, arg...) {
return
}
if arg[2] == ice.USR_VOLCANOS { if arg[2] == ice.USR_VOLCANOS {
if strings.HasPrefix(arg[1], ice.PLUGIN_LOCAL) { if strings.HasPrefix(arg[1], ice.PLUGIN_LOCAL) {
ctx.ProcessField(m, kit.Select(ice.CAN_PLUGIN, "web."+strings.Replace(kit.TrimExt(strings.TrimPrefix(arg[1], ice.PLUGIN_LOCAL), JS), nfs.PS, nfs.PT, -1)), kit.Simple()) ctx.ProcessField(m, kit.Select(ice.CAN_PLUGIN, "web."+strings.Replace(kit.TrimExt(strings.TrimPrefix(arg[1], ice.PLUGIN_LOCAL), JS), nfs.PS, nfs.PT, -1)), kit.Simple())

View File

@ -5,6 +5,7 @@ import (
"strings" "strings"
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/gdb" "shylinux.com/x/icebergs/base/gdb"
@ -61,6 +62,33 @@ func _go_navigate(m *ice.Message, arg ...string) {
} }
_c_tags(m, GOTAGS, "-f", nfs.TAGS, "-R", nfs.PWD) _c_tags(m, GOTAGS, "-f", nfs.TAGS, "-R", nfs.PWD)
} }
func _go_portal(m *ice.Message, arg ...string) bool {
if p := path.Join(arg[2], strings.Split(arg[1], "/")[0], "portal.go"); nfs.Exists(m, p) {
cmd := ctx.GetFileCmd(path.Join(arg[2], kit.ExtChange(arg[1], "go")))
if _cmd := ctx.GetFileCmd(p); _cmd != "" {
if m.ActionKey() == mdb.RENDER {
if path.Base(arg[1]) == "common.go" {
ctx.ProcessField(m, strings.ReplaceAll(_cmd, ".portal", ".clean"), kit.Simple())
} else if msg := m.Cmd(_cmd, "commandSelect", cmd); msg.Length() > 0 || cmd == "" {
ctx.ProcessField(m, _cmd, kit.Simple())
} else {
ctx.ProcessField(m, cmd, kit.Simple())
}
} else if aaa.IsTechOrRoot(m) {
ls := kit.Split(arg[1], "/")
if msg := m.Cmd(_cmd, "commandSelect", cmd); msg.Length() > 0 && !kit.IsIn(path.Base(arg[1]), "model.go", "common.go") {
ctx.ProcessField(m, "web.code.mysql.query", kit.Simple("mysql", ls[0], TableName(kit.TrimExt(kit.Select("", ls, -1), arg[0]))))
} else {
ctx.ProcessField(m, "web.code.mysql.query", kit.Simple("mysql", ls[0]))
}
} else {
m.Option(ice.MSG_DISPLAY, "")
}
}
return true
}
return false
}
func _go_show(m *ice.Message, arg ...string) { func _go_show(m *ice.Message, arg ...string) {
if arg[1] == MAIN_GO { if arg[1] == MAIN_GO {
ProcessXterm(m, kit.JoinWord("ish", arg[1]), "", "") ProcessXterm(m, kit.JoinWord("ish", arg[1]), "", "")
@ -68,31 +96,8 @@ func _go_show(m *ice.Message, arg ...string) {
ctx.ProcessField(m, cli.RUNTIME, kit.Simple()) ctx.ProcessField(m, cli.RUNTIME, kit.Simple())
} else if arg[1] == "binpack.go" { } else if arg[1] == "binpack.go" {
ctx.ProcessField(m, nfs.PACK, kit.Simple()) ctx.ProcessField(m, nfs.PACK, kit.Simple())
} else if path.Base(arg[1]) == "model.go" { } else if _go_portal(m, arg...) {
ctx.ProcessField(m, "web.code.mysql.query", kit.Simple("mysql", kit.Split(arg[1], "/", "/")[0]))
} else if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" { } else if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
if p := path.Join(arg[2], strings.Split(arg[1], "/")[0], "portal.go"); path.Base(arg[1]) != "portal.go" && nfs.Exists(m, p) {
if _cmd := ctx.GetFileCmd(p); _cmd != "" {
if m.ActionKey() == mdb.RENDER {
if path.Base(arg[1]) == "common.go" {
ctx.ProcessField(m, strings.ReplaceAll(_cmd, ".portal", ".clean"), kit.Simple())
return
}
if msg := m.Cmd(_cmd, "commandSelect", cmd); msg.Length() > 0 {
ctx.ProcessField(m, _cmd, kit.Simple())
return
}
} else {
ls := kit.Split(strings.TrimSuffix(arg[1], ".go"), "/")
if path.Base(arg[1]) == "common.go" {
ctx.ProcessField(m, "web.code.mysql.query", kit.Simple("mysql", ls[0]))
} else {
ctx.ProcessField(m, "web.code.mysql.query", kit.Simple("mysql", ls[0], TableName(kit.Select("", ls, -1))))
}
return
}
}
}
ctx.ProcessField(m, cmd, kit.Simple()) ctx.ProcessField(m, cmd, kit.Simple())
} else if msg := m.Cmd(yac.STACK, path.Join(arg[2], arg[1])); msg.Option("__index") != "" { } else if msg := m.Cmd(yac.STACK, path.Join(arg[2], arg[1])); msg.Option("__index") != "" {
ctx.ProcessField(m, msg.Option("__index"), kit.Simple()) ctx.ProcessField(m, msg.Option("__index"), kit.Simple())

View File

@ -1,7 +1,6 @@
package code package code
import ( import (
"path"
"strings" "strings"
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
@ -21,17 +20,7 @@ func _js_show(m *ice.Message, arg ...string) {
} else if strings.HasPrefix(arg[1], "plugin/local/") { } else if strings.HasPrefix(arg[1], "plugin/local/") {
ctx.ProcessField(m, kit.Select(ice.CAN_PLUGIN, "web."+strings.Replace(strings.TrimSuffix(strings.TrimPrefix(arg[1], "plugin/local/"), nfs.PT+JS), nfs.PS, nfs.PT, -1)), nil) ctx.ProcessField(m, kit.Select(ice.CAN_PLUGIN, "web."+strings.Replace(strings.TrimSuffix(strings.TrimPrefix(arg[1], "plugin/local/"), nfs.PT+JS), nfs.PS, nfs.PT, -1)), nil)
} }
} else if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" { } else if _go_portal(m, arg...) {
if p := path.Join(arg[2], strings.Split(arg[1], "/")[0], "portal.go"); nfs.Exists(m, p) {
if _cmd := ctx.GetFileCmd(p); _cmd != "" {
if msg := m.Cmd(_cmd, "commandSelect", cmd); msg.Length() > 0 {
ctx.ProcessField(m, _cmd, kit.Simple())
return
}
}
}
ctx.DisplayBase(m, require(arg[2], arg[1]))
ctx.ProcessField(m, kit.Select(ice.CAN_PLUGIN, ctx.GetFileCmd(kit.ExtChange(path.Join(arg[2], arg[1]), GO))), kit.Simple())
} }
} }

View File

@ -32,6 +32,12 @@ func init() {
}) })
}}, }},
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
if path.Base(arg[1]) == "portal.json" {
if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
ctx.ProcessField(m, cmd, kit.Simple("table"))
return
}
}
m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1])) m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1]))
ctx.DisplayStoryJSON(m) ctx.DisplayStoryJSON(m)
}}, }},

View File

@ -145,6 +145,7 @@ func init() {
gdb.Event(m, VIMER_SAVE) gdb.Event(m, VIMER_SAVE)
}}, }},
mdb.RENDER: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) { _inner_show(m, arg[0], arg[1], arg[2]) }}, mdb.RENDER: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) { _inner_show(m, arg[0], arg[1], arg[2]) }},
mdb.ENGINE: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) { _inner_exec(m, arg[0], arg[1], arg[2]) }},
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(TEMPLATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH)) m.Cmdy(TEMPLATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
}}, }},

View File

@ -52,6 +52,7 @@ func init() {
"oauth", "", web.SPACE, "", nfs.SCRIPT, "https://res.wx.qq.com/open/js/jweixin-1.6.0.js", "oauth", "", web.SPACE, "", nfs.SCRIPT, "https://res.wx.qq.com/open/js/jweixin-1.6.0.js",
)), Hand: func(m *ice.Message, arg ...string) { )), Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(ACCESS, AGENT).Options(SIGNATURE, _wx_sign(m, m.Option(NONCESTR, ice.Info.Pathname), m.Option(TIMESTAMP, kit.Format(time.Now().Unix())))).Display("") m.Cmdy(ACCESS, AGENT).Options(SIGNATURE, _wx_sign(m, m.Option(NONCESTR, ice.Info.Pathname), m.Option(TIMESTAMP, kit.Format(time.Now().Unix())))).Display("")
m.Info("what %v", m.FormatsMeta(nil))
ctx.OptionFromConfig(m, "oauth", nfs.SCRIPT) ctx.OptionFromConfig(m, "oauth", nfs.SCRIPT)
if m.Option(ice.MSG_USERNAME) == "" { if m.Option(ice.MSG_USERNAME) == "" {
msg := m.Spawn() msg := m.Spawn()

View File

@ -8,6 +8,7 @@ Volcanos(chat.ONIMPORT, {
debug = false, can.onmotion.hidden(can, can._fields) debug = false, can.onmotion.hidden(can, can._fields)
wx.config({debug: debug, signature: msg.Option("signature"), timestamp: msg.Option("timestamp"), nonceStr: msg.Option("noncestr"), appId: msg.Option("appid"), wx.config({debug: debug, signature: msg.Option("signature"), timestamp: msg.Option("timestamp"), nonceStr: msg.Option("noncestr"), appId: msg.Option("appid"),
jsApiList: can.core.Item({ jsApiList: can.core.Item({
/*
getLocation: function(can, cb) { wx.getLocation({type: "gcj02", success: function (res) { getLocation: function(can, cb) { wx.getLocation({type: "gcj02", success: function (res) {
can.base.isFunc(cb) && cb({type: "gcj02", name: "当前位置", text: "当前位置", latitude: parseInt(res.latitude*100000), longitude: parseInt(res.longitude*100000) }) can.base.isFunc(cb) && cb({type: "gcj02", name: "当前位置", text: "当前位置", latitude: parseInt(res.latitude*100000), longitude: parseInt(res.longitude*100000) })
} }) }, } }) },
@ -27,6 +28,7 @@ Volcanos(chat.ONIMPORT, {
scanQRCode: function(can, cb) { wx.scanQRCode({needResult: cb? 1: 0, scanType: ["qrCode", "barCode"], success: function (res) { scanQRCode: function(can, cb) { wx.scanQRCode({needResult: cb? 1: 0, scanType: ["qrCode", "barCode"], success: function (res) {
can.base.isFunc(cb) && cb(can.base.ParseJSON(res.resultStr)) can.base.isFunc(cb) && cb(can.base.ParseJSON(res.resultStr))
} }) }, } }) },
*/
}, function(key, value) { return can.user.agent[key] = value, key }).concat([ }, function(key, value) { return can.user.agent[key] = value, key }).concat([
"updateAppMessageShareData", "updateAppMessageShareData",
], can.user.isMobile? ["updateTimelineShareData"]: []), openTagList: ["wx-open-subscribe"], ], can.user.isMobile? ["updateTimelineShareData"]: []), openTagList: ["wx-open-subscribe"],