diff --git a/README.md b/README.md index 22685229..4a65ffa1 100644 --- a/README.md +++ b/README.md @@ -81,13 +81,9 @@ Yao has a built-in data management system. By writing **JSON** to describe the i ## Install -Run the script under terminal: (MacOS/Linux) +Latest Version download and installation: -```bash -curl -fsSL https://website.yaoapps.com/install.sh | bash -``` - -For Windows users, please refer to the Installation and Debugging chapter: [Installation and debugging](https://yaoapps.com/en-US/doc/Introduction/Install) +https://github.com/YaoApp/xgen-dev-app/blob/main/README.md ## Getting Started @@ -109,23 +105,6 @@ yao start # Start installation - Password: **A123456p+** -### Download a project - -Create a new project directory, enter the project directory, run the `yao get` command, and download the application code. - -```bash -mkdir -p /data/app # create project directory -cd /data/app # Enter the project directory -yao get yaoapp/demo-plm # download demo-plm -yao start # Start installation -``` - -**Default Account** - -- User: **xiang@iqka.com** - -- Password: **A123456p+** - ## About Yao Yao's name is derived from the Chinese character **爻 (yáo)**, the basic symbol that makes up the Eight Trigrams. The Eight Trigrams is a symbol system created by the ancient god Fuxi after observing and summarizing the laws of nature, which can refer to everything. Yao has two states of yin and yang, like 0 and 1. The transformation of yin and yang of Yao drives the replacement of Eight Trigrams, so as to summarize and record the development law of things. diff --git a/README.zh-CN.md b/README.zh-CN.md index b67a94e4..4b702877 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -50,13 +50,9 @@ Yao 内置了一套数据管理系统,通过编写 **JSON** 描述界面布局 ## 安装 -在终端下运行脚本: ( MacOS / Linux ) +Yao v0.10.4 使用说明 -```bash -curl -fsSL https://website.yaoapps.com/install.sh | bash -``` - -Windows 用户请参考安装调试章节: [安装调试](https://yaoapps.com/doc/%E4%BB%8B%E7%BB%8D/%E5%AE%89%E8%A3%85%E8%B0%83%E8%AF%95) +https://github.com/YaoApp/xgen-dev-app/blob/main/README.zh-CN.md ## 入门指南 @@ -82,23 +78,6 @@ yao start # 启动安装界面 ![安装界面](docs/yao-setup-step2.jpg) -#### 下载已上架应用 - -新建一个项目目录,进入项目目录,运行 `yao get` 命令, 下载应用代码。 - -```bash -mkdir -p /data/app # 创建应用目录 -cd /data/app # 进入应用目录 -yao get yaoapp/demo-plm # 下载 demo-plm -yao start # 启动安装界面 -``` - -**默认账号** - -- 用户名: **xiang@iqka.com** - -- 密码: **A123456p+** - ## 关于 Yao Yao 的名字源于汉字**爻(yáo)**,是构成八卦的基本符号。八卦,是上古大神伏羲观测总结自然规律后,创造的一个可以指代万事万物的符号体系。爻,有阴阳两种状态,就像 0 和 1。爻的阴阳转换,驱动八卦更替,以此来总结记录事物的发展规律。 diff --git a/config/types.go b/config/types.go index bfd22d7e..58df739d 100644 --- a/config/types.go +++ b/config/types.go @@ -65,4 +65,8 @@ type Runtime struct { HeapSizeRelease uint64 `json:"heapSizeRelease,omitempty" env:"YAO_RUNTIME_HEAP_RELEASE" envDefault:"52428800"` // the isolate will be re-created when reaching this value, and the default value is 52428800 (50M) HeapAvailableSize uint64 `json:"heapAvailableSize,omitempty" env:"YAO_RUNTIME_HEAP_AVAILABLE" envDefault:"524288000"` // the isolate will be re-created when the available size is smaller than this value, and the default value is 524288000 (500M) Precompile bool `json:"precompile,omitempty" env:"YAO_RUNTIME_PRECOMPILE" envDefault:"false"` // if true compile scripts when the VM is created. this will increase the load time, but the script will run faster. the default value is false + + // The following options are experimental features and not stable. + // They may be removed once the features become stable. Please do not use them in a production environment. + Import bool `json:"import,omitempty" env:"YAO_RUNTIME_IMPORT" envDefault:"false"` // If true, TypeScript import will be enabled. Default value is false. } diff --git a/neo/neo.go b/neo/neo.go index 6c8dbc28..0b610c01 100644 --- a/neo/neo.go +++ b/neo/neo.go @@ -130,6 +130,29 @@ func (neo *DSL) API(router *gin.Engine, path string) error { } switch cmd { + + case "ModelList": + c.JSON(200, gin.H{"data": neo.Models, "code": 200}) + c.Done() + + case "SelectModel": + model, ok := payload["model"].(string) + if !ok { + c.JSON(400, gin.H{"message": "model is required", "code": 400}) + c.Done() + return + } + + err := neo.Select(model) + if err != nil { + c.JSON(500, gin.H{"message": err.Error(), "code": 500}) + c.Done() + return + } + + c.JSON(200, gin.H{"message": "success", "code": 200}) + c.Done() + case "ExitCommandMode": err := command.Exit(sid) if err != nil { @@ -524,11 +547,17 @@ func (neo *DSL) getGuardHandlers() ([]gin.HandlerFunc, error) { // NewAI create a new AI func (neo *DSL) newAI() error { - if neo.Connector == "" { - ai, err := openai.NewMoapi("gpt-3.5-turbo") + if neo.Connector == "" || strings.HasPrefix(neo.Connector, "moapi") { + model := "gpt-3.5-turbo" + if neo.Connector != "" { + model = strings.TrimPrefix(neo.Connector, "moapi:") + } + + ai, err := openai.NewMoapi(model) if err != nil { return err } + neo.AI = ai return nil } @@ -550,6 +579,16 @@ func (neo *DSL) newAI() error { return fmt.Errorf("%s connector %s not support, should be a openai", neo.ID, neo.Connector) } +// Select select the model +func (neo *DSL) Select(model string) error { + ai, err := openai.NewMoapi(model) + if err != nil { + return err + } + neo.AI = ai + return nil +} + // newConversation create a new conversation func (neo *DSL) newConversation() error { diff --git a/neo/types.go b/neo/types.go index 37129e96..f6846caa 100644 --- a/neo/types.go +++ b/neo/types.go @@ -22,6 +22,7 @@ type DSL struct { Prompts []aigc.Prompt `json:"prompts,omitempty"` Allows []string `json:"allows,omitempty"` Command Command `json:"command,omitempty"` + Models []string `json:"models,omitempty"` AI aigc.AI `json:"-" yaml:"-"` Conversation conversation.Conversation `json:"-" yaml:"-"` GuardHandlers []gin.HandlerFunc `json:"-" yaml:"-"` diff --git a/runtime/runtime.go b/runtime/runtime.go index 35b64295..6986ade4 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -19,6 +19,7 @@ func Start(cfg config.Config) error { Mode: cfg.Runtime.Mode, DefaultTimeout: cfg.Runtime.DefaultTimeout, ContextTimeout: cfg.Runtime.ContextTimeout, + Import: cfg.Runtime.Import, } err := v8.Start(option) diff --git a/script/script.go b/script/script.go index 2c8c08a6..68cfd3dd 100644 --- a/script/script.go +++ b/script/script.go @@ -11,6 +11,7 @@ import ( // Load 加载共享库 func Load(cfg config.Config) error { + v8.CLearModules() exts := []string{"*.js", "*.ts"} err := application.App.Walk("scripts", func(root, file string, isdir bool) error { if isdir { diff --git a/sui/core/build.go b/sui/core/build.go index a72838ab..0f865738 100644 --- a/sui/core/build.go +++ b/sui/core/build.go @@ -13,7 +13,7 @@ import ( ) var slotRe = regexp.MustCompile(`\[\{([^\}]+)\}\]`) -var cssRe = regexp.MustCompile(`([\.a-z0-9A-Z# ]+)\{`) +var cssRe = regexp.MustCompile(`([\.a-z0-9A-Z-:# ]+)\{`) // Build is the struct for the public func (page *Page) Build(option *BuildOption) (*goquery.Document, []string, error) { @@ -72,11 +72,13 @@ func (page *Page) BuildForImport(option *BuildOption, slots map[string]interface for k, v := range slots { slotvars[k] = v } - data["$slot"] = slotvars + data["$slot"] = slotvars // Will be deprecated use $slots instead + data["$slots"] = slotvars } if attrs != nil { - data["$prop"] = attrs + data["$prop"] = attrs // Will be deprecated use $props instead + data["$props"] = attrs page.Attrs = attrs } @@ -195,7 +197,10 @@ func (page *Page) parse(doc *goquery.Document, option *BuildOption, warnings []s } val := attr.Val if page.Attrs != nil { - parentProps := Data{"$prop": page.Attrs} + parentProps := Data{ + "$prop": page.Attrs, // Will be deprecated use $props instead + "$props": page.Attrs, + } val, _ = parentProps.ReplaceUse(slotRe, val) } attrs[attr.Key] = val diff --git a/widgets/component/component.go b/widgets/component/component.go index c0274248..4d0a36f0 100644 --- a/widgets/component/component.go +++ b/widgets/component/component.go @@ -27,6 +27,11 @@ func (dsl DSL) Map() map[string]interface{} { "type": dsl.Type, "props": map[string]interface{}(dsl.Props), } + + if dsl.HideLabel { + res["hideLabel"] = true + } + if dsl.Bind != "" { res["bind"] = dsl.Bind } diff --git a/widgets/component/types.go b/widgets/component/types.go index c05c38c5..c2df429a 100644 --- a/widgets/component/types.go +++ b/widgets/component/types.go @@ -2,10 +2,11 @@ package component // DSL the component DSL type DSL struct { - Bind string `json:"bind,omitempty"` - Type string `json:"type,omitempty"` - Compute *Compute `json:"compute,omitempty"` - Props PropsDSL `json:"props,omitempty"` + Bind string `json:"bind,omitempty"` + HideLabel bool `json:"hideLabel,omitempty"` + Type string `json:"type,omitempty"` + Compute *Compute `json:"compute,omitempty"` + Props PropsDSL `json:"props,omitempty"` } // Actions the actions diff --git a/widgets/field/column.go b/widgets/field/column.go index 00346cf7..eef798c3 100644 --- a/widgets/field/column.go +++ b/widgets/field/column.go @@ -112,6 +112,10 @@ func (column ColumnDSL) Map() map[string]interface{} { "bind": column.Bind, } + if column.HideLabel { + res["hideLabel"] = true + } + if column.Data != nil { res["data"] = map[string]interface{}{"process": column.Data.Process, "query": column.Data.Query} } diff --git a/widgets/field/types.go b/widgets/field/types.go index 58fd1daa..10f5b958 100644 --- a/widgets/field/types.go +++ b/widgets/field/types.go @@ -18,13 +18,14 @@ type CloudProps map[string]component.CloudPropsDSL // ColumnDSL the field column dsl type ColumnDSL struct { - ID string `json:"id,omitempty"` - Data *component.CloudPropsDSL `json:"$data,omitempty"` - Key string `json:"key,omitempty"` - Bind string `json:"bind,omitempty"` - Link string `json:"link,omitempty"` - View *component.DSL `json:"view,omitempty"` - Edit *component.DSL `json:"edit,omitempty"` + ID string `json:"id,omitempty"` + Data *component.CloudPropsDSL `json:"$data,omitempty"` + Key string `json:"key,omitempty"` + Bind string `json:"bind,omitempty"` + Link string `json:"link,omitempty"` + HideLabel bool `json:"hideLabel,omitempty"` + View *component.DSL `json:"view,omitempty"` + Edit *component.DSL `json:"edit,omitempty"` } type aliasColumnDSL ColumnDSL diff --git a/widgets/form/form.go b/widgets/form/form.go index 5a4e46d3..58ae07b4 100644 --- a/widgets/form/form.go +++ b/widgets/form/form.go @@ -264,15 +264,24 @@ func (dsl *DSL) Xgen(data map[string]interface{}, excludes map[string]bool) (map return nil, err } - // full width default value - if _, has := dsl.Config["full"]; !has { - dsl.Config["full"] = true + // ** WARNING ** + // set the full configuration by default + // Temporary solution, Will be removed in the future + // should be set when the list is created + config := map[string]interface{}{} + if dsl.Config != nil { + for key, value := range dsl.Config { + config[key] = value + } + } + if _, has := config["full"]; !has { + config["full"] = true } // Merge the layout config if layout.Config != nil { for key, value := range layout.Config { - dsl.Config[key] = value + config[key] = value } } @@ -289,7 +298,7 @@ func (dsl *DSL) Xgen(data map[string]interface{}, excludes map[string]bool) (map onChange := map[string]interface{}{} // Hooks setting["fields"] = fields - setting["config"] = dsl.Config + setting["config"] = config for _, cProp := range dsl.CProps { err := cProp.Replace(setting, func(cProp component.CloudPropsDSL) interface{} { diff --git a/widgets/list/list.go b/widgets/list/list.go index 3eab15ab..e76112e7 100644 --- a/widgets/list/list.go +++ b/widgets/list/list.go @@ -219,9 +219,18 @@ func (dsl *DSL) Xgen(data map[string]interface{}, excludes map[string]bool, quer return nil, err } - // full width default value - if _, has := dsl.Config["full"]; !has { - dsl.Config["full"] = true + // ** WARNING ** + // set the full configuration by default + // Temporary solution, Will be removed in the future + // should be set when the list is created + config := map[string]interface{}{} + if dsl.Config != nil { + for key, value := range dsl.Config { + config[key] = value + } + } + if _, has := config["full"]; !has { + config["full"] = true } setting := map[string]interface{}{} @@ -237,7 +246,7 @@ func (dsl *DSL) Xgen(data map[string]interface{}, excludes map[string]bool, quer onChange := map[string]interface{}{} // Hooks setting["fields"] = fields - setting["config"] = dsl.Config + setting["config"] = config replacements := maps.Map{} if query != nil {