fix LoadLang bug
This commit is contained in:
parent
9b604ec846
commit
05f4596dea
4 changed files with 14 additions and 7 deletions
2
.github/workflows/unit-test.yml
vendored
2
.github/workflows/unit-test.yml
vendored
|
|
@ -17,6 +17,8 @@ env:
|
|||
YAO_LOG_MODE: "TEXT"
|
||||
YAO_JWT_SECRET: "bLp@bi!oqo-2U+hoTRUG"
|
||||
YAO_DB_AESKEY: "ZLX=T&f6refeCh-ro*r@"
|
||||
OSS_TEST_ID: ${{ secrets.OSS_TEST_ID}}
|
||||
OSS_TEST_SECRET: ${{ secrets.OSS_TEST_SECRET}}
|
||||
ROOT_PLUGIN: ${{ github.WORKSPACE }}/../../../data/gou-unit/plugins
|
||||
|
||||
jobs:
|
||||
|
|
|
|||
11
app/app.go
11
app/app.go
|
|
@ -114,18 +114,21 @@ func LoadLang(cfg config.Config) error {
|
|||
|
||||
var defaults = []share.Script{}
|
||||
if os.Getenv("YAO_DEV") != "" {
|
||||
defaults = share.GetFilesFS(filepath.Join(os.Getenv("YAO_DEV"), "xiang", "langs"), ".json")
|
||||
defaults = share.GetFilesFS(filepath.Join(os.Getenv("YAO_DEV"), "xiang"), ".json")
|
||||
} else {
|
||||
defaults = share.GetFilesBin("/xiang/langs", ".json")
|
||||
defaults = share.GetFilesBin("xiang", ".json")
|
||||
}
|
||||
|
||||
for _, lang := range defaults {
|
||||
if lang.Type != "langs" {
|
||||
continue
|
||||
}
|
||||
content := lang.Content
|
||||
name := strings.ToLower(lang.Type) // 这个读取函数需要优化
|
||||
name := strings.ToLower(lang.Name) // 这个读取函数需要优化
|
||||
lang := map[string]string{}
|
||||
err := jsoniter.Unmarshal(content, &lang)
|
||||
if err != nil {
|
||||
log.With(log.F{"name": name, "content": content}).Error(err.Error())
|
||||
log.With(log.F{"name": name}).Error(err.Error())
|
||||
}
|
||||
langs[name] = lang
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/yaoapp/gou/helper"
|
||||
"github.com/yaoapp/kun/exception"
|
||||
"github.com/yaoapp/kun/log"
|
||||
"github.com/yaoapp/kun/maps"
|
||||
"github.com/yaoapp/yao/config"
|
||||
"github.com/yaoapp/yao/share"
|
||||
)
|
||||
|
|
@ -72,7 +73,7 @@ func LoadTable(source string, name string) (*Table, error) {
|
|||
}
|
||||
err := helper.UnmarshalFile(input, &table)
|
||||
if err != nil {
|
||||
exception.Err(err, 400).Throw()
|
||||
exception.Err(err, 400).Ctx(maps.Map{"name": name}).Throw()
|
||||
}
|
||||
|
||||
table.loadColumns()
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package xfs
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -19,8 +20,8 @@ func init() {
|
|||
Default: "oss",
|
||||
OSS: &share.AppStorageOSS{
|
||||
Endpoint: "oss-cn-hangzhou.aliyuncs.com",
|
||||
ID: "LTAI5tHXfWAMpcsobfqfeXsm",
|
||||
Secret: "4NeGNw97nFrfmgBWZTlFE0XtYQdMQO",
|
||||
ID: os.Getenv("OSS_TEST_ID"),
|
||||
Secret: os.Getenv("OSS_TEST_SECRET"),
|
||||
RoleArn: "acs:ram::31524094:role/ramosstest",
|
||||
SessionName: "SessionTest",
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue