From 044b5aafeaee211a4947a3087aca0179608d9b04 Mon Sep 17 00:00:00 2001 From: fengsilin Date: Thu, 26 Mar 2026 14:54:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=94=B9=E8=BF=9B=20RWMap=20JSON=20?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=8E=9F=E5=AD=90=E6=80=A7=20&=20UI=20?= =?UTF-8?q?=E6=96=87=E6=A1=88=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - types/rw_map.go: 解析失败时不再清空原有数据 - HomePricingFilters: 模型类型标签从"对话"改为"文本" - makefile: docker-build 目标添加自动 push Co-Authored-By: Claude Opus 4.6 --- makefile | 1 + types/rw_map.go | 23 +++++++++++++++++------ web/src/pages/Home/HomePricingFilters.jsx | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/makefile b/makefile index fdb2c68..cc626c3 100644 --- a/makefile +++ b/makefile @@ -22,6 +22,7 @@ DOCKER_TAG := $(DOCKER_REGISTRY):$(BUILD_TIME)-$(BRANCH_NAME) docker-build: @echo "Building Docker image with tag: $(DOCKER_TAG)" docker build -t $(DOCKER_TAG) . + docker push $(DOCKER_TAG) docker-push: docker-build @echo "Pushing Docker image: $(DOCKER_TAG)" diff --git a/types/rw_map.go b/types/rw_map.go index 3d29681..89bdfa1 100644 --- a/types/rw_map.go +++ b/types/rw_map.go @@ -77,20 +77,31 @@ func (m *RWMap[K, V]) Len() int { func LoadFromJsonString[K comparable, V any](m *RWMap[K, V], jsonStr string) error { m.mutex.Lock() defer m.mutex.Unlock() - m.data = make(map[K]V) - return common.Unmarshal([]byte(jsonStr), &m.data) + // 先尝试解析到临时 map,成功后再替换,避免解析失败时丢失原有数据 + tempData := make(map[K]V) + err := common.Unmarshal([]byte(jsonStr), &tempData) + if err != nil { + return err + } + m.data = tempData + return nil } // LoadFromJsonStringWithCallback loads a JSON string into the RWMap and calls the callback on success. func LoadFromJsonStringWithCallback[K comparable, V any](m *RWMap[K, V], jsonStr string, onSuccess func()) error { m.mutex.Lock() defer m.mutex.Unlock() - m.data = make(map[K]V) - err := common.Unmarshal([]byte(jsonStr), &m.data) - if err == nil && onSuccess != nil { + // 先尝试解析到临时 map,成功后再替换,避免解析失败时丢失原有数据 + tempData := make(map[K]V) + err := common.Unmarshal([]byte(jsonStr), &tempData) + if err != nil { + return err + } + m.data = tempData + if onSuccess != nil { onSuccess() } - return err + return nil } // MarshalJSONString returns the JSON string representation of the RWMap. diff --git a/web/src/pages/Home/HomePricingFilters.jsx b/web/src/pages/Home/HomePricingFilters.jsx index b3157b2..cfb443a 100644 --- a/web/src/pages/Home/HomePricingFilters.jsx +++ b/web/src/pages/Home/HomePricingFilters.jsx @@ -28,7 +28,7 @@ import { getLobeHubIcon } from '../../helpers'; // 与 model_meta.go ModelType 常量一致:1=Chat, 2=Image, 3=Audio, 4=Video, 5=Embedding, 6=Rerank, 7=Vision, 8=Other const MODEL_TYPE_LIST = [ - { value: 1, labelKey: '对话' }, + { value: 1, labelKey: '文本' }, { value: 2, labelKey: '图像' }, { value: 3, labelKey: '音频' }, { value: 4, labelKey: '视频' },