From 191f5219261e5a0d653aa0080bf4244d097e8979 Mon Sep 17 00:00:00 2001 From: RedwindA Date: Thu, 5 Jun 2025 20:42:56 +0800 Subject: [PATCH 1/8] fix: change RedisHDelObj to use Del instead of HDel --- common/redis.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/redis.go b/common/redis.go index 49d3ec78a..50030d2a9 100644 --- a/common/redis.go +++ b/common/redis.go @@ -97,7 +97,7 @@ func RedisHDelObj(key string) error { SysLog(fmt.Sprintf("Redis HDEL: key=%s", key)) } ctx := context.Background() - return RDB.HDel(ctx, key).Err() + return RDB.Del(ctx, key).Err() } func RedisHSetObj(key string, obj interface{}, expiration time.Duration) error { From eff9ce117f149e0d760d51bc1b0920f3d1c38456 Mon Sep 17 00:00:00 2001 From: RedwindA Date: Thu, 5 Jun 2025 21:17:57 +0800 Subject: [PATCH 2/8] refactor: rename RedisHDelObj to RedisDelKey and update references --- common/redis.go | 4 ++-- model/token_cache.go | 2 +- model/user_cache.go | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/common/redis.go b/common/redis.go index 50030d2a9..ba35331a6 100644 --- a/common/redis.go +++ b/common/redis.go @@ -92,9 +92,9 @@ func RedisDel(key string) error { return RDB.Del(ctx, key).Err() } -func RedisHDelObj(key string) error { +func RedisDelKey(key string) error { if DebugEnabled { - SysLog(fmt.Sprintf("Redis HDEL: key=%s", key)) + SysLog(fmt.Sprintf("Redis DEL Key: key=%s", key)) } ctx := context.Background() return RDB.Del(ctx, key).Err() diff --git a/model/token_cache.go b/model/token_cache.go index 0fe02fea5..b2e0c9510 100644 --- a/model/token_cache.go +++ b/model/token_cache.go @@ -19,7 +19,7 @@ func cacheSetToken(token Token) error { func cacheDeleteToken(key string) error { key = common.GenerateHMAC(key) - err := common.RedisHDelObj(fmt.Sprintf("token:%s", key)) + err := common.RedisDelKey(fmt.Sprintf("token:%s", key)) if err != nil { return err } diff --git a/model/user_cache.go b/model/user_cache.go index bc412e77e..d74877bd8 100644 --- a/model/user_cache.go +++ b/model/user_cache.go @@ -3,11 +3,12 @@ package model import ( "encoding/json" "fmt" - "github.com/gin-gonic/gin" "one-api/common" "one-api/constant" "time" + "github.com/gin-gonic/gin" + "github.com/bytedance/gopkg/util/gopool" ) @@ -57,7 +58,7 @@ func invalidateUserCache(userId int) error { if !common.RedisEnabled { return nil } - return common.RedisHDelObj(getUserCacheKey(userId)) + return common.RedisDelKey(getUserCacheKey(userId)) } // updateUserCache updates all user cache fields using hash From b7c742166a728c4c82d6df1f78ac1e054ad90be5 Mon Sep 17 00:00:00 2001 From: RedwindA Date: Sun, 8 Jun 2025 01:16:27 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=F0=9F=8E=A8=20feat(channel):=20add=20endpo?= =?UTF-8?q?int=20to=20retrieve=20models=20by=20tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/channel.go | 41 +++++++++++++++++++++++++++++++++++++++++ router/api-router.go | 1 + 2 files changed, 42 insertions(+) diff --git a/controller/channel.go b/controller/channel.go index a31e1f477..a4ef87c30 100644 --- a/controller/channel.go +++ b/controller/channel.go @@ -623,3 +623,44 @@ func BatchSetChannelTag(c *gin.Context) { }) return } + +func GetTagModels(c *gin.Context) { + tag := c.Query("tag") + if tag == "" { + c.JSON(http.StatusBadRequest, gin.H{ + "success": false, + "message": "tag不能为空", + }) + return + } + + channels, err := model.GetChannelsByTag(tag, false) // Assuming false for idSort is fine here + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{ + "success": false, + "message": err.Error(), + }) + return + } + + var longestModels string + maxLength := 0 + + // Find the longest models string among all channels with the given tag + for _, channel := range channels { + if channel.Models != "" { + currentModels := strings.Split(channel.Models, ",") + if len(currentModels) > maxLength { + maxLength = len(currentModels) + longestModels = channel.Models + } + } + } + + c.JSON(http.StatusOK, gin.H{ + "success": true, + "message": "", + "data": longestModels, + }) + return +} diff --git a/router/api-router.go b/router/api-router.go index 1720ff579..6251c8a24 100644 --- a/router/api-router.go +++ b/router/api-router.go @@ -105,6 +105,7 @@ func SetApiRouter(router *gin.Engine) { channelRoute.GET("/fetch_models/:id", controller.FetchUpstreamModels) channelRoute.POST("/fetch_models", controller.FetchModels) channelRoute.POST("/batch/tag", controller.BatchSetChannelTag) + channelRoute.GET("/tag/models", controller.GetTagModels) } tokenRoute := apiRouter.Group("/token") tokenRoute.Use(middleware.UserAuth()) From 49898928309ef72d5f2cbbb7c7c6a153b69904c8 Mon Sep 17 00:00:00 2001 From: RedwindA Date: Sun, 8 Jun 2025 01:16:39 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=F0=9F=90=9B=20fix(EditTagModal):=20add=20f?= =?UTF-8?q?etchTagModels=20function=20to=20retrieve=20models=20based=20on?= =?UTF-8?q?=20tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pages/Channel/EditTagModal.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/web/src/pages/Channel/EditTagModal.js b/web/src/pages/Channel/EditTagModal.js index 52dd4bbbf..1b3702976 100644 --- a/web/src/pages/Channel/EditTagModal.js +++ b/web/src/pages/Channel/EditTagModal.js @@ -194,6 +194,24 @@ const EditTagModal = (props) => { }, [originModelOptions, inputs.models]); useEffect(() => { + const fetchTagModels = async () => { + if (!tag) return; + setLoading(true); + try { + const res = await API.get(`/api/channel/tag/models?tag=${tag}`); + if (res?.data?.success) { + const models = res.data.data ? res.data.data.split(',') : []; + setInputs((inputs) => ({ ...inputs, models: models })); + } else { + showError(res.data.message); + } + } catch (error) { + showError(error.message); + } finally { + setLoading(false); + } + }; + setInputs({ ...originInputs, tag: tag, @@ -201,7 +219,8 @@ const EditTagModal = (props) => { }); fetchModels().then(); fetchGroups().then(); - }, [visible]); + fetchTagModels().then(); // Call the new function + }, [visible, tag]); // Add tag to dependency array const addCustomModels = () => { if (customModel.trim() === '') return; From a92952f07034adcf19fb3492991bc8ca4f6b2b84 Mon Sep 17 00:00:00 2001 From: "Apple\\Apple" Date: Sun, 8 Jun 2025 12:14:49 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=F0=9F=8E=A8=20fix:=20Import=20Semi=20UI=20?= =?UTF-8?q?CSS=20explicitly=20to=20resolve=20missing=20component=20styles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add explicit import of '@douyinfe/semi-ui/dist/css/semi.css' in index.js - Ensures Semi Design components render with proper styling - Resolves issue where Semi components appeared unstyled after dependency updates This change addresses the style loading issue that occurred after adding antd dependency and updating the build configuration. The explicit import ensures consistent style loading regardless of plugin behavior changes. --- web/src/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/web/src/index.js b/web/src/index.js index 0f57f5a18..ef8a3a07f 100644 --- a/web/src/index.js +++ b/web/src/index.js @@ -1,6 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import { BrowserRouter } from 'react-router-dom'; +import '@douyinfe/semi-ui/dist/css/semi.css'; import { UserProvider } from './context/User'; import 'react-toastify/dist/ReactToastify.css'; import { StatusProvider } from './context/Status'; From c26599ef46b8c0f3692ccaaa118ece532b184569 Mon Sep 17 00:00:00 2001 From: "Apple\\Apple" Date: Sun, 8 Jun 2025 12:23:54 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=F0=9F=92=84=20style(Logs):=20Add=20rounded?= =?UTF-8?q?=20corners=20to=20image=20view=20button=20in=20MjLogsTable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add rounded-full class to "查看图片" (View Image) button for consistent UI styling - All other buttons in both MjLogsTable.js and TaskLogsTable.js already have rounded corners applied - Ensures uniform button styling across the log tables interface --- web/src/components/table/MjLogsTable.js | 3 ++- web/src/components/table/TaskLogsTable.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/web/src/components/table/MjLogsTable.js b/web/src/components/table/MjLogsTable.js index 48513eb10..b4cf046ef 100644 --- a/web/src/components/table/MjLogsTable.js +++ b/web/src/components/table/MjLogsTable.js @@ -462,7 +462,7 @@ const LogsTable = () => { percent={text ? parseInt(text.replace('%', '')) : 0} showInfo={true} aria-label='drawing progress' - style={{ minWidth: '200px' }} + style={{ minWidth: '160px' }} /> } @@ -483,6 +483,7 @@ const LogsTable = () => { setModalImageUrl(text); setIsModalOpenurl(true); }} + className="!rounded-full" > {t('查看图片')} diff --git a/web/src/components/table/TaskLogsTable.js b/web/src/components/table/TaskLogsTable.js index 4e329d293..91ccc06c5 100644 --- a/web/src/components/table/TaskLogsTable.js +++ b/web/src/components/table/TaskLogsTable.js @@ -395,7 +395,7 @@ const LogsTable = () => { percent={text ? parseInt(text.replace('%', '')) : 0} showInfo={true} aria-label='task progress' - style={{ minWidth: '200px' }} + style={{ minWidth: '160px' }} /> ) } From 97a8219845ab9e81b58d73f8d33748e2ad9707aa Mon Sep 17 00:00:00 2001 From: "Apple\\Apple" Date: Sun, 8 Jun 2025 12:38:03 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E2=9C=A8=20feat(token):=20auto-generate=20?= =?UTF-8?q?default=20token=20names=20when=20user=20input=20is=20empty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When creating tokens, if the user doesn't provide a token name (empty or whitespace-only), the system will now automatically generate a name using the format "default-xxxxxx" where "xxxxxx" is a 6-character random alphanumeric string. This enhancement ensures that all created tokens have meaningful names and improves the user experience by removing the requirement to manually input token names for quick token creation scenarios. Changes: - Modified token creation logic to detect empty token names - Added automatic fallback to "default" base name when user input is missing - Maintained existing behavior for multiple token creation with random suffixes - Ensured consistent naming pattern across single and batch token creation --- web/src/pages/Token/EditToken.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/web/src/pages/Token/EditToken.js b/web/src/pages/Token/EditToken.js index 946164da5..71f611bd5 100644 --- a/web/src/pages/Token/EditToken.js +++ b/web/src/pages/Token/EditToken.js @@ -219,9 +219,15 @@ const EditToken = (props) => { let successCount = 0; // 记录成功创建的令牌数量 for (let i = 0; i < tokenCount; i++) { let localInputs = { ...inputs }; - if (i !== 0) { - // 如果用户想要创建多个令牌,则给每个令牌一个序号后缀 - localInputs.name = `${inputs.name}-${generateRandomSuffix()}`; + + // 检查用户是否填写了令牌名称 + const baseName = inputs.name.trim() === '' ? 'default' : inputs.name; + + if (i !== 0 || inputs.name.trim() === '') { + // 如果创建多个令牌(i !== 0)或者用户没有填写名称,则添加随机后缀 + localInputs.name = `${baseName}-${generateRandomSuffix()}`; + } else { + localInputs.name = baseName; } localInputs.remain_quota = parseInt(localInputs.remain_quota); From b47274bfadc637722f473bdfa217a30656406b23 Mon Sep 17 00:00:00 2001 From: RedwindA Date: Sun, 8 Jun 2025 13:23:59 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=F0=9F=90=9B=20fix(EditTagModal):=20add=20i?= =?UTF-8?q?nfo=20banner=20to=20clarify=20modelList=20behavior?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pages/Channel/EditTagModal.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/src/pages/Channel/EditTagModal.js b/web/src/pages/Channel/EditTagModal.js index 1b3702976..695ed2b47 100644 --- a/web/src/pages/Channel/EditTagModal.js +++ b/web/src/pages/Channel/EditTagModal.js @@ -366,6 +366,11 @@ const EditTagModal = (props) => {
{t('模型')} +