Просмотр исходного кода

refactor: Improve channel status update logic and clean up code

- Simplified conditional checks in UpdateChannelStatusById function in channel.go to enhance readability.
- Commented out unused image number check in relay-gemini.go for clarity.
- Updated JSON field in en.json for currency consistency, changing "元" from "RMB/CNY" to "CNY" and added a space in "实付金额:" for formatting.
CalciumIon 1 год назад
Родитель
Сommit
2d865eb735
3 измененных файлов с 14 добавлено и 13 удалено
  1. 9 8
      model/channel.go
  2. 3 3
      relay/channel/gemini/relay-gemini.go
  3. 2 2
      web/src/i18n/locales/en.json

+ 9 - 8
model/channel.go

@@ -292,19 +292,20 @@ func (channel *Channel) Delete() error {
 }
 
 var channelStatusLock sync.Mutex
+
 func UpdateChannelStatusById(id int, status int, reason string) {
-	if (common.MemoryCacheEnabled) {
+	if common.MemoryCacheEnabled {
 		channelStatusLock.Lock()
-		channelCache, err := CacheGetChannel(id)
-		// 如果缓存渠道存在,且状态已是目标状态,直接返回 
-		if channelCache != nil && channelCache.Status == status {  
+		channelCache, _ := CacheGetChannel(id)
+		// 如果缓存渠道存在,且状态已是目标状态,直接返回
+		if channelCache != nil && channelCache.Status == status {
 			channelStatusLock.Unlock()
-			return 
+			return
 		}
-		// 如果缓存渠道不存在(说明已经被禁用),且要设置的状态不为启用,直接返回 
-		if channelCache == nil && status != common.ChannelStatusEnabled {  
+		// 如果缓存渠道不存在(说明已经被禁用),且要设置的状态不为启用,直接返回
+		if channelCache == nil && status != common.ChannelStatusEnabled {
 			channelStatusLock.Unlock()
-			return 
+			return
 		}
 		CacheUpdateChannelStatus(id, status)
 		channelStatusLock.Unlock()

+ 3 - 3
relay/channel/gemini/relay-gemini.go

@@ -103,9 +103,9 @@ func CovertGemini2OpenAI(textRequest dto.GeneralOpenAIRequest) *GeminiChatReques
 				})
 			} else if part.Type == dto.ContentTypeImageURL {
 				imageNum += 1
-				if imageNum > GeminiVisionMaxImageNum {
-					continue
-				}
+				//if imageNum > GeminiVisionMaxImageNum {
+				//	continue
+				//}
 				// 判断是否是url
 				if strings.HasPrefix(part.ImageUrl.(dto.MessageImageUrl).Url, "http") {
 					// 是url,获取图片的类型和base64编码的数据

+ 2 - 2
web/src/i18n/locales/en.json

@@ -797,7 +797,7 @@
   "管理员未开启Stripe在线充值!": "The administrator has not enabled Stripe online recharge!",
   "当前充值1美金=": "Current recharge = 1 USD =",
   "请选择充值方式!": "Please choose a recharge method!",
-  "元": "RMB/CNY",
+  "元": "CNY",
   "充值记录": "Recharge record",
   "返利记录": "Rebate record",
   "确定要充值 $": "Confirm to top up $",
@@ -963,7 +963,7 @@
   "请输入星火大模型版本,注意是接口地址中的版本号,例如:v2[1]": "Please enter the Spark model version, note that it is the version number in the interface address, for example: v2.1",
   "等待中": "Waiting",
   "所有各厂聊天模型请统一使用OpenAI方式请求,支持OpenAI官方库": "Please use the OpenAI method to request all chat models from each factory, and support the OpenAI official library.",
-  "实付金额:": "Actual payment amount:",
+  "实付金额:": "Actual payment amount: ",
   "金额": "Amount",
   "充值金额": "Recharge amount",
   "易支付 实付金额:": "Easy Pay Actual payment amount:",