diff --git a/README.md b/README.md
index 41335599..3cc1524a 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,17 @@
+## 自定义部分
+
+[x] 当用户充值达到5刀时,自动提升为vip分组,具体金额可在`web\src\pages\TopUp\index.js`调整;
+[x] 修改颜色
+[x] 日志页面新增快速筛选日期、修复渠道ID查询、自动更新消耗额度、删除日志详情(因为没有太大意义);
+[x] 用户管理界面,支持快速设置用户组,在`web\src\components\UsersTable.js`处修改相关值;
+[x] 令牌界面,删除无用的多种复制、聊天等按钮;
+[x] 删除 系统访问令牌;
+[ ] 在个人设置页面显示分组;
+[ ] 渠道管理处,已启用渠道和禁用渠道, 启用/禁用 按钮改为不同颜色;
+
+[x] 等
+
+---
中文 | English | 日本語
diff --git a/controller/user.go b/controller/user.go
index 8fd10b82..59e50017 100644
--- a/controller/user.go
+++ b/controller/user.go
@@ -7,7 +7,6 @@ import (
"one-api/common"
"one-api/model"
"strconv"
-
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
)
@@ -554,10 +553,128 @@ func CreateUser(c *gin.Context) {
type ManageRequest struct {
Username string `json:"username"`
- Action string `json:"action"`
+ NewGroup string `json:"newGroup"`
}
// ManageUser Only admin user can do this
+// func ManageUser(c *gin.Context) {
+// var req ManageRequest
+// err := json.NewDecoder(c.Request.Body).Decode(&req)
+
+// if err != nil {
+// c.JSON(http.StatusOK, gin.H{
+// "success": false,
+// "message": "无效的参数",
+// })
+// return
+// }
+// user := model.User{
+// Username: req.Username,
+// }
+// // Fill attributes
+// model.DB.Where(&user).First(&user)
+// if user.Id == 0 {
+// c.JSON(http.StatusOK, gin.H{
+// "success": false,
+// "message": "用户不存在",
+// })
+// return
+// }
+// myRole := c.GetInt("role")
+// if myRole <= user.Role && myRole != common.RoleRootUser {
+// c.JSON(http.StatusOK, gin.H{
+// "success": false,
+// "message": "无权更新同权限等级或更高权限等级的用户信息",
+// })
+// return
+// }
+// switch req.Action {
+// case "disable":
+// user.Status = common.UserStatusDisabled
+// if user.Role == common.RoleRootUser {
+// c.JSON(http.StatusOK, gin.H{
+// "success": false,
+// "message": "无法禁用超级管理员用户",
+// })
+// return
+// }
+// case "enable":
+// user.Status = common.UserStatusEnabled
+// case "delete":
+// if user.Role == common.RoleRootUser {
+// c.JSON(http.StatusOK, gin.H{
+// "success": false,
+// "message": "无法删除超级管理员用户",
+// })
+// return
+// }
+// if err := user.Delete(); err != nil {
+// c.JSON(http.StatusOK, gin.H{
+// "success": false,
+// "message": err.Error(),
+// })
+// return
+// }
+// case "promote":
+// if myRole != common.RoleRootUser {
+// c.JSON(http.StatusOK, gin.H{
+// "success": false,
+// "message": "普通管理员用户无法提升其他用户为管理员",
+// })
+// return
+// }
+// if user.Role >= common.RoleAdminUser {
+// c.JSON(http.StatusOK, gin.H{
+// "success": false,
+// "message": "该用户已经是管理员",
+// })
+// return
+// }
+// user.Role = common.RoleAdminUser
+// case "demote":
+// if user.Role == common.RoleRootUser {
+// c.JSON(http.StatusOK, gin.H{
+// "success": false,
+// "message": "无法降级超级管理员用户",
+// })
+// return
+// }
+// if user.Role == common.RoleCommonUser {
+// c.JSON(http.StatusOK, gin.H{
+// "success": false,
+// "message": "该用户已经是普通用户",
+// })
+// return
+// }
+// user.Role = common.RoleCommonUser
+// }
+
+// if err := user.Update(false); err != nil {
+// c.JSON(http.StatusOK, gin.H{
+// "success": false,
+// "message": err.Error(),
+// })
+// return
+// }
+
+// user.Group = req.NewGroup
+
+
+// clearUser := model.User{
+// Group: user.Group,
+// Role: user.Role,
+// Status: user.Status,
+// }
+// c.JSON(http.StatusOK, gin.H{
+// "success": true,
+// "message": "",
+// "data": clearUser,
+// })
+// return
+
+
+
+// }
func ManageUser(c *gin.Context) {
var req ManageRequest
err := json.NewDecoder(c.Request.Body).Decode(&req)
@@ -569,10 +686,11 @@ func ManageUser(c *gin.Context) {
})
return
}
+
user := model.User{
Username: req.Username,
}
- // Fill attributes
+
model.DB.Where(&user).First(&user)
if user.Id == 0 {
c.JSON(http.StatusOK, gin.H{
@@ -581,6 +699,7 @@ func ManageUser(c *gin.Context) {
})
return
}
+
myRole := c.GetInt("role")
if myRole <= user.Role && myRole != common.RoleRootUser {
c.JSON(http.StatusOK, gin.H{
@@ -589,66 +708,9 @@ func ManageUser(c *gin.Context) {
})
return
}
- switch req.Action {
- case "disable":
- user.Status = common.UserStatusDisabled
- if user.Role == common.RoleRootUser {
- c.JSON(http.StatusOK, gin.H{
- "success": false,
- "message": "无法禁用超级管理员用户",
- })
- return
- }
- case "enable":
- user.Status = common.UserStatusEnabled
- case "delete":
- if user.Role == common.RoleRootUser {
- c.JSON(http.StatusOK, gin.H{
- "success": false,
- "message": "无法删除超级管理员用户",
- })
- return
- }
- if err := user.Delete(); err != nil {
- c.JSON(http.StatusOK, gin.H{
- "success": false,
- "message": err.Error(),
- })
- return
- }
- case "promote":
- if myRole != common.RoleRootUser {
- c.JSON(http.StatusOK, gin.H{
- "success": false,
- "message": "普通管理员用户无法提升其他用户为管理员",
- })
- return
- }
- if user.Role >= common.RoleAdminUser {
- c.JSON(http.StatusOK, gin.H{
- "success": false,
- "message": "该用户已经是管理员",
- })
- return
- }
- user.Role = common.RoleAdminUser
- case "demote":
- if user.Role == common.RoleRootUser {
- c.JSON(http.StatusOK, gin.H{
- "success": false,
- "message": "无法降级超级管理员用户",
- })
- return
- }
- if user.Role == common.RoleCommonUser {
- c.JSON(http.StatusOK, gin.H{
- "success": false,
- "message": "该用户已经是普通用户",
- })
- return
- }
- user.Role = common.RoleCommonUser
- }
+
+ // 更新用户分组
+ user.Group = req.NewGroup
if err := user.Update(false); err != nil {
c.JSON(http.StatusOK, gin.H{
@@ -657,10 +719,13 @@ func ManageUser(c *gin.Context) {
})
return
}
+
clearUser := model.User{
+ Group: user.Group,
Role: user.Role,
Status: user.Status,
}
+
c.JSON(http.StatusOK, gin.H{
"success": true,
"message": "",
@@ -669,6 +734,7 @@ func ManageUser(c *gin.Context) {
return
}
+
func EmailBind(c *gin.Context) {
email := c.Query("email")
code := c.Query("code")
diff --git a/web/src/components/ChannelsTable.js b/web/src/components/ChannelsTable.js
index c072f26d..4ba5c901 100644
--- a/web/src/components/ChannelsTable.js
+++ b/web/src/components/ChannelsTable.js
@@ -30,21 +30,22 @@ function renderType(type) {
function renderBalance(type, balance) {
switch (type) {
case 1: // OpenAI
- return ${balance.toFixed(2)};
+ return ${balance.toFixed(2)};
case 4: // CloseAI
- return ¥{balance.toFixed(2)};
+ return ¥{balance.toFixed(2)};
case 8: // 自定义
- return ${balance.toFixed(2)};
+ return ${balance.toFixed(2)};
case 5: // OpenAI-SB
- return ¥{(balance / 10000).toFixed(2)};
+ return ¥{(balance / 10000).toFixed(2)};
case 10: // AI Proxy
- return {renderNumber(balance)};
+ return {renderNumber(balance)};
case 12: // API2GPT
- return ¥{balance.toFixed(2)};
+ return ¥{balance.toFixed(2)};
case 13: // AIGC2D
- return {renderNumber(balance)};
+ return {renderNumber(balance)};
default:
- return 不支持;
+ return 不支持;
+
}
}
@@ -150,11 +151,11 @@ const ChannelsTable = () => {
const renderStatus = (status) => {
switch (status) {
case 1:
- return ;
+ return ;
case 2:
return (
+ trigger={}
content='本渠道被手动禁用'
@@ -164,7 +165,7 @@ const ChannelsTable = () => {
case 3:
return (
+ trigger={}
content='本渠道被程序自动禁用'
@@ -173,10 +174,11 @@ const ChannelsTable = () => {
);
default:
return (
-