- Added a new `setting` package to replace the `constant` package for configuration management, improving code organization and clarity. - Moved various configuration variables such as `ServerAddress`, `PayAddress`, and `SensitiveWords` to the new `setting` package. - Updated references throughout the codebase to use the new `setting` package, ensuring consistent access to configuration values. - Introduced new files for managing chat settings and midjourney settings, enhancing modularity and maintainability of the code.
36 lines
872 B
Go
36 lines
872 B
Go
package setting
|
|
|
|
import (
|
|
"encoding/json"
|
|
"one-api/common"
|
|
)
|
|
|
|
var Chats = []map[string]string{
|
|
{
|
|
"ChatGPT Next Web 官方示例": "https://app.nextchat.dev/#/?settings={\"key\":\"{key}\",\"url\":\"{address}\"}",
|
|
},
|
|
{
|
|
"Lobe Chat 官方示例": "https://chat-preview.lobehub.com/?settings={\"keyVaults\":{\"openai\":{\"apiKey\":\"{key}\",\"baseURL\":\"{address}/v1\"}}}",
|
|
},
|
|
{
|
|
"AMA 问天": "ama://set-api-key?server={address}&key={key}",
|
|
},
|
|
{
|
|
"OpenCat": "opencat://team/join?domain={address}&token={key}",
|
|
},
|
|
}
|
|
|
|
func UpdateChatsByJsonString(jsonString string) error {
|
|
Chats = make([]map[string]string, 0)
|
|
return json.Unmarshal([]byte(jsonString), &Chats)
|
|
}
|
|
|
|
func Chats2JsonString() string {
|
|
jsonBytes, err := json.Marshal(Chats)
|
|
if err != nil {
|
|
common.SysError("error marshalling chats: " + err.Error())
|
|
return "[]"
|
|
}
|
|
return string(jsonBytes)
|
|
}
|