Apply multilingual support
This commit is contained in:
parent
26e5b18a5d
commit
d060968b7a
15 changed files with 2346 additions and 217 deletions
2
UI
2
UI
|
@ -1 +1 @@
|
|||
Subproject commit d457b64e2656febd680e92b974a14776edfa2a7f
|
||||
Subproject commit a6074812f4dc40424cf6468e47d98eb8a26f9d58
|
|
@ -35,7 +35,7 @@ func installSyncthing(appId string) {
|
|||
m := model.CustomizationPostData{}
|
||||
var dockerImage string
|
||||
var dockerImageVersion string
|
||||
appInfo = service.MyService.OAPI().GetServerAppInfo(appId, "system")
|
||||
appInfo = service.MyService.OAPI().GetServerAppInfo(appId, "system", "us_en")
|
||||
dockerImage = appInfo.Image
|
||||
dockerImageVersion = appInfo.ImageVersion
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ func AppList(c *gin.Context) {
|
|||
t := c.DefaultQuery("type", "rank")
|
||||
categoryId := c.DefaultQuery("category_id", "0")
|
||||
key := c.DefaultQuery("key", "")
|
||||
recommend, list, community := service.MyService.OAPI().GetServerList(index, size, t, categoryId, key)
|
||||
language := c.GetHeader("Language")
|
||||
recommend, list, community := service.MyService.OAPI().GetServerList(index, size, t, categoryId, key, language)
|
||||
// for i := 0; i < len(recommend); i++ {
|
||||
// ct, _ := service.MyService.Docker().DockerListByImage(recommend[i].Image, recommend[i].ImageVersion)
|
||||
// if ct != nil {
|
||||
|
@ -137,7 +138,8 @@ func AppUsageList(c *gin.Context) {
|
|||
func AppInfo(c *gin.Context) {
|
||||
|
||||
id := c.Param("id")
|
||||
info := service.MyService.OAPI().GetServerAppInfo(id, "")
|
||||
language := c.GetHeader("Language")
|
||||
info := service.MyService.OAPI().GetServerAppInfo(id, "", language)
|
||||
if info.NetworkModel != "host" {
|
||||
for i := 0; i < len(info.Ports); i++ {
|
||||
if p, _ := strconv.Atoi(info.Ports[i].ContainerPort); port2.IsPortAvailable(p, info.Ports[i].Protocol) {
|
||||
|
|
|
@ -82,7 +82,7 @@ func GetDiskList(c *gin.Context) {
|
|||
continue
|
||||
}
|
||||
|
||||
if list[i].Tran == "sata" {
|
||||
if list[i].Tran == "sata" || list[i].Tran == "nvme" {
|
||||
temp := service.MyService.Disk().SmartCTL(list[i].Path)
|
||||
if reflect.DeepEqual(temp, model.SmartctlA{}) {
|
||||
continue
|
||||
|
|
|
@ -145,6 +145,7 @@ func SpeedPush(c *gin.Context) {
|
|||
// @Router /app/install/{id} [post]
|
||||
func InstallApp(c *gin.Context) {
|
||||
appId := c.Param("id")
|
||||
language := c.GetHeader("Language")
|
||||
var appInfo model.ServerAppList
|
||||
m := model.CustomizationPostData{}
|
||||
c.BindJSON(&m)
|
||||
|
@ -174,7 +175,7 @@ func InstallApp(c *gin.Context) {
|
|||
dockerImageVersion = "latest"
|
||||
}
|
||||
if m.Origin != "custom" {
|
||||
appInfo = service.MyService.OAPI().GetServerAppInfo(appId, "")
|
||||
appInfo = service.MyService.OAPI().GetServerAppInfo(appId, "", language)
|
||||
|
||||
} else {
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ func Info(c *gin.Context) {
|
|||
findSystem += 1
|
||||
continue
|
||||
}
|
||||
if list[i].Tran == "sata" {
|
||||
if list[i].Tran == "sata" || list[i].Tran == "nvme" {
|
||||
temp := service.MyService.Disk().SmartCTL(list[i].Path)
|
||||
if reflect.DeepEqual(temp, model.SmartctlA{}) {
|
||||
continue
|
||||
|
|
|
@ -2,12 +2,13 @@ package v1
|
|||
|
||||
import (
|
||||
json2 "encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
oasis_err2 "github.com/IceWhaleTech/CasaOS/pkg/utils/oasis_err"
|
||||
"github.com/IceWhaleTech/CasaOS/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// @Summary 登录zerotier获取token
|
||||
|
@ -432,11 +433,17 @@ func ZeroTierDeleteNetwork(c *gin.Context) {
|
|||
// @Router /zerotier/join/{id} [post]
|
||||
func ZeroTierJoinNetwork(c *gin.Context) {
|
||||
networkId := c.Param("id")
|
||||
service.MyService.ZeroTier().ZeroTierJoinNetwork(networkId)
|
||||
if len(networkId) == 0 {
|
||||
if len(networkId) != 16 {
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.INVALID_PARAMS, Message: oasis_err2.GetMsg(oasis_err2.INVALID_PARAMS)})
|
||||
return
|
||||
}
|
||||
for _, v := range networkId {
|
||||
if !service.MyService.ZeroTier().NetworkIdFilter(v) {
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.INVALID_PARAMS, Message: oasis_err2.GetMsg(oasis_err2.INVALID_PARAMS)})
|
||||
return
|
||||
}
|
||||
}
|
||||
service.MyService.ZeroTier().ZeroTierJoinNetwork(networkId)
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS)})
|
||||
}
|
||||
|
||||
|
@ -450,10 +457,19 @@ func ZeroTierJoinNetwork(c *gin.Context) {
|
|||
// @Router /zerotier/leave/{id} [post]
|
||||
func ZeroTierLeaveNetwork(c *gin.Context) {
|
||||
networkId := c.Param("id")
|
||||
service.MyService.ZeroTier().ZeroTierLeaveNetwork(networkId)
|
||||
if len(networkId) == 0 {
|
||||
|
||||
if len(networkId) != 16 {
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.INVALID_PARAMS, Message: oasis_err2.GetMsg(oasis_err2.INVALID_PARAMS)})
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range networkId {
|
||||
if !service.MyService.ZeroTier().NetworkIdFilter(v) {
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.INVALID_PARAMS, Message: oasis_err2.GetMsg(oasis_err2.INVALID_PARAMS)})
|
||||
return
|
||||
}
|
||||
}
|
||||
service.MyService.ZeroTier().ZeroTierLeaveNetwork(networkId)
|
||||
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS)})
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@ import (
|
|||
)
|
||||
|
||||
type CasaService interface {
|
||||
GetServerList(index, size, tp, categoryId, key string) (recommend, list, community []model.ServerAppList)
|
||||
GetServerList(index, size, tp, categoryId, key, language string) (recommend, list, community []model.ServerAppList)
|
||||
GetServerCategoryList() []model.ServerCategoryList
|
||||
GetTaskList(size int) []model2.TaskDBModel
|
||||
GetServerAppInfo(id, t string) model.ServerAppList
|
||||
GetServerAppInfo(id, t string, language string) model.ServerAppList
|
||||
ShareAppFile(body []byte) string
|
||||
}
|
||||
|
||||
|
@ -45,9 +45,9 @@ func (o *casaService) GetTaskList(size int) []model2.TaskDBModel {
|
|||
return list
|
||||
}
|
||||
|
||||
func (o *casaService) GetServerList(index, size, tp, categoryId, key string) (recommend, list, community []model.ServerAppList) {
|
||||
func (o *casaService) GetServerList(index, size, tp, categoryId, key, language string) (recommend, list, community []model.ServerAppList) {
|
||||
|
||||
keyName := fmt.Sprintf("list_%s_%s_%s_%s", index, size, tp, categoryId)
|
||||
keyName := fmt.Sprintf("list_%s_%s_%s_%s_%s", index, size, tp, categoryId, language)
|
||||
|
||||
if result, ok := Cache.Get(keyName); ok {
|
||||
res, ok := result.(string)
|
||||
|
@ -63,7 +63,7 @@ func (o *casaService) GetServerList(index, size, tp, categoryId, key string) (re
|
|||
|
||||
head["Authorization"] = GetToken()
|
||||
|
||||
listS := httper2.Get(config.ServerInfo.ServerApi+"/v2/app/newlist?index="+index+"&size="+size+"&rank="+tp+"&category_id="+categoryId+"&key="+key, head)
|
||||
listS := httper2.Get(config.ServerInfo.ServerApi+"/v2/app/newlist?index="+index+"&size="+size+"&rank="+tp+"&category_id="+categoryId+"&key="+key+"&language="+language, head)
|
||||
|
||||
json2.Unmarshal([]byte(gjson.Get(listS, "data.list").String()), &list)
|
||||
json2.Unmarshal([]byte(gjson.Get(listS, "data.recommend").String()), &recommend)
|
||||
|
@ -88,12 +88,12 @@ func (o *casaService) GetServerCategoryList() []model.ServerCategoryList {
|
|||
|
||||
return list
|
||||
}
|
||||
func (o *casaService) GetServerAppInfo(id, t string) model.ServerAppList {
|
||||
func (o *casaService) GetServerAppInfo(id, t string, language string) model.ServerAppList {
|
||||
|
||||
head := make(map[string]string)
|
||||
|
||||
head["Authorization"] = GetToken()
|
||||
infoS := httper2.Get(config.ServerInfo.ServerApi+"/v2/app/info/"+id+"?t="+t, head)
|
||||
infoS := httper2.Get(config.ServerInfo.ServerApi+"/v2/app/info/"+id+"?t="+t+"&language="+language, head)
|
||||
|
||||
info := model.ServerAppList{}
|
||||
json2.Unmarshal([]byte(gjson.Get(infoS, "data").String()), &info)
|
||||
|
|
|
@ -4,18 +4,20 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
command2 "github.com/IceWhaleTech/CasaOS/pkg/utils/command"
|
||||
httper2 "github.com/IceWhaleTech/CasaOS/pkg/utils/httper"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/zerotier"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/tidwall/gjson"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
command2 "github.com/IceWhaleTech/CasaOS/pkg/utils/command"
|
||||
httper2 "github.com/IceWhaleTech/CasaOS/pkg/utils/httper"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/zerotier"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
type ZeroTierService interface {
|
||||
|
@ -33,6 +35,7 @@ type ZeroTierService interface {
|
|||
DeleteMember(token string, id, mId string) interface{}
|
||||
DeleteNetwork(token, id string) interface{}
|
||||
GetJoinNetworks() string
|
||||
NetworkIdFilter(letter rune) bool
|
||||
}
|
||||
type zerotierStruct struct {
|
||||
}
|
||||
|
@ -333,6 +336,13 @@ func (c *zerotierStruct) GetJoinNetworks() string {
|
|||
return json
|
||||
}
|
||||
|
||||
func (c *zerotierStruct) NetworkIdFilter(letter rune) bool {
|
||||
if unicode.IsNumber(letter) || unicode.IsLetter(letter) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
func NewZeroTierService() ZeroTierService {
|
||||
//初始化client
|
||||
client = http.Client{Timeout: 30 * time.Second, CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package types
|
||||
|
||||
const CURRENTVERSION = "0.2.6"
|
||||
const CURRENTVERSION = "0.2.7"
|
||||
|
||||
const BODY = "<li>Fix a disk that cannot be formatted under certain circumstances</li><li>Add a bug report panel.</li>"
|
||||
const BODY = "<li>Apply multilingual support</li><li>Fix a security vulnerability</li>"
|
||||
|
|
292
web/js/2.js
292
web/js/2.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
10
web/js/4.js
10
web/js/4.js
File diff suppressed because one or more lines are too long
108
web/js/app.js
108
web/js/app.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue