mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 09:14:06 +08:00
add plugin/favor
This commit is contained in:
parent
e2b8d0a9cf
commit
831ead99e0
@ -1,5 +1,9 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
|
# ctx_log_debug=false
|
||||||
|
# ctx_log_disable=false
|
||||||
|
# ctx_gdb_enable=false
|
||||||
|
|
||||||
ctx_log=${ctx_log:="var/log"}
|
ctx_log=${ctx_log:="var/log"}
|
||||||
ctx_app=${ctx_app:="bench"}
|
ctx_app=${ctx_app:="bench"}
|
||||||
ctx_bin=${ctx_app} && [ -f bin/${ctx_app} ] && ctx_bin=$(pwd)/bin/${ctx_app}
|
ctx_bin=${ctx_app} && [ -f bin/${ctx_app} ] && ctx_bin=$(pwd)/bin/${ctx_app}
|
||||||
|
@ -4,5 +4,5 @@ var version = struct {
|
|||||||
host string
|
host string
|
||||||
self int
|
self int
|
||||||
}{
|
}{
|
||||||
"2019-07-31 21:50:19", "ZYB-20190522USI", 329,
|
"2019-08-01 09:34:16", "com.mac", 245,
|
||||||
}
|
}
|
||||||
|
@ -46,24 +46,24 @@ func (ctx *CTX) Begin(m *Message, arg ...string) Server {
|
|||||||
func (ctx *CTX) Start(m *Message, arg ...string) bool {
|
func (ctx *CTX) Start(m *Message, arg ...string) bool {
|
||||||
if m.Optionv("bio.ctx", Index); len(arg) == 0 {
|
if m.Optionv("bio.ctx", Index); len(arg) == 0 {
|
||||||
kit.DisableLog = false
|
kit.DisableLog = false
|
||||||
m.Optionv("bio.msg", m)
|
m.Option("log.debug", kit.Right(os.Getenv("ctx_log_debug")))
|
||||||
m.Optionv("bio.ctx", m.Target())
|
m.Option("log.disable", kit.Right(os.Getenv("ctx_log_disable")))
|
||||||
m.Option("bio.modal", "active")
|
m.Option("gdb.enable", kit.Right(os.Getenv("ctx_gdb_enable")))
|
||||||
m.Option("log.debug", false)
|
|
||||||
m.Option("log.disable", false)
|
|
||||||
m.Option("gdb.enable", false)
|
|
||||||
m.Cap("stream", "stdio")
|
|
||||||
m.Cmd("log._init")
|
m.Cmd("log._init")
|
||||||
m.Cmd("gdb._init")
|
m.Cmd("gdb._init")
|
||||||
|
|
||||||
m.Cmd("ctx._init")
|
m.Cmd("ctx._init")
|
||||||
|
m.Option("bio.modal", "active")
|
||||||
|
|
||||||
|
m.Optionv("bio.ctx", m.Target())
|
||||||
|
m.Optionv("bio.msg", m)
|
||||||
|
m.Cap("stream", "stdio")
|
||||||
m.Cmd("aaa.role", "root", "user", m.Option("username", m.Conf("runtime", "boot.username")))
|
m.Cmd("aaa.role", "root", "user", m.Option("username", m.Conf("runtime", "boot.username")))
|
||||||
m.Option("sessid", m.Cmdx("aaa.user", "session", "select"))
|
m.Option("sessid", m.Cmdx("aaa.user", "session", "select"))
|
||||||
|
|
||||||
m.Cmd("nfs.source", m.Conf("cli.system", "script.init")).Cmd("nfs.source", "stdio").Cmd("nfs.source", m.Conf("cli.system", "script.exit"))
|
m.Cmd("nfs.source", m.Conf("cli.system", "script.init")).Cmd("nfs.source", "stdio").Cmd("nfs.source", m.Conf("cli.system", "script.exit"))
|
||||||
} else {
|
} else {
|
||||||
m.Option("bio.modal", "action")
|
|
||||||
|
|
||||||
m.Cmd("ctx._init")
|
m.Cmd("ctx._init")
|
||||||
|
m.Option("bio.modal", "action")
|
||||||
for _, v := range m.Sess("cli").Cmd(arg).Meta["result"] {
|
for _, v := range m.Sess("cli").Cmd(arg).Meta["result"] {
|
||||||
fmt.Printf("%s", v)
|
fmt.Printf("%s", v)
|
||||||
}
|
}
|
||||||
|
@ -328,6 +328,9 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心",
|
|||||||
map[string]interface{}{"page": "line", "hash": "line", "word": []interface{}{"opt{", "mul{", "stm", "cmd", "}", "}", "com"}},
|
map[string]interface{}{"page": "line", "hash": "line", "word": []interface{}{"opt{", "mul{", "stm", "cmd", "}", "}", "com"}},
|
||||||
|
|
||||||
// 复合语句
|
// 复合语句
|
||||||
|
map[string]interface{}{"page": "op1", "hash": "op1", "word": []interface{}{"mul{", "!", "}"}},
|
||||||
|
map[string]interface{}{"page": "op2", "hash": "op2", "word": []interface{}{"mul{", "&&", "||", "}"}},
|
||||||
|
map[string]interface{}{"page": "exe", "hash": "exe", "word": []interface{}{"(", "exp", ")"}},
|
||||||
map[string]interface{}{"page": "exe", "hash": "exe", "word": []interface{}{"$", "(", "cmd", ")"}},
|
map[string]interface{}{"page": "exe", "hash": "exe", "word": []interface{}{"$", "(", "cmd", ")"}},
|
||||||
map[string]interface{}{"page": "stm", "hash": "var", "word": []interface{}{"var", "key", "opt{", "=", "exp", "}"}},
|
map[string]interface{}{"page": "stm", "hash": "var", "word": []interface{}{"var", "key", "opt{", "=", "exp", "}"}},
|
||||||
map[string]interface{}{"page": "stm", "hash": "let", "word": []interface{}{"let", "key", "opt{", "=", "exp", "}"}},
|
map[string]interface{}{"page": "stm", "hash": "let", "word": []interface{}{"let", "key", "opt{", "=", "exp", "}"}},
|
||||||
@ -595,6 +598,8 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心",
|
|||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case "$", "@":
|
case "$", "@":
|
||||||
m.Result(0, arg[2:len(arg)-1])
|
m.Result(0, arg[2:len(arg)-1])
|
||||||
|
case "(":
|
||||||
|
m.Echo(arg[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -629,6 +634,8 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心",
|
|||||||
if info, e := os.Stat(arg[1]); e == nil && info.IsDir() {
|
if info, e := os.Stat(arg[1]); e == nil && info.IsDir() {
|
||||||
result = "true"
|
result = "true"
|
||||||
}
|
}
|
||||||
|
case "!":
|
||||||
|
result = kit.Format(!kit.Right(arg[1]))
|
||||||
case "+":
|
case "+":
|
||||||
result = arg[1]
|
result = arg[1]
|
||||||
case "-":
|
case "-":
|
||||||
@ -713,6 +720,18 @@ var Index = &ctx.Context{Name: "yac", Help: "语法中心",
|
|||||||
} else {
|
} else {
|
||||||
result = fmt.Sprintf("%t", arg[0] != arg[2])
|
result = fmt.Sprintf("%t", arg[0] != arg[2])
|
||||||
}
|
}
|
||||||
|
case "&&":
|
||||||
|
if kit.Right(arg[0]) {
|
||||||
|
result = arg[2]
|
||||||
|
} else {
|
||||||
|
result = arg[0]
|
||||||
|
}
|
||||||
|
case "||":
|
||||||
|
if kit.Right(arg[0]) {
|
||||||
|
result = arg[0]
|
||||||
|
} else {
|
||||||
|
result = arg[2]
|
||||||
|
}
|
||||||
|
|
||||||
case "~":
|
case "~":
|
||||||
if m, e := regexp.MatchString(arg[2], arg[0]); m && e == nil {
|
if m, e := regexp.MatchString(arg[2], arg[0]); m && e == nil {
|
||||||
|
36
src/plugin/favor/index.go
Normal file
36
src/plugin/favor/index.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"contexts/cli"
|
||||||
|
"contexts/ctx"
|
||||||
|
"toolkit"
|
||||||
|
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Index = &ctx.Context{Name: "test", Help: "测试工具",
|
||||||
|
Caches: map[string]*ctx.Cache{},
|
||||||
|
Configs: map[string]*ctx.Config{
|
||||||
|
"_index": &ctx.Config{Name: "index", Value: []interface{}{
|
||||||
|
map[string]interface{}{"name": "demo", "help": "demo",
|
||||||
|
"tmpl": "componet", "view": "componet", "init": "",
|
||||||
|
"type": "public", "ctx": "demo", "cmd": "demo",
|
||||||
|
"args": []interface{}{}, "inputs": []interface{}{
|
||||||
|
map[string]interface{}{"type": "text", "name": "pod", "value": "hello world"},
|
||||||
|
map[string]interface{}{"type": "button", "value": "执行"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
Commands: map[string]*ctx.Command{
|
||||||
|
"demo": {Name: "demo", Help: "demo", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
|
m.Echo(kit.Select("hello world", arg, 0))
|
||||||
|
return
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Print(cli.Index.Plugin(Index, os.Args[1:]))
|
||||||
|
}
|
4
src/plugin/favor/index.js
Normal file
4
src/plugin/favor/index.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
{init: function(page, pane, field, option, output) {
|
||||||
|
kit.Log("hello world")
|
||||||
|
}}
|
79
src/plugin/favor/index.shy
Normal file
79
src/plugin/favor/index.shy
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
|
||||||
|
fun clip "粘贴板" "" "" \
|
||||||
|
public \
|
||||||
|
text "" name you imports plugin_you action auto \
|
||||||
|
text "" view long \
|
||||||
|
button "存储"
|
||||||
|
|
||||||
|
copy ssh._route $1 aaa.clip $2
|
||||||
|
end
|
||||||
|
|
||||||
|
fun qrcode "二维码" "" "" \
|
||||||
|
public \
|
||||||
|
text "" view long \
|
||||||
|
button "生成"
|
||||||
|
|
||||||
|
table qrcode $1
|
||||||
|
end
|
||||||
|
|
||||||
|
fun salary "工资单" "" "" \
|
||||||
|
public \
|
||||||
|
text "9000" label total \
|
||||||
|
text "9000" label base \
|
||||||
|
button "计算"
|
||||||
|
|
||||||
|
let total = $1 || $2
|
||||||
|
let base = $2 || $1
|
||||||
|
|
||||||
|
let house = $base * 120 / 1000
|
||||||
|
let old = $base * 80 / 1000
|
||||||
|
let tread = $base * 20 / 1000
|
||||||
|
let job = $base * 2 / 1000
|
||||||
|
let get = $total - $house - $old - $tread - $job
|
||||||
|
|
||||||
|
let tax = 0
|
||||||
|
let rest = $get
|
||||||
|
if $rest > 85000
|
||||||
|
let tax = $tax + ($rest - 85000) * 45 / 100
|
||||||
|
let rest = 85000
|
||||||
|
end
|
||||||
|
if $rest > 60000
|
||||||
|
let tax = $tax + ($rest - 60000) * 35 / 100
|
||||||
|
let rest = 60000
|
||||||
|
end
|
||||||
|
if $rest > 40000
|
||||||
|
let tax = $tax + ($rest - 40000) * 30 / 100
|
||||||
|
let rest = 40000
|
||||||
|
end
|
||||||
|
if $rest > 30000
|
||||||
|
let tax = $tax + ($rest - 30000) * 25 / 100
|
||||||
|
let rest = 30000
|
||||||
|
end
|
||||||
|
if $rest > 17000
|
||||||
|
let tax = $tax + ($rest - 17000) * 20 / 100
|
||||||
|
let rest = 17000
|
||||||
|
end
|
||||||
|
if $rest > 8000
|
||||||
|
let tax = $tax + ($rest - 8000) * 10 / 100
|
||||||
|
let rest = 8000
|
||||||
|
end
|
||||||
|
if $rest > 5000
|
||||||
|
let tax = $tax + ($rest - 5000) * 3 / 100
|
||||||
|
end
|
||||||
|
let rest = $get - $tax
|
||||||
|
|
||||||
|
|
||||||
|
append "公积金" $house
|
||||||
|
append "养老保险" $old
|
||||||
|
append "医疗保险" $tread
|
||||||
|
append "失业保险" $job
|
||||||
|
append "个税" $tax
|
||||||
|
append "结余" $rest
|
||||||
|
end
|
||||||
|
|
||||||
|
fun hello world "" "" \
|
||||||
|
public \
|
||||||
|
text "" \
|
||||||
|
button "执行"
|
||||||
|
copy pwd
|
||||||
|
end
|
1
src/plugin/favor/local.shy
Normal file
1
src/plugin/favor/local.shy
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
Loading…
x
Reference in New Issue
Block a user