2023-04-22 20:39:27 +08:00
|
|
|
package router
|
|
|
|
|
|
|
|
|
|
import (
|
2023-04-22 21:14:09 +08:00
|
|
|
"one-api/controller"
|
|
|
|
|
"one-api/middleware"
|
2023-07-15 12:41:21 +08:00
|
|
|
|
|
|
|
|
"github.com/gin-contrib/gzip"
|
|
|
|
|
"github.com/gin-gonic/gin"
|
2023-04-22 20:39:27 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func SetApiRouter(router *gin.Engine) {
|
|
|
|
|
apiRouter := router.Group("/api")
|
2023-04-25 21:56:07 +08:00
|
|
|
apiRouter.Use(gzip.Gzip(gzip.DefaultCompression))
|
2023-04-22 20:39:27 +08:00
|
|
|
apiRouter.Use(middleware.GlobalAPIRateLimit())
|
|
|
|
|
{
|
2025-04-03 18:57:15 +08:00
|
|
|
apiRouter.GET("/setup", controller.GetSetup)
|
|
|
|
|
apiRouter.POST("/setup", controller.PostSetup)
|
2023-04-22 20:39:27 +08:00
|
|
|
apiRouter.GET("/status", controller.GetStatus)
|
2025-06-11 02:28:36 +08:00
|
|
|
apiRouter.GET("/uptime/status", controller.GetUptimeKumaStatus)
|
2024-05-12 19:07:33 +08:00
|
|
|
apiRouter.GET("/models", middleware.UserAuth(), controller.DashboardListModels)
|
2024-03-04 19:32:59 +08:00
|
|
|
apiRouter.GET("/status/test", middleware.AdminAuth(), controller.TestStatus)
|
2023-04-22 20:39:27 +08:00
|
|
|
apiRouter.GET("/notice", controller.GetNotice)
|
|
|
|
|
apiRouter.GET("/about", controller.GetAbout)
|
2024-03-23 19:09:09 +08:00
|
|
|
//apiRouter.GET("/midjourney", controller.GetMidjourney)
|
2023-05-13 21:27:49 +08:00
|
|
|
apiRouter.GET("/home_page_content", controller.GetHomePageContent)
|
2024-05-15 23:56:26 +08:00
|
|
|
apiRouter.GET("/pricing", middleware.TryUserAuth(), controller.GetPricing)
|
2025-08-10 21:22:53 +08:00
|
|
|
apiRouter.GET("/verification", middleware.EmailVerificationRateLimit(), middleware.TurnstileCheck(), controller.SendEmailVerification)
|
2023-04-22 20:39:27 +08:00
|
|
|
apiRouter.GET("/reset_password", middleware.CriticalRateLimit(), middleware.TurnstileCheck(), controller.SendPasswordResetEmail)
|
|
|
|
|
apiRouter.POST("/user/reset", middleware.CriticalRateLimit(), controller.ResetPassword)
|
|
|
|
|
apiRouter.GET("/oauth/github", middleware.CriticalRateLimit(), controller.GitHubOAuth)
|
2025-02-28 15:18:03 +08:00
|
|
|
apiRouter.GET("/oauth/oidc", middleware.CriticalRateLimit(), controller.OidcAuth)
|
2024-11-10 23:56:22 +08:00
|
|
|
apiRouter.GET("/oauth/linuxdo", middleware.CriticalRateLimit(), controller.LinuxdoOAuth)
|
2023-09-15 00:24:20 +08:00
|
|
|
apiRouter.GET("/oauth/state", middleware.CriticalRateLimit(), controller.GenerateOAuthCode)
|
2023-04-22 20:39:27 +08:00
|
|
|
apiRouter.GET("/oauth/wechat", middleware.CriticalRateLimit(), controller.WeChatAuth)
|
2024-12-27 18:32:11 +08:00
|
|
|
apiRouter.GET("/oauth/wechat/bind", middleware.CriticalRateLimit(), controller.WeChatBind)
|
|
|
|
|
apiRouter.GET("/oauth/email/bind", middleware.CriticalRateLimit(), controller.EmailBind)
|
2024-03-02 17:15:52 +08:00
|
|
|
apiRouter.GET("/oauth/telegram/login", middleware.CriticalRateLimit(), controller.TelegramLogin)
|
2024-12-27 18:32:11 +08:00
|
|
|
apiRouter.GET("/oauth/telegram/bind", middleware.CriticalRateLimit(), controller.TelegramBind)
|
2025-06-19 08:57:34 +08:00
|
|
|
apiRouter.GET("/ratio_config", middleware.CriticalRateLimit(), controller.GetRatioConfig)
|
2023-04-22 20:39:27 +08:00
|
|
|
|
2025-07-10 16:29:38 +08:00
|
|
|
apiRouter.POST("/stripe/webhook", controller.StripeWebhook)
|
2023-04-22 20:39:27 +08:00
|
|
|
|
|
|
|
|
userRoute := apiRouter.Group("/user")
|
|
|
|
|
{
|
|
|
|
|
userRoute.POST("/register", middleware.CriticalRateLimit(), middleware.TurnstileCheck(), controller.Register)
|
2023-11-06 22:11:05 +08:00
|
|
|
userRoute.POST("/login", middleware.CriticalRateLimit(), middleware.TurnstileCheck(), controller.Login)
|
2025-08-02 14:53:28 +08:00
|
|
|
userRoute.POST("/login/2fa", middleware.CriticalRateLimit(), controller.Verify2FALogin)
|
2023-08-14 22:16:32 +08:00
|
|
|
//userRoute.POST("/tokenlog", middleware.CriticalRateLimit(), controller.TokenLog)
|
2023-04-22 20:39:27 +08:00
|
|
|
userRoute.GET("/logout", controller.Logout)
|
2023-08-14 22:16:32 +08:00
|
|
|
userRoute.GET("/epay/notify", controller.EpayNotify)
|
2024-09-18 05:19:10 +08:00
|
|
|
userRoute.GET("/groups", controller.GetUserGroups)
|
2023-04-22 20:39:27 +08:00
|
|
|
|
|
|
|
|
selfRoute := userRoute.Group("/")
|
2023-04-23 18:24:11 +08:00
|
|
|
selfRoute.Use(middleware.UserAuth())
|
2023-04-22 20:39:27 +08:00
|
|
|
{
|
2024-10-14 16:15:10 +08:00
|
|
|
selfRoute.GET("/self/groups", controller.GetUserGroups)
|
2023-04-22 20:39:27 +08:00
|
|
|
selfRoute.GET("/self", controller.GetSelf)
|
2023-11-21 16:35:51 +08:00
|
|
|
selfRoute.GET("/models", controller.GetUserModels)
|
2023-04-22 20:39:27 +08:00
|
|
|
selfRoute.PUT("/self", controller.UpdateSelf)
|
2023-08-06 22:28:07 +08:00
|
|
|
selfRoute.DELETE("/self", controller.DeleteSelf)
|
2023-04-26 20:54:39 +08:00
|
|
|
selfRoute.GET("/token", controller.GenerateAccessToken)
|
2023-06-17 18:12:58 +08:00
|
|
|
selfRoute.GET("/aff", controller.GetAffCode)
|
2025-07-10 16:29:38 +08:00
|
|
|
selfRoute.POST("/topup", middleware.CriticalRateLimit(), controller.TopUp)
|
|
|
|
|
selfRoute.POST("/pay", middleware.CriticalRateLimit(), controller.RequestEpay)
|
2023-08-14 22:16:32 +08:00
|
|
|
selfRoute.POST("/amount", controller.RequestAmount)
|
2025-07-10 16:29:38 +08:00
|
|
|
selfRoute.POST("/stripe/pay", middleware.CriticalRateLimit(), controller.RequestStripePay)
|
|
|
|
|
selfRoute.POST("/stripe/amount", controller.RequestStripeAmount)
|
2023-11-21 16:35:51 +08:00
|
|
|
selfRoute.POST("/aff_transfer", controller.TransferAffQuota)
|
2025-02-18 14:54:21 +08:00
|
|
|
selfRoute.PUT("/setting", controller.UpdateUserSetting)
|
2025-08-10 21:22:53 +08:00
|
|
|
|
2025-08-02 14:53:28 +08:00
|
|
|
// 2FA routes
|
|
|
|
|
selfRoute.GET("/2fa/status", controller.Get2FAStatus)
|
|
|
|
|
selfRoute.POST("/2fa/setup", controller.Setup2FA)
|
|
|
|
|
selfRoute.POST("/2fa/enable", controller.Enable2FA)
|
|
|
|
|
selfRoute.POST("/2fa/disable", controller.Disable2FA)
|
|
|
|
|
selfRoute.POST("/2fa/backup_codes", controller.RegenerateBackupCodes)
|
2023-04-22 20:39:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
adminRoute := userRoute.Group("/")
|
2023-04-23 18:24:11 +08:00
|
|
|
adminRoute.Use(middleware.AdminAuth())
|
2023-04-22 20:39:27 +08:00
|
|
|
{
|
|
|
|
|
adminRoute.GET("/", controller.GetAllUsers)
|
|
|
|
|
adminRoute.GET("/search", controller.SearchUsers)
|
|
|
|
|
adminRoute.GET("/:id", controller.GetUser)
|
|
|
|
|
adminRoute.POST("/", controller.CreateUser)
|
|
|
|
|
adminRoute.POST("/manage", controller.ManageUser)
|
|
|
|
|
adminRoute.PUT("/", controller.UpdateUser)
|
|
|
|
|
adminRoute.DELETE("/:id", controller.DeleteUser)
|
2025-08-10 21:22:53 +08:00
|
|
|
|
2025-08-02 14:53:28 +08:00
|
|
|
// Admin 2FA routes
|
|
|
|
|
adminRoute.GET("/2fa/stats", controller.Admin2FAStats)
|
|
|
|
|
adminRoute.DELETE("/:id/2fa", controller.AdminDisable2FA)
|
2023-04-22 20:39:27 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
optionRoute := apiRouter.Group("/option")
|
2023-04-23 18:24:11 +08:00
|
|
|
optionRoute.Use(middleware.RootAuth())
|
2023-04-22 20:39:27 +08:00
|
|
|
{
|
|
|
|
|
optionRoute.GET("/", controller.GetOptions)
|
|
|
|
|
optionRoute.PUT("/", controller.UpdateOption)
|
2024-05-24 15:28:16 +08:00
|
|
|
optionRoute.POST("/rest_model_ratio", controller.ResetModelRatio)
|
2025-06-14 01:05:09 +08:00
|
|
|
optionRoute.POST("/migrate_console_setting", controller.MigrateConsoleSetting) // 用于迁移检测的旧键,下个版本会删除
|
2023-04-22 20:39:27 +08:00
|
|
|
}
|
2025-06-19 08:57:34 +08:00
|
|
|
ratioSyncRoute := apiRouter.Group("/ratio_sync")
|
|
|
|
|
ratioSyncRoute.Use(middleware.RootAuth())
|
|
|
|
|
{
|
|
|
|
|
ratioSyncRoute.GET("/channels", controller.GetSyncableChannels)
|
|
|
|
|
ratioSyncRoute.POST("/fetch", controller.FetchUpstreamRatios)
|
2023-04-22 20:39:27 +08:00
|
|
|
}
|
2023-04-22 22:02:59 +08:00
|
|
|
channelRoute := apiRouter.Group("/channel")
|
|
|
|
|
channelRoute.Use(middleware.AdminAuth())
|
2023-04-22 20:39:27 +08:00
|
|
|
{
|
2023-04-22 22:02:59 +08:00
|
|
|
channelRoute.GET("/", controller.GetAllChannels)
|
|
|
|
|
channelRoute.GET("/search", controller.SearchChannels)
|
2024-03-03 15:53:48 +08:00
|
|
|
channelRoute.GET("/models", controller.ChannelListModels)
|
2025-02-28 21:13:30 +08:00
|
|
|
channelRoute.GET("/models_enabled", controller.EnabledListModels)
|
2023-04-22 22:02:59 +08:00
|
|
|
channelRoute.GET("/:id", controller.GetChannel)
|
2023-05-15 12:36:55 +08:00
|
|
|
channelRoute.GET("/test", controller.TestAllChannels)
|
2023-05-15 10:48:52 +08:00
|
|
|
channelRoute.GET("/test/:id", controller.TestChannel)
|
2023-05-21 16:09:54 +08:00
|
|
|
channelRoute.GET("/update_balance", controller.UpdateAllChannelsBalance)
|
|
|
|
|
channelRoute.GET("/update_balance/:id", controller.UpdateChannelBalance)
|
2023-04-22 22:02:59 +08:00
|
|
|
channelRoute.POST("/", controller.AddChannel)
|
|
|
|
|
channelRoute.PUT("/", controller.UpdateChannel)
|
2023-10-14 17:25:48 +08:00
|
|
|
channelRoute.DELETE("/disabled", controller.DeleteDisabledChannel)
|
2024-11-19 01:13:18 +08:00
|
|
|
channelRoute.POST("/tag/disabled", controller.DisableTagChannels)
|
|
|
|
|
channelRoute.POST("/tag/enabled", controller.EnableTagChannels)
|
|
|
|
|
channelRoute.PUT("/tag", controller.EditTagChannels)
|
2023-04-22 22:02:59 +08:00
|
|
|
channelRoute.DELETE("/:id", controller.DeleteChannel)
|
2023-12-14 16:35:03 +08:00
|
|
|
channelRoute.POST("/batch", controller.DeleteChannelBatch)
|
2024-01-10 13:23:43 +08:00
|
|
|
channelRoute.POST("/fix", controller.FixChannelsAbilities)
|
2024-05-21 22:16:20 +08:00
|
|
|
channelRoute.GET("/fetch_models/:id", controller.FetchUpstreamModels)
|
2024-12-24 18:02:08 +08:00
|
|
|
channelRoute.POST("/fetch_models", controller.FetchModels)
|
2024-12-25 14:19:00 +08:00
|
|
|
channelRoute.POST("/batch/tag", controller.BatchSetChannelTag)
|
2025-06-08 01:16:27 +08:00
|
|
|
channelRoute.GET("/tag/models", controller.GetTagModels)
|
2025-07-14 21:54:53 +08:00
|
|
|
channelRoute.POST("/copy/:id", controller.CopyChannel)
|
2025-08-04 16:52:31 +08:00
|
|
|
channelRoute.POST("/multi_key/manage", controller.ManageMultiKeys)
|
2023-04-22 20:39:27 +08:00
|
|
|
}
|
2023-04-23 11:31:00 +08:00
|
|
|
tokenRoute := apiRouter.Group("/token")
|
|
|
|
|
tokenRoute.Use(middleware.UserAuth())
|
|
|
|
|
{
|
|
|
|
|
tokenRoute.GET("/", controller.GetAllTokens)
|
|
|
|
|
tokenRoute.GET("/search", controller.SearchTokens)
|
|
|
|
|
tokenRoute.GET("/:id", controller.GetToken)
|
|
|
|
|
tokenRoute.POST("/", controller.AddToken)
|
|
|
|
|
tokenRoute.PUT("/", controller.UpdateToken)
|
|
|
|
|
tokenRoute.DELETE("/:id", controller.DeleteToken)
|
2025-06-22 16:35:30 +08:00
|
|
|
tokenRoute.POST("/batch", controller.DeleteTokenBatch)
|
2023-04-23 11:31:00 +08:00
|
|
|
}
|
2025-08-23 15:45:43 +08:00
|
|
|
|
|
|
|
|
usageRoute := apiRouter.Group("/usage")
|
|
|
|
|
usageRoute.Use(middleware.CriticalRateLimit())
|
|
|
|
|
{
|
|
|
|
|
tokenUsageRoute := usageRoute.Group("/token")
|
|
|
|
|
tokenUsageRoute.Use(middleware.TokenAuth())
|
|
|
|
|
{
|
|
|
|
|
tokenUsageRoute.GET("/", controller.GetTokenUsage)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-26 17:02:26 +08:00
|
|
|
redemptionRoute := apiRouter.Group("/redemption")
|
|
|
|
|
redemptionRoute.Use(middleware.AdminAuth())
|
|
|
|
|
{
|
|
|
|
|
redemptionRoute.GET("/", controller.GetAllRedemptions)
|
|
|
|
|
redemptionRoute.GET("/search", controller.SearchRedemptions)
|
|
|
|
|
redemptionRoute.GET("/:id", controller.GetRedemption)
|
|
|
|
|
redemptionRoute.POST("/", controller.AddRedemption)
|
|
|
|
|
redemptionRoute.PUT("/", controller.UpdateRedemption)
|
2025-06-13 20:51:20 +08:00
|
|
|
redemptionRoute.DELETE("/invalid", controller.DeleteInvalidRedemption)
|
2023-04-26 17:02:26 +08:00
|
|
|
redemptionRoute.DELETE("/:id", controller.DeleteRedemption)
|
|
|
|
|
}
|
2023-06-09 16:59:00 +08:00
|
|
|
logRoute := apiRouter.Group("/log")
|
|
|
|
|
logRoute.GET("/", middleware.AdminAuth(), controller.GetAllLogs)
|
2023-09-17 17:09:56 +08:00
|
|
|
logRoute.DELETE("/", middleware.AdminAuth(), controller.DeleteHistoryLogs)
|
2023-06-24 15:28:11 +08:00
|
|
|
logRoute.GET("/stat", middleware.AdminAuth(), controller.GetLogsStat)
|
|
|
|
|
logRoute.GET("/self/stat", middleware.UserAuth(), controller.GetLogsSelfStat)
|
2023-06-09 16:59:00 +08:00
|
|
|
logRoute.GET("/search", middleware.AdminAuth(), controller.SearchAllLogs)
|
|
|
|
|
logRoute.GET("/self", middleware.UserAuth(), controller.GetUserLogs)
|
|
|
|
|
logRoute.GET("/self/search", middleware.UserAuth(), controller.SearchUserLogs)
|
2023-09-18 01:42:04 +08:00
|
|
|
|
2024-01-07 18:31:14 +08:00
|
|
|
dataRoute := apiRouter.Group("/data")
|
|
|
|
|
dataRoute.GET("/", middleware.AdminAuth(), controller.GetAllQuotaDates)
|
2024-01-07 19:47:35 +08:00
|
|
|
dataRoute.GET("/self", middleware.UserAuth(), controller.GetUserQuotaDates)
|
2024-01-07 18:31:14 +08:00
|
|
|
|
2023-09-18 01:42:04 +08:00
|
|
|
logRoute.Use(middleware.CORS())
|
|
|
|
|
{
|
|
|
|
|
logRoute.GET("/token", controller.GetLogByKey)
|
|
|
|
|
}
|
2023-06-11 11:08:16 +08:00
|
|
|
groupRoute := apiRouter.Group("/group")
|
|
|
|
|
groupRoute.Use(middleware.AdminAuth())
|
|
|
|
|
{
|
|
|
|
|
groupRoute.GET("/", controller.GetGroups)
|
|
|
|
|
}
|
2025-08-04 02:54:37 +08:00
|
|
|
|
|
|
|
|
prefillGroupRoute := apiRouter.Group("/prefill_group")
|
|
|
|
|
prefillGroupRoute.Use(middleware.AdminAuth())
|
|
|
|
|
{
|
|
|
|
|
prefillGroupRoute.GET("/", controller.GetPrefillGroups)
|
|
|
|
|
prefillGroupRoute.POST("/", controller.CreatePrefillGroup)
|
|
|
|
|
prefillGroupRoute.PUT("/", controller.UpdatePrefillGroup)
|
|
|
|
|
prefillGroupRoute.DELETE("/:id", controller.DeletePrefillGroup)
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-14 22:16:32 +08:00
|
|
|
mjRoute := apiRouter.Group("/mj")
|
|
|
|
|
mjRoute.GET("/self", middleware.UserAuth(), controller.GetUserMidjourney)
|
|
|
|
|
mjRoute.GET("/", middleware.AdminAuth(), controller.GetAllMidjourney)
|
2024-06-12 20:37:42 +08:00
|
|
|
|
|
|
|
|
taskRoute := apiRouter.Group("/task")
|
|
|
|
|
{
|
|
|
|
|
taskRoute.GET("/self", middleware.UserAuth(), controller.GetUserTask)
|
|
|
|
|
taskRoute.GET("/", middleware.AdminAuth(), controller.GetAllTask)
|
|
|
|
|
}
|
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements
Backend
• Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps
• Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go`
• Auto-migrate new tables in DB startup logic
Frontend
• Build complete “Model Management” module under `/console/models`
- New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs
- Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile`
• Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature
• Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes
Table UX improvements
• Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style)
• Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags
• Color all tags deterministically using `stringToColor` for consistent theming
• Change vendor column tag color to white for better contrast
Misc
• Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up
These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
|
|
|
|
|
|
|
|
vendorRoute := apiRouter.Group("/vendors")
|
2025-08-10 21:22:53 +08:00
|
|
|
vendorRoute.Use(middleware.AdminAuth())
|
|
|
|
|
{
|
|
|
|
|
vendorRoute.GET("/", controller.GetAllVendors)
|
|
|
|
|
vendorRoute.GET("/search", controller.SearchVendors)
|
|
|
|
|
vendorRoute.GET("/:id", controller.GetVendorMeta)
|
|
|
|
|
vendorRoute.POST("/", controller.CreateVendorMeta)
|
|
|
|
|
vendorRoute.PUT("/", controller.UpdateVendorMeta)
|
|
|
|
|
vendorRoute.DELETE("/:id", controller.DeleteVendorMeta)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
modelsRoute := apiRouter.Group("/models")
|
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements
Backend
• Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps
• Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go`
• Auto-migrate new tables in DB startup logic
Frontend
• Build complete “Model Management” module under `/console/models`
- New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs
- Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile`
• Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature
• Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes
Table UX improvements
• Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style)
• Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags
• Color all tags deterministically using `stringToColor` for consistent theming
• Change vendor column tag color to white for better contrast
Misc
• Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up
These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
|
|
|
modelsRoute.Use(middleware.AdminAuth())
|
|
|
|
|
{
|
2025-08-03 22:51:24 +08:00
|
|
|
modelsRoute.GET("/missing", controller.GetMissingModels)
|
2025-08-10 21:22:53 +08:00
|
|
|
modelsRoute.GET("/", controller.GetAllModelsMeta)
|
|
|
|
|
modelsRoute.GET("/search", controller.SearchModelsMeta)
|
🚀 feat: Introduce full Model & Vendor Management suite (backend + frontend) and UI refinements
Backend
• Add `model/model_meta.go` and `model/vendor_meta.go` defining Model & Vendor entities with CRUD helpers, soft-delete and time stamps
• Create corresponding controllers `controller/model_meta.go`, `controller/vendor_meta.go` and register routes in `router/api-router.go`
• Auto-migrate new tables in DB startup logic
Frontend
• Build complete “Model Management” module under `/console/models`
- New pages, tables, filters, actions, hooks (`useModelsData`) and dynamic vendor tabs
- Modals `EditModelModal.jsx` & unified `EditVendorModal.jsx`; latter now uses default confirm/cancel footer and mobile-friendly modal sizing (`full-width` / `small`) via `useIsMobile`
• Update sidebar (`SiderBar.js`) and routing (`App.js`) to surface the feature
• Add helper updates (`render.js`) incl. `stringToColor`, dynamic LobeHub icon retrieval, and tag color palettes
Table UX improvements
• Replace separate status column with inline Enable / Disable buttons in operation column (matching channel table style)
• Limit visible tags to max 3; overflow represented as “+x” tag with padded `Popover` showing remaining tags
• Color all tags deterministically using `stringToColor` for consistent theming
• Change vendor column tag color to white for better contrast
Misc
• Minor layout tweaks, compact-mode toggle relocation, lint fixes and TypeScript/ESLint clean-up
These changes collectively deliver end-to-end model & vendor administration while unifying visual language across management tables.
2025-07-31 22:28:09 +08:00
|
|
|
modelsRoute.GET("/:id", controller.GetModelMeta)
|
|
|
|
|
modelsRoute.POST("/", controller.CreateModelMeta)
|
|
|
|
|
modelsRoute.PUT("/", controller.UpdateModelMeta)
|
|
|
|
|
modelsRoute.DELETE("/:id", controller.DeleteModelMeta)
|
|
|
|
|
}
|
2023-04-22 20:39:27 +08:00
|
|
|
}
|
|
|
|
|
}
|