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

fix: 改进 RWMap JSON 加载原子性 & UI 文案调整

- types/rw_map.go: 解析失败时不再清空原有数据
- HomePricingFilters: 模型类型标签从"对话"改为"文本"
- makefile: docker-build 目标添加自动 push

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
feat/alipay-payment
fengsilin 1 месяц назад
Родитель
Сommit
044b5aafea
3 измененных файлов: 19 добавлений и 7 удалений
  1. +1
    -0
      makefile
  2. +17
    -6
      types/rw_map.go
  3. +1
    -1
      web/src/pages/Home/HomePricingFilters.jsx

+ 1
- 0
makefile Просмотреть файл

@@ -22,6 +22,7 @@ DOCKER_TAG := $(DOCKER_REGISTRY):$(BUILD_TIME)-$(BRANCH_NAME)
docker-build: docker-build:
@echo "Building Docker image with tag: $(DOCKER_TAG)" @echo "Building Docker image with tag: $(DOCKER_TAG)"
docker build -t $(DOCKER_TAG) . docker build -t $(DOCKER_TAG) .
docker push $(DOCKER_TAG)


docker-push: docker-build docker-push: docker-build
@echo "Pushing Docker image: $(DOCKER_TAG)" @echo "Pushing Docker image: $(DOCKER_TAG)"


+ 17
- 6
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 { func LoadFromJsonString[K comparable, V any](m *RWMap[K, V], jsonStr string) error {
m.mutex.Lock() m.mutex.Lock()
defer m.mutex.Unlock() 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. // 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 { func LoadFromJsonStringWithCallback[K comparable, V any](m *RWMap[K, V], jsonStr string, onSuccess func()) error {
m.mutex.Lock() m.mutex.Lock()
defer m.mutex.Unlock() 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() onSuccess()
} }
return err
return nil
} }


// MarshalJSONString returns the JSON string representation of the RWMap. // MarshalJSONString returns the JSON string representation of the RWMap.


+ 1
- 1
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 // 与 model_meta.go ModelType 常量一致:1=Chat, 2=Image, 3=Audio, 4=Video, 5=Embedding, 6=Rerank, 7=Vision, 8=Other
const MODEL_TYPE_LIST = [ const MODEL_TYPE_LIST = [
{ value: 1, labelKey: '对话' },
{ value: 1, labelKey: '文本' },
{ value: 2, labelKey: '图像' }, { value: 2, labelKey: '图像' },
{ value: 3, labelKey: '音频' }, { value: 3, labelKey: '音频' },
{ value: 4, labelKey: '视频' }, { value: 4, labelKey: '视频' },


Загрузка…
Отмена
Сохранить