- Replace all encoding/json direct calls with common.Marshal/Unmarshal/DecodeJson per Rule 1 - Fix Dify nil pointer dereference on remote image upload (relay-dify.go) - Fix Claude relay file content type detection for text/* and PDF (relay-claude.go) - Fix unsafe type assertions in Claude relay and Vertex GetModelRegion - Fix StreamScanner unconditionally resetting pre-existing StreamStatus - Add inferMimeTypeFromFilename() for proper MIME type handling in DTO - Fix Mac build script hardcoded DMG version (now reads from tauri.conf.json) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package setting
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/heicode/manager/common"
|
|
)
|
|
|
|
var userUsableGroups = map[string]string{
|
|
"default": "默认分组",
|
|
"vip": "vip分组",
|
|
}
|
|
var userUsableGroupsMutex sync.RWMutex
|
|
|
|
func GetUserUsableGroupsCopy() map[string]string {
|
|
userUsableGroupsMutex.RLock()
|
|
defer userUsableGroupsMutex.RUnlock()
|
|
|
|
copyUserUsableGroups := make(map[string]string)
|
|
for k, v := range userUsableGroups {
|
|
copyUserUsableGroups[k] = v
|
|
}
|
|
return copyUserUsableGroups
|
|
}
|
|
|
|
func UserUsableGroups2JSONString() string {
|
|
userUsableGroupsMutex.RLock()
|
|
defer userUsableGroupsMutex.RUnlock()
|
|
|
|
jsonBytes, err := common.Marshal(userUsableGroups)
|
|
if err != nil {
|
|
common.SysLog("error marshalling user groups: " + err.Error())
|
|
}
|
|
return string(jsonBytes)
|
|
}
|
|
|
|
func UpdateUserUsableGroupsByJSONString(jsonStr string) error {
|
|
userUsableGroupsMutex.Lock()
|
|
defer userUsableGroupsMutex.Unlock()
|
|
|
|
userUsableGroups = make(map[string]string)
|
|
return common.Unmarshal([]byte(jsonStr), &userUsableGroups)
|
|
}
|
|
|
|
func GetUsableGroupDescription(groupName string) string {
|
|
userUsableGroupsMutex.RLock()
|
|
defer userUsableGroupsMutex.RUnlock()
|
|
|
|
if desc, ok := userUsableGroups[groupName]; ok {
|
|
return desc
|
|
}
|
|
return groupName
|
|
}
|