1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 01:24:05 +08:00

opt studio

This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-08-27 21:06:27 +08:00
parent 58d94c80bb
commit 99865b5459
8 changed files with 42 additions and 29 deletions

View File

@ -18,8 +18,11 @@ import (
)
const (
COOKIE = "cookie"
STATUS = "status"
STATUS = "status"
HEADER = "header"
COOKIE = "cookie"
REQUEST = "request"
RESPONSE = "response"
)
func Render(m *ice.Message, cmd string, args ...ice.Any) bool {

View File

@ -108,10 +108,7 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response
kit.If(m.Optionv(ice.MSG_CMDS) == nil, func() {
kit.If(strings.TrimPrefix(r.URL.Path, key), func(p string) { m.Optionv(ice.MSG_CMDS, strings.Split(p, nfs.PS)) })
})
defer func() {
Render(m, m.Option(ice.MSG_OUTPUT), kit.List(m.Optionv(ice.MSG_ARGS))...)
m.Debug("what %v", m.FormatMeta())
}()
defer func() { Render(m, m.Option(ice.MSG_OUTPUT), kit.List(m.Optionv(ice.MSG_ARGS))...) }()
if cmds, ok := _serve_auth(m, key, kit.Simple(m.Optionv(ice.MSG_CMDS)), w, r); ok {
defer func() { m.Cost(kit.Format("%s: %s %v", r.Method, m.PrefixPath()+path.Join(cmds...), 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) }))

View File

@ -149,11 +149,12 @@ func ShareLocalFile(m *ice.Message, arg ...string) {
if m.Option(ice.POD) == "" {
m.RenderDownload(p)
return
} else if p := kit.Path(ice.USR_LOCAL_WORK, m.Option(ice.POD), p); nfs.Exists(m, p) {
} else if pp := kit.Path(ice.USR_LOCAL_WORK, m.Option(ice.POD), p); nfs.Exists(m, pp) {
m.RenderDownload(pp)
return
} else if pp := kit.Path(ice.USR_LOCAL_WORK, m.Option(ice.POD)); nfs.Exists(m, pp) {
m.RenderDownload(p)
return
} else {
m.Debug("what %v %v", p, nfs.Exists(m, p))
}
pp := path.Join(ice.VAR_PROXY, m.Option(ice.POD), p)
cache, size := time.Now().Add(-time.Hour*24), int64(0)

View File

@ -25,7 +25,7 @@ func _spide_create(m *ice.Message, name, link string) {
dir, file := path.Split(u.EscapedPath())
m.Logs(mdb.INSERT, SPIDE, name, LINK, link)
mdb.HashSelectUpdate(m, mdb.HashCreate(m, CLIENT_NAME, name), func(value ice.Map) {
value[SPIDE_CLIENT] = kit.Dict(mdb.NAME, name, SPIDE_METHOD, http.MethodPost, "url", link, ORIGIN, u.Scheme+"://"+u.Host,
value[SPIDE_CLIENT] = kit.Dict(mdb.NAME, name, SPIDE_METHOD, http.MethodGet, "url", link, ORIGIN, u.Scheme+"://"+u.Host,
tcp.PROTOCOL, u.Scheme, tcp.HOSTNAME, u.Hostname(), tcp.HOST, u.Host, nfs.PATH, dir, nfs.FILE, file, cli.TIMEOUT, "300s",
)
})
@ -37,7 +37,7 @@ func _spide_show(m *ice.Message, name string, arg ...string) {
kit.If(action == SPIDE_SAVE, func() { file, arg = arg[0], arg[1:] })
msg := mdb.HashSelects(m.Spawn(), name)
method, arg := _spide_args(m, arg, http.MethodGet, http.MethodPut, http.MethodPost, http.MethodDelete)
method = kit.Select(http.MethodPost, msg.Append(CLIENT_METHOD), method)
method = kit.Select(http.MethodGet, msg.Append(CLIENT_METHOD), method)
uri, arg := arg[0], arg[1:]
body, head, arg := _spide_body(m, method, arg...)
if c, ok := body.(io.Closer); ok {
@ -48,26 +48,27 @@ func _spide_show(m *ice.Message, name string, arg ...string) {
return
}
mdb.HashSelectDetail(m, name, func(value ice.Map) { _spide_head(m, req, head, value) })
kit.For(req.Header, func(k string, v []string) { m.Logs(REQUEST, k, v) })
res, e := _spide_send(m, name, req, kit.Format(m.OptionDefault(CLIENT_TIMEOUT, msg.Append(CLIENT_TIMEOUT))))
if m.Warn(e, ice.ErrNotFound, uri) {
return
}
defer res.Body.Close()
m.Push(mdb.TYPE, "status")
m.Push(mdb.TYPE, STATUS)
m.Push(mdb.NAME, res.StatusCode)
m.Push(mdb.VALUE, res.Status)
m.Cost(cli.STATUS, res.Status, nfs.SIZE, kit.FmtSize(kit.Int64(res.Header.Get(ContentLength))), mdb.TYPE, res.Header.Get(ContentType))
kit.For(res.Header, func(k string, v []string) {
m.Logs("response", k, v)
m.Push(mdb.TYPE, "header")
m.Logs(RESPONSE, k, v)
m.Push(mdb.TYPE, SPIDE_HEADER)
m.Push(mdb.NAME, k)
m.Push(mdb.VALUE, v[0])
})
mdb.HashSelectUpdate(m, name, func(value ice.Map) {
kit.For(res.Cookies(), func(v *http.Cookie) {
kit.Value(value, kit.Keys(SPIDE_COOKIE, v.Name), v.Value)
m.Logs("response", v.Name, v.Value)
m.Push(mdb.TYPE, "cookie")
m.Logs(RESPONSE, v.Name, v.Value)
m.Push(mdb.TYPE, COOKIE)
m.Push(mdb.NAME, v.Name)
m.Push(mdb.VALUE, v.Value)
})
@ -256,12 +257,10 @@ const (
CLIENT_ORIGIN = "client.origin"
CLIENT_URL = "client.url"
OPEN = "open"
FULL = "full"
LINK = "link"
MERGE = "merge"
REQUEST = "request"
RESPONSE = "response"
OPEN = "open"
FULL = "full"
LINK = "link"
MERGE = "merge"
)
const SPIDE = "spide"

View File

@ -7,12 +7,13 @@ Volcanos(chat.ONIMPORT, {
},
_project: function(can, msg) { var target; msg.Table(function(value) {
var item = can.onimport.item(can, value, function(event) { can.Option(mdb.ZONE, value.zone)
if (can.onmotion.cache(can, function(data, old) {
if (old) { data[old] = {db: can.db, toggle: can.ui.toggle, _display_class: can.ui.display.className, _profile_class: can.ui.profile.className} }
var back = data[value.zone]||{}; can.db = back.db||{}, can.ui.toggle = back.toggle
can.ui.display.className = back._display_class||can.ui.display.className
can.ui.profile.className = back._profile_class||can.ui.profile.className
return value.zone
if (can.onmotion.cache(can, function(save, load) {
save({db: can.db, toggle: can.ui.toggle, _display_class: can.ui.display.className, _profile_class: can.ui.profile.className})
return load(value.zone, function(bak) {
can.db = bak.db, can.ui.toggle = bak.toggle
can.ui.display.className = bak._display_class||can.ui.display.className
can.ui.profile.className = bak._profile_class||can.ui.profile.className
})
}, can.ui.content, can.ui.display, can._status)) { return can.page.isDisplay(can.ui.profile) && can.onimport._profile(can, can.db.current), can.onimport.layout(can) }
can.run(event, [value.zone], function(msg) { can.onimport._content(can, msg, can.Option(mdb.ZONE)) })
}, null, can.ui.project); target = can.Option(mdb.ZONE) == value.zone? item: target||item

View File

@ -40,6 +40,7 @@ fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.item:last
fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.item:last-child { margin-right:80px; }
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>* { margin:10px 0px 10px 10px; }
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>div.item:last-child { margin-right:120px; }
fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>div.tabs { display:none; }
fieldset.macos.desktop>div.output>div.desktop>fieldset.web.wiki.feel>div.status { display:none; }
fieldset.macos.desktop>div.output>div.desktop>fieldset.web.code.vimer>div.status { display:none; }
fieldset.macos.desktop>div.output>div.desktop>fieldset.web.code.vimer>div.action>div.tabs { display:none; }

View File

@ -12,6 +12,7 @@ import (
"shylinux.com/x/icebergs/base/lex"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"
)
@ -124,6 +125,14 @@ func init() {
m.Cmdy(NAVIGATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH))
}},
}, ctx.CmdAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
if kit.HasPrefix(arg[0], "/require/", "http") {
m.Echo(m.Cmdx(web.SPIDE, ice.DEV, web.SPIDE_RAW, arg[0]))
ctx.DisplayLocal(m, "")
u := kit.ParseURL(arg[0])
m.Options("mode", "simple", "parse", kit.Ext(u.Path))
// ctx.ProcessRewrite(m, nfs.PATH, path.Dir(u.Path)+nfs.PS, nfs.FILE, path.Base(u.Path))
return
}
if arg[0] = strings.Split(arg[0], mdb.FS)[0]; !strings.HasSuffix(arg[0], nfs.PS) && len(arg) == 1 {
arg[1] = kit.Slice(strings.Split(arg[0], nfs.PS), -1)[0]
arg[0] = strings.TrimSuffix(arg[0], arg[1])

View File

@ -68,7 +68,9 @@ Volcanos(chat.ONACTION, {
if (link.indexOf(can.db.current) < 0 || link.endsWith(nfs.PS)) { return can.isCmdMode()? can.user.jumps(can.base.Path(can.db.prefix, link)+params): (can.Option(nfs.PATH, link), can.Update()) }
}
var file = can.base.trimPrefix(link, can.db.current); can.isCmdMode() && can.user.jumps("#"+file)
if (can.onmotion.cache(can, function(cache, key) { cache[key] = can._plugins, can._plugins = cache[file]||[]; return file }, can.ui.main, can.ui.aside)) { return file }
if (can.onmotion.cache(can, function(save, load) { save({plugins: can._plugins})
return load(file, function(bak) { can._plugins = bak.file })
}, can.ui.main, can.ui.aside)) { return file }
can.onimport.content(can, file)
can.user.toast(can, "加载成功")
return link