i18n: Translate all Chinese to English across the codebase
Translate Chinese comments, log/error messages, validator labels and Swagger annotations to English throughout the source code, generated Swagger docs, config files and CI workflows. Make the English README primary: README.md now holds the English docs and README_EN.md holds the Chinese version, with cross-language links updated accordingly. Note: the generated docs/ swagger files were translated in place; run `go generate ./...` (swag init) to regenerate them from the now-English annotations when a Go toolchain is available. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -6,11 +6,11 @@ import (
|
||||
"github.com/lejianwen/rustdesk-api/v2/service"
|
||||
)
|
||||
|
||||
// BackendUserAuth 后台权限验证中间件
|
||||
// BackendUserAuth backend permission verification middleware
|
||||
func BackendUserAuth() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
|
||||
//测试先关闭
|
||||
//disabled for testing
|
||||
token := c.GetHeader("api-token")
|
||||
if token == "" {
|
||||
response.Fail(c, 403, response.TranslateMsg(c, "NeedLogin"))
|
||||
@@ -34,7 +34,7 @@ func BackendUserAuth() gin.HandlerFunc {
|
||||
|
||||
c.Set("curUser", user)
|
||||
c.Set("token", token)
|
||||
//如果时间小于1天,token自动续期
|
||||
// if the remaining time is less than 1 day, the token is auto-renewed
|
||||
service.AllService.UserService.AutoRefreshAccessToken(ut)
|
||||
|
||||
c.Next()
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Cors 跨域
|
||||
// Cors CORS
|
||||
func Cors() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
origin := c.GetHeader("Origin")
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
func JwtAuth() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
//测试先关闭
|
||||
//disabled for testing
|
||||
token := c.GetHeader("api-token")
|
||||
if token == "" {
|
||||
response.Fail(c, 403, response.TranslateMsg(c, "NeedLogin"))
|
||||
@@ -31,7 +31,7 @@ func JwtAuth() gin.HandlerFunc {
|
||||
user := service.AllService.UserService.InfoById(uid)
|
||||
//user := &model.User{
|
||||
// Id: uid,
|
||||
// Username: "测试用户",
|
||||
// Username: "test user",
|
||||
//}
|
||||
if user.Id == 0 {
|
||||
response.Fail(c, 403, response.TranslateMsg(c, "NeedLogin"))
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Logger 日志中间件
|
||||
// Logger logging middleware
|
||||
func Logger() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
global.Logger.WithFields(
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
func RustAuth() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
//fmt.Println(c.Request.URL, c.Request.Header)
|
||||
//获取HTTP_AUTHORIZATION
|
||||
//getHTTP_AUTHORIZATION
|
||||
token := c.GetHeader("Authorization")
|
||||
if token == "" {
|
||||
c.JSON(401, gin.H{
|
||||
@@ -25,13 +25,13 @@ func RustAuth() gin.HandlerFunc {
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
//提取token,格式是Bearer {token}
|
||||
//这里只是简单的提取
|
||||
//extracttoken, format is Bearer {token}
|
||||
//this is just a simple extraction
|
||||
token = token[7:]
|
||||
|
||||
//验证token
|
||||
// verify the token
|
||||
|
||||
//检查是否设置了jwt key
|
||||
//check whether it is set jwt key
|
||||
if len(global.Jwt.Key) > 0 {
|
||||
uid, _ := service.AllService.UserService.VerifyJWT(token)
|
||||
if uid == 0 {
|
||||
|
||||
Reference in New Issue
Block a user