mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
feat: enhance template configuration and update README for translation status
This commit is contained in:
parent
8f8a30c02c
commit
06738d5d16
@ -26,6 +26,10 @@
|
||||
|
||||
### Translation
|
||||
|
||||
<a href="https://hosted.weblate.org/engage/nezha/">
|
||||
<img src="https://hosted.weblate.org/widget/nezha/multi-blue.svg" alt="Translation status" />
|
||||
</a>
|
||||
|
||||
Is Nezha not in your language, or the translation is incorrect or incomplete? Get involved in the translations on [Hosted Weblate](https://hosted.weblate.org/engage/nezha/).
|
||||
|
||||
## Screenshots
|
||||
@ -35,6 +39,8 @@ Is Nezha not in your language, or the translation is incorrect or incomplete? Ge
|
||||
| ![user](.github/user-frontend.20241128.png) | ![admin](.github/admin-frontend.20241128.png) |
|
||||
| [hamster1963/nezha-dash](https://github.com/hamster1963/nezha-dash) | [nezhahq/admin-frontend](https://github.com/nezhahq/admin-frontend) |
|
||||
|
||||
add your theme to [service/singleton/frontend-templates.yaml](service/singleton/frontend-templates.yaml)
|
||||
|
||||
## Contributors
|
||||
|
||||
<!--GAMFC_DELIMITER--><a href="https://github.com/naiba" title="naiba"><img src="https://avatars.githubusercontent.com/u/29243953?v=4" width="50;" alt="naiba"/></a>
|
||||
|
@ -240,11 +240,11 @@ func fallbackToFrontend(frontendDist fs.FS) func(*gin.Context) {
|
||||
}
|
||||
if strings.HasPrefix(c.Request.URL.Path, "/dashboard") {
|
||||
stripPath := strings.TrimPrefix(c.Request.URL.Path, "/dashboard")
|
||||
localFilePath := path.Join("admin-dist", stripPath)
|
||||
localFilePath := path.Join(singleton.Conf.AdminTemplate, stripPath)
|
||||
if checkLocalFileOrFs(c, frontendDist, localFilePath) {
|
||||
return
|
||||
}
|
||||
if !checkLocalFileOrFs(c, frontendDist, "admin-dist/index.html") {
|
||||
if !checkLocalFileOrFs(c, frontendDist, singleton.Conf.AdminTemplate+"/index.html") {
|
||||
c.JSON(http.StatusOK, newErrorResponse(errors.New("404 Not Found")))
|
||||
}
|
||||
return
|
||||
|
@ -60,8 +60,10 @@ func updateConfig(c *gin.Context) (any, error) {
|
||||
}
|
||||
var userTemplateValid bool
|
||||
for _, v := range singleton.FrontendTemplates {
|
||||
if v.Path == sf.UserTemplate && sf.UserTemplate != "admin-dist" {
|
||||
if !userTemplateValid && v.Path == sf.UserTemplate && !v.IsAdmin {
|
||||
userTemplateValid = true
|
||||
}
|
||||
if userTemplateValid {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ type Config struct {
|
||||
Language string `mapstructure:"language" json:"language"` // 系统语言,默认 zh_CN
|
||||
SiteName string `mapstructure:"site_name" json:"site_name"`
|
||||
UserTemplate string `mapstructure:"user_template" json:"user_template,omitempty"`
|
||||
AdminTemplate string `mapstructure:"admin_template" json:"admin_template,omitempty"`
|
||||
JWTSecretKey string `mapstructure:"jwt_secret_key" json:"jwt_secret_key,omitempty"`
|
||||
AgentSecretKey string `mapstructure:"agent_secret_key" json:"agent_secret_key,omitempty"`
|
||||
ListenPort uint `mapstructure:"listen_port" json:"listen_port,omitempty"`
|
||||
@ -88,16 +89,24 @@ func (c *Config) Read(path string, frontendTemplates []FrontendTemplate) error {
|
||||
if c.Location == "" {
|
||||
c.Location = "Asia/Shanghai"
|
||||
}
|
||||
var userTemplateValid bool
|
||||
var userTemplateValid, adminTemplateValid bool
|
||||
for _, v := range frontendTemplates {
|
||||
if v.Path == c.UserTemplate && c.UserTemplate != "admin-dist" {
|
||||
if !userTemplateValid && v.Path == c.UserTemplate && !v.IsAdmin {
|
||||
userTemplateValid = true
|
||||
}
|
||||
if !adminTemplateValid && v.Path == c.AdminTemplate && v.IsAdmin {
|
||||
adminTemplateValid = true
|
||||
}
|
||||
if userTemplateValid && adminTemplateValid {
|
||||
break
|
||||
}
|
||||
}
|
||||
if c.UserTemplate == "" || !userTemplateValid {
|
||||
c.UserTemplate = "user-dist"
|
||||
}
|
||||
if c.AdminTemplate == "" || !adminTemplateValid {
|
||||
c.AdminTemplate = "admin-dist"
|
||||
}
|
||||
if c.AvgPingCount == 0 {
|
||||
c.AvgPingCount = 2
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ type FrontendTemplate struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Repository string `json:"repository,omitempty"`
|
||||
Author string `json:"author,omitempty"`
|
||||
Community bool `json:"community,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
IsAdmin string `json:"is_admin,omitempty"`
|
||||
IsAdmin bool `json:"is_admin,omitempty"`
|
||||
IsOfficial bool `json:"is_official,omitempty"`
|
||||
}
|
||||
|
||||
type SettingResponse struct {
|
||||
|
@ -2,16 +2,17 @@
|
||||
name: "OfficialAdmin"
|
||||
repository: "https://github.com/nezhahq/admin-frontend"
|
||||
author: "nezhahq"
|
||||
version: "v1.1.1"
|
||||
version: "v1.1.3"
|
||||
isadmin: true
|
||||
isofficial: true
|
||||
- path: "user-dist"
|
||||
name: "Official"
|
||||
repository: "https://github.com/hamster1963/nezha-dash-v1"
|
||||
author: "hamster1963"
|
||||
version: "v1.2.5"
|
||||
isofficial: true
|
||||
- path: "nazhua-dist"
|
||||
name: "Nazhua"
|
||||
repository: "https://github.com/hi2shark/nazhua"
|
||||
author: "hi2hi"
|
||||
version: "v0.4.10"
|
||||
community: true
|
||||
version: "v0.4.13"
|
||||
|
Loading…
Reference in New Issue
Block a user