Compare commits
11 Commits
v0.6.11-pr
...
v0.6.11-al
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54c38de813 | ||
|
|
d6284bf6b0 | ||
|
|
df5d2ca93d | ||
|
|
fef7ae048b | ||
|
|
6916debf66 | ||
|
|
53da209134 | ||
|
|
517f6ad211 | ||
|
|
10aba11f18 | ||
|
|
4d011c5f98 | ||
|
|
eb96aa635e | ||
|
|
c715f2bc1d |
@@ -115,7 +115,7 @@ _✨ 通过标准的 OpenAI API 格式访问所有的大模型,开箱即用
|
|||||||
19. 支持丰富的**自定义**设置,
|
19. 支持丰富的**自定义**设置,
|
||||||
1. 支持自定义系统名称,logo 以及页脚。
|
1. 支持自定义系统名称,logo 以及页脚。
|
||||||
2. 支持自定义首页和关于页面,可以选择使用 HTML & Markdown 代码进行自定义,或者使用一个单独的网页通过 iframe 嵌入。
|
2. 支持自定义首页和关于页面,可以选择使用 HTML & Markdown 代码进行自定义,或者使用一个单独的网页通过 iframe 嵌入。
|
||||||
20. 支持通过系统访问令牌调用管理 API,进而**在无需二开的情况下扩展和自定义** One API 的功能,详情请参考此处 [API 文档](./docs/API.md)。。
|
20. 支持通过系统访问令牌调用管理 API,进而**在无需二开的情况下扩展和自定义** One API 的功能,详情请参考此处 [API 文档](./docs/API.md)。
|
||||||
21. 支持 Cloudflare Turnstile 用户校验。
|
21. 支持 Cloudflare Turnstile 用户校验。
|
||||||
22. 支持用户管理,支持**多种用户登录注册方式**:
|
22. 支持用户管理,支持**多种用户登录注册方式**:
|
||||||
+ 邮箱登录注册(支持注册邮箱白名单)以及通过邮箱进行密码重置。
|
+ 邮箱登录注册(支持注册邮箱白名单)以及通过邮箱进行密码重置。
|
||||||
|
|||||||
@@ -163,4 +163,4 @@ var UserContentRequestProxy = env.String("USER_CONTENT_REQUEST_PROXY", "")
|
|||||||
var UserContentRequestTimeout = env.Int("USER_CONTENT_REQUEST_TIMEOUT", 30)
|
var UserContentRequestTimeout = env.Int("USER_CONTENT_REQUEST_TIMEOUT", 30)
|
||||||
|
|
||||||
var EnforceIncludeUsage = env.Bool("ENFORCE_INCLUDE_USAGE", false)
|
var EnforceIncludeUsage = env.Bool("ENFORCE_INCLUDE_USAGE", false)
|
||||||
var TestPrompt = env.String("TEST_PROMPT", "Print your model name exactly and do not output without any other text.")
|
var TestPrompt = env.String("TEST_PROMPT", "Output only your specific model name with no additional text.")
|
||||||
|
|||||||
@@ -112,6 +112,13 @@ type DeepSeekUsageResponse struct {
|
|||||||
} `json:"balance_infos"`
|
} `json:"balance_infos"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type OpenRouterResponse struct {
|
||||||
|
Data struct {
|
||||||
|
TotalCredits float64 `json:"total_credits"`
|
||||||
|
TotalUsage float64 `json:"total_usage"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
// GetAuthHeader get auth header
|
// GetAuthHeader get auth header
|
||||||
func GetAuthHeader(token string) http.Header {
|
func GetAuthHeader(token string) http.Header {
|
||||||
h := http.Header{}
|
h := http.Header{}
|
||||||
@@ -285,6 +292,22 @@ func updateChannelDeepSeekBalance(channel *model.Channel) (float64, error) {
|
|||||||
return balance, nil
|
return balance, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateChannelOpenRouterBalance(channel *model.Channel) (float64, error) {
|
||||||
|
url := "https://openrouter.ai/api/v1/credits"
|
||||||
|
body, err := GetResponseBody("GET", url, channel, GetAuthHeader(channel.Key))
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
response := OpenRouterResponse{}
|
||||||
|
err = json.Unmarshal(body, &response)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
balance := response.Data.TotalCredits - response.Data.TotalUsage
|
||||||
|
channel.UpdateBalance(balance)
|
||||||
|
return balance, nil
|
||||||
|
}
|
||||||
|
|
||||||
func updateChannelBalance(channel *model.Channel) (float64, error) {
|
func updateChannelBalance(channel *model.Channel) (float64, error) {
|
||||||
baseURL := channeltype.ChannelBaseURLs[channel.Type]
|
baseURL := channeltype.ChannelBaseURLs[channel.Type]
|
||||||
if channel.GetBaseURL() == "" {
|
if channel.GetBaseURL() == "" {
|
||||||
@@ -313,6 +336,8 @@ func updateChannelBalance(channel *model.Channel) (float64, error) {
|
|||||||
return updateChannelSiliconFlowBalance(channel)
|
return updateChannelSiliconFlowBalance(channel)
|
||||||
case channeltype.DeepSeek:
|
case channeltype.DeepSeek:
|
||||||
return updateChannelDeepSeekBalance(channel)
|
return updateChannelDeepSeekBalance(channel)
|
||||||
|
case channeltype.OpenRouter:
|
||||||
|
return updateChannelOpenRouterBalance(channel)
|
||||||
default:
|
default:
|
||||||
return 0, errors.New("尚未实现")
|
return 0, errors.New("尚未实现")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ func testChannel(ctx context.Context, channel *model.Channel, request *relaymode
|
|||||||
rawResponse := w.Body.String()
|
rawResponse := w.Body.String()
|
||||||
_, responseMessage, err = parseTestResponse(rawResponse)
|
_, responseMessage, err = parseTestResponse(rawResponse)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logger.SysError(fmt.Sprintf("failed to parse error: %s, \nresponse: %s", err.Error(), rawResponse))
|
||||||
return "", err, nil
|
return "", err, nil
|
||||||
}
|
}
|
||||||
result := w.Result()
|
result := w.Result()
|
||||||
|
|||||||
20
relay/adaptor/alibailian/constants.go
Normal file
20
relay/adaptor/alibailian/constants.go
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package alibailian
|
||||||
|
|
||||||
|
// https://help.aliyun.com/zh/model-studio/getting-started/models
|
||||||
|
|
||||||
|
var ModelList = []string{
|
||||||
|
"qwen-turbo",
|
||||||
|
"qwen-plus",
|
||||||
|
"qwen-long",
|
||||||
|
"qwen-max",
|
||||||
|
"qwen-coder-plus",
|
||||||
|
"qwen-coder-plus-latest",
|
||||||
|
"qwen-coder-turbo",
|
||||||
|
"qwen-coder-turbo-latest",
|
||||||
|
"qwen-mt-plus",
|
||||||
|
"qwen-mt-turbo",
|
||||||
|
"qwq-32b-preview",
|
||||||
|
|
||||||
|
"deepseek-r1",
|
||||||
|
"deepseek-v3",
|
||||||
|
}
|
||||||
19
relay/adaptor/alibailian/main.go
Normal file
19
relay/adaptor/alibailian/main.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package alibailian
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/songquanpeng/one-api/relay/meta"
|
||||||
|
"github.com/songquanpeng/one-api/relay/relaymode"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetRequestURL(meta *meta.Meta) (string, error) {
|
||||||
|
switch meta.Mode {
|
||||||
|
case relaymode.ChatCompletions:
|
||||||
|
return fmt.Sprintf("%s/compatible-mode/v1/chat/completions", meta.BaseURL), nil
|
||||||
|
case relaymode.Embeddings:
|
||||||
|
return fmt.Sprintf("%s/compatible-mode/v1/embeddings", meta.BaseURL), nil
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
return "", fmt.Errorf("unsupported relay mode %d for ali bailian", meta.Mode)
|
||||||
|
}
|
||||||
@@ -5,9 +5,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/songquanpeng/one-api/common/config"
|
||||||
"github.com/songquanpeng/one-api/common/helper"
|
"github.com/songquanpeng/one-api/common/helper"
|
||||||
channelhelper "github.com/songquanpeng/one-api/relay/adaptor"
|
channelhelper "github.com/songquanpeng/one-api/relay/adaptor"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/openai"
|
"github.com/songquanpeng/one-api/relay/adaptor/openai"
|
||||||
@@ -20,17 +21,12 @@ type Adaptor struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Adaptor) Init(meta *meta.Meta) {
|
func (a *Adaptor) Init(meta *meta.Meta) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
|
func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
|
||||||
var defaultVersion string
|
defaultVersion := config.GeminiVersion
|
||||||
switch meta.ActualModelName {
|
if strings.Contains(meta.ActualModelName, "gemini-2.0") ||
|
||||||
case "gemini-2.0-flash-exp",
|
strings.Contains(meta.ActualModelName, "gemini-1.5") {
|
||||||
"gemini-2.0-flash-thinking-exp",
|
|
||||||
"gemini-2.0-flash-thinking-exp-01-21":
|
|
||||||
defaultVersion = "v1beta"
|
|
||||||
default:
|
|
||||||
defaultVersion = "v1beta"
|
defaultVersion = "v1beta"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,38 @@ package gemini
|
|||||||
|
|
||||||
var ModelList = []string{
|
var ModelList = []string{
|
||||||
"gemini-pro", "gemini-1.0-pro",
|
"gemini-pro", "gemini-1.0-pro",
|
||||||
"gemini-1.5-flash", "gemini-1.5-pro",
|
// "gemma-2-2b-it", "gemma-2-9b-it", "gemma-2-27b-it",
|
||||||
|
"gemini-1.5-flash", "gemini-1.5-flash-8b",
|
||||||
|
"gemini-1.5-pro", "gemini-1.5-pro-experimental",
|
||||||
"text-embedding-004", "aqa",
|
"text-embedding-004", "aqa",
|
||||||
"gemini-2.0-flash-exp",
|
"gemini-2.0-flash", "gemini-2.0-flash-exp",
|
||||||
"gemini-2.0-flash-thinking-exp", "gemini-2.0-flash-thinking-exp-01-21",
|
"gemini-2.0-flash-lite-preview-02-05",
|
||||||
|
"gemini-2.0-flash-thinking-exp-01-21",
|
||||||
|
"gemini-2.0-pro-exp-02-05",
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModelsSupportSystemInstruction is the list of models that support system instruction.
|
||||||
|
//
|
||||||
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/learn/prompts/system-instructions
|
||||||
|
var ModelsSupportSystemInstruction = []string{
|
||||||
|
// "gemini-1.0-pro-002",
|
||||||
|
// "gemini-1.5-flash", "gemini-1.5-flash-001", "gemini-1.5-flash-002",
|
||||||
|
// "gemini-1.5-flash-8b",
|
||||||
|
// "gemini-1.5-pro", "gemini-1.5-pro-001", "gemini-1.5-pro-002",
|
||||||
|
// "gemini-1.5-pro-experimental",
|
||||||
|
"gemini-2.0-flash", "gemini-2.0-flash-exp",
|
||||||
|
"gemini-2.0-flash-thinking-exp-01-21",
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsModelSupportSystemInstruction check if the model support system instruction.
|
||||||
|
//
|
||||||
|
// Because the main version of Go is 1.20, slice.Contains cannot be used
|
||||||
|
func IsModelSupportSystemInstruction(model string) bool {
|
||||||
|
for _, m := range ModelsSupportSystemInstruction {
|
||||||
|
if m == model {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,9 +132,16 @@ func ConvertRequest(textRequest model.GeneralOpenAIRequest) *ChatRequest {
|
|||||||
}
|
}
|
||||||
// Converting system prompt to prompt from user for the same reason
|
// Converting system prompt to prompt from user for the same reason
|
||||||
if content.Role == "system" {
|
if content.Role == "system" {
|
||||||
content.Role = "user"
|
|
||||||
shouldAddDummyModelMessage = true
|
shouldAddDummyModelMessage = true
|
||||||
|
if IsModelSupportSystemInstruction(textRequest.Model) {
|
||||||
|
geminiRequest.SystemInstruction = &content
|
||||||
|
geminiRequest.SystemInstruction.Role = ""
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
content.Role = "user"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
geminiRequest.Contents = append(geminiRequest.Contents, content)
|
geminiRequest.Contents = append(geminiRequest.Contents, content)
|
||||||
|
|
||||||
// If a system message is the last message, we need to add a dummy model message to make gemini happy
|
// If a system message is the last message, we need to add a dummy model message to make gemini happy
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package gemini
|
package gemini
|
||||||
|
|
||||||
type ChatRequest struct {
|
type ChatRequest struct {
|
||||||
Contents []ChatContent `json:"contents"`
|
Contents []ChatContent `json:"contents"`
|
||||||
SafetySettings []ChatSafetySettings `json:"safety_settings,omitempty"`
|
SafetySettings []ChatSafetySettings `json:"safety_settings,omitempty"`
|
||||||
GenerationConfig ChatGenerationConfig `json:"generation_config,omitempty"`
|
GenerationConfig ChatGenerationConfig `json:"generation_config,omitempty"`
|
||||||
Tools []ChatTools `json:"tools,omitempty"`
|
Tools []ChatTools `json:"tools,omitempty"`
|
||||||
|
SystemInstruction *ChatContent `json:"system_instruction,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type EmbeddingRequest struct {
|
type EmbeddingRequest struct {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor"
|
"github.com/songquanpeng/one-api/relay/adaptor"
|
||||||
|
"github.com/songquanpeng/one-api/relay/adaptor/alibailian"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/baiduv2"
|
"github.com/songquanpeng/one-api/relay/adaptor/baiduv2"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/doubao"
|
"github.com/songquanpeng/one-api/relay/adaptor/doubao"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/minimax"
|
"github.com/songquanpeng/one-api/relay/adaptor/minimax"
|
||||||
@@ -56,6 +57,8 @@ func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
|
|||||||
return novita.GetRequestURL(meta)
|
return novita.GetRequestURL(meta)
|
||||||
case channeltype.BaiduV2:
|
case channeltype.BaiduV2:
|
||||||
return baiduv2.GetRequestURL(meta)
|
return baiduv2.GetRequestURL(meta)
|
||||||
|
case channeltype.AliBailian:
|
||||||
|
return alibailian.GetRequestURL(meta)
|
||||||
default:
|
default:
|
||||||
return GetFullRequestURL(meta.BaseURL, meta.RequestURLPath, meta.ChannelType), nil
|
return GetFullRequestURL(meta.BaseURL, meta.RequestURLPath, meta.ChannelType), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package openai
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/ai360"
|
"github.com/songquanpeng/one-api/relay/adaptor/ai360"
|
||||||
|
"github.com/songquanpeng/one-api/relay/adaptor/alibailian"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/baichuan"
|
"github.com/songquanpeng/one-api/relay/adaptor/baichuan"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/baiduv2"
|
"github.com/songquanpeng/one-api/relay/adaptor/baiduv2"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/deepseek"
|
"github.com/songquanpeng/one-api/relay/adaptor/deepseek"
|
||||||
@@ -12,6 +13,7 @@ import (
|
|||||||
"github.com/songquanpeng/one-api/relay/adaptor/mistral"
|
"github.com/songquanpeng/one-api/relay/adaptor/mistral"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/moonshot"
|
"github.com/songquanpeng/one-api/relay/adaptor/moonshot"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/novita"
|
"github.com/songquanpeng/one-api/relay/adaptor/novita"
|
||||||
|
"github.com/songquanpeng/one-api/relay/adaptor/openrouter"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/siliconflow"
|
"github.com/songquanpeng/one-api/relay/adaptor/siliconflow"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/stepfun"
|
"github.com/songquanpeng/one-api/relay/adaptor/stepfun"
|
||||||
"github.com/songquanpeng/one-api/relay/adaptor/togetherai"
|
"github.com/songquanpeng/one-api/relay/adaptor/togetherai"
|
||||||
@@ -76,6 +78,10 @@ func GetCompatibleChannelMeta(channelType int) (string, []string) {
|
|||||||
return "baiduv2", baiduv2.ModelList
|
return "baiduv2", baiduv2.ModelList
|
||||||
case channeltype.XunfeiV2:
|
case channeltype.XunfeiV2:
|
||||||
return "xunfeiv2", xunfeiv2.ModelList
|
return "xunfeiv2", xunfeiv2.ModelList
|
||||||
|
case channeltype.OpenRouter:
|
||||||
|
return "openrouter", openrouter.ModelList
|
||||||
|
case channeltype.AliBailian:
|
||||||
|
return "alibailian", alibailian.ModelList
|
||||||
default:
|
default:
|
||||||
return "openai", ModelList
|
return "openai", ModelList
|
||||||
}
|
}
|
||||||
|
|||||||
20
relay/adaptor/openrouter/constants.go
Normal file
20
relay/adaptor/openrouter/constants.go
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package openrouter
|
||||||
|
|
||||||
|
var ModelList = []string{
|
||||||
|
"openai/gpt-3.5-turbo",
|
||||||
|
"openai/chatgpt-4o-latest",
|
||||||
|
"openai/o1",
|
||||||
|
"openai/o1-preview",
|
||||||
|
"openai/o1-mini",
|
||||||
|
"openai/o3-mini",
|
||||||
|
"google/gemini-2.0-flash-001",
|
||||||
|
"google/gemini-2.0-flash-thinking-exp:free",
|
||||||
|
"google/gemini-2.0-flash-lite-preview-02-05:free",
|
||||||
|
"google/gemini-2.0-pro-exp-02-05:free",
|
||||||
|
"google/gemini-flash-1.5-8b",
|
||||||
|
"anthropic/claude-3.5-sonnet",
|
||||||
|
"anthropic/claude-3.5-haiku",
|
||||||
|
"deepseek/deepseek-r1:free",
|
||||||
|
"deepseek/deepseek-r1",
|
||||||
|
"qwen/qwen-vl-plus:free",
|
||||||
|
}
|
||||||
@@ -16,10 +16,12 @@ import (
|
|||||||
|
|
||||||
var ModelList = []string{
|
var ModelList = []string{
|
||||||
"gemini-pro", "gemini-pro-vision",
|
"gemini-pro", "gemini-pro-vision",
|
||||||
"gemini-1.5-pro-001", "gemini-1.5-flash-001",
|
"gemini-exp-1206",
|
||||||
"gemini-1.5-pro-002", "gemini-1.5-flash-002",
|
"gemini-1.5-pro-001", "gemini-1.5-pro-002",
|
||||||
"gemini-2.0-flash-exp",
|
"gemini-1.5-flash-001", "gemini-1.5-flash-002",
|
||||||
"gemini-2.0-flash-thinking-exp", "gemini-2.0-flash-thinking-exp-01-21",
|
"gemini-2.0-flash-exp", "gemini-2.0-flash-001",
|
||||||
|
"gemini-2.0-flash-lite-preview-02-05",
|
||||||
|
"gemini-2.0-flash-thinking-exp-01-21",
|
||||||
}
|
}
|
||||||
|
|
||||||
type Adaptor struct {
|
type Adaptor struct {
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
package xai
|
package xai
|
||||||
|
|
||||||
|
//https://console.x.ai/
|
||||||
|
|
||||||
var ModelList = []string{
|
var ModelList = []string{
|
||||||
|
"grok-2",
|
||||||
|
"grok-vision-beta",
|
||||||
|
"grok-2-vision-1212",
|
||||||
|
"grok-2-vision",
|
||||||
|
"grok-2-vision-latest",
|
||||||
|
"grok-2-1212",
|
||||||
|
"grok-2-latest",
|
||||||
"grok-beta",
|
"grok-beta",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,15 +115,24 @@ var ModelRatio = map[string]float64{
|
|||||||
"bge-large-en": 0.002 * RMB,
|
"bge-large-en": 0.002 * RMB,
|
||||||
"tao-8k": 0.002 * RMB,
|
"tao-8k": 0.002 * RMB,
|
||||||
// https://ai.google.dev/pricing
|
// https://ai.google.dev/pricing
|
||||||
"gemini-pro": 1, // $0.00025 / 1k characters -> $0.001 / 1k tokens
|
// https://cloud.google.com/vertex-ai/generative-ai/pricing
|
||||||
"gemini-1.0-pro": 1,
|
// "gemma-2-2b-it": 0,
|
||||||
"gemini-1.5-pro": 1,
|
// "gemma-2-9b-it": 0,
|
||||||
"gemini-1.5-pro-001": 1,
|
// "gemma-2-27b-it": 0,
|
||||||
"gemini-1.5-flash": 1,
|
"gemini-pro": 0.25 * MILLI_USD, // $0.00025 / 1k characters -> $0.001 / 1k tokens
|
||||||
"gemini-1.5-flash-001": 1,
|
"gemini-1.0-pro": 0.125 * MILLI_USD,
|
||||||
"gemini-2.0-flash-exp": 1,
|
"gemini-1.5-pro": 1.25 * MILLI_USD,
|
||||||
"gemini-2.0-flash-thinking-exp": 1,
|
"gemini-1.5-pro-001": 1.25 * MILLI_USD,
|
||||||
"gemini-2.0-flash-thinking-exp-01-21": 1,
|
"gemini-1.5-pro-experimental": 1.25 * MILLI_USD,
|
||||||
|
"gemini-1.5-flash": 0.075 * MILLI_USD,
|
||||||
|
"gemini-1.5-flash-001": 0.075 * MILLI_USD,
|
||||||
|
"gemini-1.5-flash-8b": 0.0375 * MILLI_USD,
|
||||||
|
"gemini-2.0-flash-exp": 0.075 * MILLI_USD,
|
||||||
|
"gemini-2.0-flash": 0.15 * MILLI_USD,
|
||||||
|
"gemini-2.0-flash-001": 0.15 * MILLI_USD,
|
||||||
|
"gemini-2.0-flash-lite-preview-02-05": 0.075 * MILLI_USD,
|
||||||
|
"gemini-2.0-flash-thinking-exp-01-21": 0.075 * MILLI_USD,
|
||||||
|
"gemini-2.0-pro-exp-02-05": 1.25 * MILLI_USD,
|
||||||
"aqa": 1,
|
"aqa": 1,
|
||||||
// https://open.bigmodel.cn/pricing
|
// https://open.bigmodel.cn/pricing
|
||||||
"glm-zero-preview": 0.01 * RMB,
|
"glm-zero-preview": 0.01 * RMB,
|
||||||
|
|||||||
@@ -50,5 +50,6 @@ const (
|
|||||||
Replicate
|
Replicate
|
||||||
BaiduV2
|
BaiduV2
|
||||||
XunfeiV2
|
XunfeiV2
|
||||||
|
AliBailian
|
||||||
Dummy
|
Dummy
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ var ChannelBaseURLs = []string{
|
|||||||
"https://api.replicate.com/v1/models/", // 46
|
"https://api.replicate.com/v1/models/", // 46
|
||||||
"https://qianfan.baidubce.com", // 47
|
"https://qianfan.baidubce.com", // 47
|
||||||
"https://spark-api-open.xf-yun.com", // 48
|
"https://spark-api-open.xf-yun.com", // 48
|
||||||
|
"https://dashscope.aliyuncs.com", // 49
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export const CHANNEL_OPTIONS = [
|
|||||||
{ key: 8, text: '自定义渠道', value: 8, color: 'pink' },
|
{ key: 8, text: '自定义渠道', value: 8, color: 'pink' },
|
||||||
{ key: 22, text: '知识库:FastGPT', value: 22, color: 'blue' },
|
{ key: 22, text: '知识库:FastGPT', value: 22, color: 'blue' },
|
||||||
{ key: 21, text: '知识库:AI Proxy', value: 21, color: 'purple' },
|
{ key: 21, text: '知识库:AI Proxy', value: 21, color: 'purple' },
|
||||||
{ key: 20, text: '代理:OpenRouter', value: 20, color: 'black' },
|
{key: 20, text: 'OpenRouter', value: 20, color: 'black'},
|
||||||
{ key: 2, text: '代理:API2D', value: 2, color: 'blue' },
|
{ key: 2, text: '代理:API2D', value: 2, color: 'blue' },
|
||||||
{ key: 5, text: '代理:OpenAI-SB', value: 5, color: 'brown' },
|
{ key: 5, text: '代理:OpenAI-SB', value: 5, color: 'brown' },
|
||||||
{ key: 7, text: '代理:OhMyGPT', value: 7, color: 'purple' },
|
{ key: 7, text: '代理:OhMyGPT', value: 7, color: 'purple' },
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ export const CHANNEL_OPTIONS = {
|
|||||||
},
|
},
|
||||||
20: {
|
20: {
|
||||||
key: 20,
|
key: 20,
|
||||||
text: '代理:OpenRouter',
|
text: 'OpenRouter',
|
||||||
value: 20,
|
value: 20,
|
||||||
color: 'success'
|
color: 'success'
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,17 @@
|
|||||||
import React, {useEffect, useState} from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import {useTranslation} from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import {Button, Dropdown, Form, Input, Label, Message, Pagination, Popup, Table,} from 'semantic-ui-react';
|
import {
|
||||||
import {Link} from 'react-router-dom';
|
Button,
|
||||||
|
Dropdown,
|
||||||
|
Form,
|
||||||
|
Input,
|
||||||
|
Label,
|
||||||
|
Message,
|
||||||
|
Pagination,
|
||||||
|
Popup,
|
||||||
|
Table,
|
||||||
|
} from 'semantic-ui-react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
API,
|
API,
|
||||||
loadChannelModels,
|
loadChannelModels,
|
||||||
@@ -13,8 +23,8 @@ import {
|
|||||||
timestamp2string,
|
timestamp2string,
|
||||||
} from '../helpers';
|
} from '../helpers';
|
||||||
|
|
||||||
import {CHANNEL_OPTIONS, ITEMS_PER_PAGE} from '../constants';
|
import { CHANNEL_OPTIONS, ITEMS_PER_PAGE } from '../constants';
|
||||||
import {renderGroup, renderNumber} from '../helpers/render';
|
import { renderGroup, renderNumber } from '../helpers/render';
|
||||||
|
|
||||||
function renderTimestamp(timestamp) {
|
function renderTimestamp(timestamp) {
|
||||||
return <>{timestamp2string(timestamp)}</>;
|
return <>{timestamp2string(timestamp)}</>;
|
||||||
@@ -57,6 +67,8 @@ function renderBalance(type, balance, t) {
|
|||||||
return <span>¥{balance.toFixed(2)}</span>;
|
return <span>¥{balance.toFixed(2)}</span>;
|
||||||
case 13: // AIGC2D
|
case 13: // AIGC2D
|
||||||
return <span>{renderNumber(balance)}</span>;
|
return <span>{renderNumber(balance)}</span>;
|
||||||
|
case 20: // OpenRouter
|
||||||
|
return <span>${balance.toFixed(2)}</span>;
|
||||||
case 36: // DeepSeek
|
case 36: // DeepSeek
|
||||||
return <span>¥{balance.toFixed(2)}</span>;
|
return <span>¥{balance.toFixed(2)}</span>;
|
||||||
case 44: // SiliconFlow
|
case 44: // SiliconFlow
|
||||||
@@ -106,7 +118,7 @@ const ChannelsTable = () => {
|
|||||||
|
|
||||||
const loadChannels = async (startIdx) => {
|
const loadChannels = async (startIdx) => {
|
||||||
const res = await API.get(`/api/channel/?p=${startIdx}`);
|
const res = await API.get(`/api/channel/?p=${startIdx}`);
|
||||||
const {success, message, data} = res.data;
|
const { success, message, data } = res.data;
|
||||||
if (success) {
|
if (success) {
|
||||||
let localChannels = data.map(processChannelData);
|
let localChannels = data.map(processChannelData);
|
||||||
if (startIdx === 0) {
|
if (startIdx === 0) {
|
||||||
@@ -488,7 +500,6 @@ const ChannelsTable = () => {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
sortChannel('balance');
|
sortChannel('balance');
|
||||||
}}
|
}}
|
||||||
hidden={!showDetail}
|
|
||||||
>
|
>
|
||||||
{t('channel.table.balance')}
|
{t('channel.table.balance')}
|
||||||
</Table.HeaderCell>
|
</Table.HeaderCell>
|
||||||
@@ -497,6 +508,7 @@ const ChannelsTable = () => {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
sortChannel('priority');
|
sortChannel('priority');
|
||||||
}}
|
}}
|
||||||
|
hidden={!showDetail}
|
||||||
>
|
>
|
||||||
{t('channel.table.priority')}
|
{t('channel.table.priority')}
|
||||||
</Table.HeaderCell>
|
</Table.HeaderCell>
|
||||||
@@ -536,7 +548,7 @@ const ChannelsTable = () => {
|
|||||||
basic
|
basic
|
||||||
/>
|
/>
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell hidden={!showDetail}>
|
<Table.Cell>
|
||||||
<Popup
|
<Popup
|
||||||
trigger={
|
trigger={
|
||||||
<span
|
<span
|
||||||
@@ -552,7 +564,7 @@ const ChannelsTable = () => {
|
|||||||
basic
|
basic
|
||||||
/>
|
/>
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell>
|
<Table.Cell hidden={!showDetail}>
|
||||||
<Popup
|
<Popup
|
||||||
trigger={
|
trigger={
|
||||||
<Input
|
<Input
|
||||||
@@ -586,7 +598,15 @@ const ChannelsTable = () => {
|
|||||||
/>
|
/>
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell>
|
<Table.Cell>
|
||||||
<div>
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
gap: '2px',
|
||||||
|
rowGap: '6px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
size={'tiny'}
|
size={'tiny'}
|
||||||
positive
|
positive
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
export const CHANNEL_OPTIONS = [
|
export const CHANNEL_OPTIONS = [
|
||||||
{key: 1, text: 'OpenAI', value: 1, color: 'green'},
|
{key: 1, text: 'OpenAI', value: 1, color: 'green'},
|
||||||
{key: 14, text: 'Anthropic Claude', value: 14, color: 'black'},
|
{key: 14, text: 'Anthropic Claude', value: 14, color: 'black'},
|
||||||
{key: 33, text: 'AWS', value: 33, color: 'black'},
|
{key: 33, text: 'AWS', value: 33, color: 'black'},
|
||||||
{key: 3, text: 'Azure OpenAI', value: 3, color: 'olive'},
|
{key: 3, text: 'Azure OpenAI', value: 3, color: 'olive'},
|
||||||
{key: 11, text: 'Google PaLM2', value: 11, color: 'orange'},
|
{key: 11, text: 'Google PaLM2', value: 11, color: 'orange'},
|
||||||
{key: 24, text: 'Google Gemini', value: 24, color: 'orange'},
|
{key: 24, text: 'Google Gemini', value: 24, color: 'orange'},
|
||||||
{key: 28, text: 'Mistral AI', value: 28, color: 'orange'},
|
{key: 28, text: 'Mistral AI', value: 28, color: 'orange'},
|
||||||
{key: 41, text: 'Novita', value: 41, color: 'purple'},
|
{key: 41, text: 'Novita', value: 41, color: 'purple'},
|
||||||
{
|
{
|
||||||
key: 40,
|
key: 40,
|
||||||
text: '字节火山引擎',
|
text: '字节火山引擎',
|
||||||
@@ -28,7 +28,14 @@ export const CHANNEL_OPTIONS = [
|
|||||||
color: 'blue',
|
color: 'blue',
|
||||||
tip: '请前往<a href="https://console.bce.baidu.com/iam/#/iam/apikey/list" target="_blank">此处</a>获取 API Key,注意本渠道仅支持<a target="_blank" href="https://cloud.baidu.com/doc/WENXINWORKSHOP/s/em4tsqo3v">推理服务 V2</a>相关模型',
|
tip: '请前往<a href="https://console.bce.baidu.com/iam/#/iam/apikey/list" target="_blank">此处</a>获取 API Key,注意本渠道仅支持<a target="_blank" href="https://cloud.baidu.com/doc/WENXINWORKSHOP/s/em4tsqo3v">推理服务 V2</a>相关模型',
|
||||||
},
|
},
|
||||||
{key: 17, text: '阿里通义千问', value: 17, color: 'orange'},
|
{
|
||||||
|
key: 17,
|
||||||
|
text: '阿里通义千问',
|
||||||
|
value: 17,
|
||||||
|
color: 'orange',
|
||||||
|
tip: '如需使用阿里云百炼,请使用<strong>阿里云百炼</strong>渠道',
|
||||||
|
},
|
||||||
|
{key: 49, text: '阿里云百炼', value: 49, color: 'orange'},
|
||||||
{
|
{
|
||||||
key: 18,
|
key: 18,
|
||||||
text: '讯飞星火认知',
|
text: '讯飞星火认知',
|
||||||
@@ -43,38 +50,38 @@ export const CHANNEL_OPTIONS = [
|
|||||||
color: 'blue',
|
color: 'blue',
|
||||||
tip: 'HTTP 版本的讯飞接口,前往<a href="https://console.xfyun.cn/services/cbm" target="_blank">此处</a>获取 HTTP 服务接口认证密钥',
|
tip: 'HTTP 版本的讯飞接口,前往<a href="https://console.xfyun.cn/services/cbm" target="_blank">此处</a>获取 HTTP 服务接口认证密钥',
|
||||||
},
|
},
|
||||||
{key: 16, text: '智谱 ChatGLM', value: 16, color: 'violet'},
|
{key: 16, text: '智谱 ChatGLM', value: 16, color: 'violet'},
|
||||||
{key: 19, text: '360 智脑', value: 19, color: 'blue'},
|
{key: 19, text: '360 智脑', value: 19, color: 'blue'},
|
||||||
{key: 25, text: 'Moonshot AI', value: 25, color: 'black'},
|
{key: 25, text: 'Moonshot AI', value: 25, color: 'black'},
|
||||||
{key: 23, text: '腾讯混元', value: 23, color: 'teal'},
|
{key: 23, text: '腾讯混元', value: 23, color: 'teal'},
|
||||||
{key: 26, text: '百川大模型', value: 26, color: 'orange'},
|
{key: 26, text: '百川大模型', value: 26, color: 'orange'},
|
||||||
{key: 27, text: 'MiniMax', value: 27, color: 'red'},
|
{key: 27, text: 'MiniMax', value: 27, color: 'red'},
|
||||||
{key: 29, text: 'Groq', value: 29, color: 'orange'},
|
{key: 29, text: 'Groq', value: 29, color: 'orange'},
|
||||||
{key: 30, text: 'Ollama', value: 30, color: 'black'},
|
{key: 30, text: 'Ollama', value: 30, color: 'black'},
|
||||||
{key: 31, text: '零一万物', value: 31, color: 'green'},
|
{key: 31, text: '零一万物', value: 31, color: 'green'},
|
||||||
{key: 32, text: '阶跃星辰', value: 32, color: 'blue'},
|
{key: 32, text: '阶跃星辰', value: 32, color: 'blue'},
|
||||||
{key: 34, text: 'Coze', value: 34, color: 'blue'},
|
{key: 34, text: 'Coze', value: 34, color: 'blue'},
|
||||||
{key: 35, text: 'Cohere', value: 35, color: 'blue'},
|
{key: 35, text: 'Cohere', value: 35, color: 'blue'},
|
||||||
{key: 36, text: 'DeepSeek', value: 36, color: 'black'},
|
{key: 36, text: 'DeepSeek', value: 36, color: 'black'},
|
||||||
{key: 37, text: 'Cloudflare', value: 37, color: 'orange'},
|
{key: 37, text: 'Cloudflare', value: 37, color: 'orange'},
|
||||||
{key: 38, text: 'DeepL', value: 38, color: 'black'},
|
{key: 38, text: 'DeepL', value: 38, color: 'black'},
|
||||||
{key: 39, text: 'together.ai', value: 39, color: 'blue'},
|
{key: 39, text: 'together.ai', value: 39, color: 'blue'},
|
||||||
{key: 42, text: 'VertexAI', value: 42, color: 'blue'},
|
{key: 42, text: 'VertexAI', value: 42, color: 'blue'},
|
||||||
{key: 43, text: 'Proxy', value: 43, color: 'blue'},
|
{key: 43, text: 'Proxy', value: 43, color: 'blue'},
|
||||||
{key: 44, text: 'SiliconFlow', value: 44, color: 'blue'},
|
{key: 44, text: 'SiliconFlow', value: 44, color: 'blue'},
|
||||||
{key: 45, text: 'xAI', value: 45, color: 'blue'},
|
{key: 45, text: 'xAI', value: 45, color: 'blue'},
|
||||||
{key: 46, text: 'Replicate', value: 46, color: 'blue'},
|
{key: 46, text: 'Replicate', value: 46, color: 'blue'},
|
||||||
{key: 8, text: '自定义渠道', value: 8, color: 'pink'},
|
{key: 8, text: '自定义渠道', value: 8, color: 'pink'},
|
||||||
{key: 22, text: '知识库:FastGPT', value: 22, color: 'blue'},
|
{key: 22, text: '知识库:FastGPT', value: 22, color: 'blue'},
|
||||||
{key: 21, text: '知识库:AI Proxy', value: 21, color: 'purple'},
|
{key: 21, text: '知识库:AI Proxy', value: 21, color: 'purple'},
|
||||||
{key: 20, text: '代理:OpenRouter', value: 20, color: 'black'},
|
{key: 20, text: 'OpenRouter', value: 20, color: 'black'},
|
||||||
{key: 2, text: '代理:API2D', value: 2, color: 'blue'},
|
{key: 2, text: '代理:API2D', value: 2, color: 'blue'},
|
||||||
{key: 5, text: '代理:OpenAI-SB', value: 5, color: 'brown'},
|
{key: 5, text: '代理:OpenAI-SB', value: 5, color: 'brown'},
|
||||||
{key: 7, text: '代理:OhMyGPT', value: 7, color: 'purple'},
|
{key: 7, text: '代理:OhMyGPT', value: 7, color: 'purple'},
|
||||||
{key: 10, text: '代理:AI Proxy', value: 10, color: 'purple'},
|
{key: 10, text: '代理:AI Proxy', value: 10, color: 'purple'},
|
||||||
{key: 4, text: '代理:CloseAI', value: 4, color: 'teal'},
|
{key: 4, text: '代理:CloseAI', value: 4, color: 'teal'},
|
||||||
{key: 6, text: '代理:OpenAI Max', value: 6, color: 'violet'},
|
{key: 6, text: '代理:OpenAI Max', value: 6, color: 'violet'},
|
||||||
{key: 9, text: '代理:AI.LS', value: 9, color: 'yellow'},
|
{key: 9, text: '代理:AI.LS', value: 9, color: 'yellow'},
|
||||||
{key: 12, text: '代理:API2GPT', value: 12, color: 'blue'},
|
{key: 12, text: '代理:API2GPT', value: 12, color: 'blue'},
|
||||||
{key: 13, text: '代理:AIGC2D', value: 13, color: 'purple'},
|
{key: 13, text: '代理:AIGC2D', value: 13, color: 'purple'},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Label, Message} from 'semantic-ui-react';
|
import { Label, Message } from 'semantic-ui-react';
|
||||||
import {getChannelOption} from './helper';
|
import { getChannelOption } from './helper';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
export function renderText(text, limit) {
|
export function renderText(text, limit) {
|
||||||
@@ -16,7 +16,15 @@ export function renderGroup(group) {
|
|||||||
let groups = group.split(',');
|
let groups = group.split(',');
|
||||||
groups.sort();
|
groups.sort();
|
||||||
return (
|
return (
|
||||||
<>
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
gap: '2px',
|
||||||
|
rowGap: '6px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
{groups.map((group) => {
|
{groups.map((group) => {
|
||||||
if (group === 'vip' || group === 'pro') {
|
if (group === 'vip' || group === 'pro') {
|
||||||
return <Label color='yellow'>{group}</Label>;
|
return <Label color='yellow'>{group}</Label>;
|
||||||
@@ -25,7 +33,7 @@ export function renderGroup(group) {
|
|||||||
}
|
}
|
||||||
return <Label>{group}</Label>;
|
return <Label>{group}</Label>;
|
||||||
})}
|
})}
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,8 +114,8 @@ export function renderChannelTip(channelId) {
|
|||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Message>
|
<Message>
|
||||||
<div dangerouslySetInnerHTML={{__html: channel.tip}}></div>
|
<div dangerouslySetInnerHTML={{ __html: channel.tip }}></div>
|
||||||
</Message>
|
</Message>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { toast } from 'react-toastify';
|
import {toast} from 'react-toastify';
|
||||||
import { toastConstants } from '../constants';
|
import {toastConstants} from '../constants';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { API } from './api';
|
import {API} from './api';
|
||||||
|
|
||||||
const HTMLToastContent = ({ htmlContent }) => {
|
const HTMLToastContent = ({ htmlContent }) => {
|
||||||
return <div dangerouslySetInnerHTML={{ __html: htmlContent }} />;
|
return <div dangerouslySetInnerHTML={{ __html: htmlContent }} />;
|
||||||
@@ -74,6 +74,7 @@ if (isMobile()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function showError(error) {
|
export function showError(error) {
|
||||||
|
if (!error) return;
|
||||||
console.error(error);
|
console.error(error);
|
||||||
if (error.message) {
|
if (error.message) {
|
||||||
if (error.name === 'AxiosError') {
|
if (error.name === 'AxiosError') {
|
||||||
@@ -158,17 +159,7 @@ export function timestamp2string(timestamp) {
|
|||||||
second = '0' + second;
|
second = '0' + second;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
year +
|
year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second
|
||||||
'-' +
|
|
||||||
month +
|
|
||||||
'-' +
|
|
||||||
day +
|
|
||||||
' ' +
|
|
||||||
hour +
|
|
||||||
':' +
|
|
||||||
minute +
|
|
||||||
':' +
|
|
||||||
second
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +184,6 @@ export const verifyJSON = (str) => {
|
|||||||
export function shouldShowPrompt(id) {
|
export function shouldShowPrompt(id) {
|
||||||
let prompt = localStorage.getItem(`prompt-${id}`);
|
let prompt = localStorage.getItem(`prompt-${id}`);
|
||||||
return !prompt;
|
return !prompt;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setPromptShown(id) {
|
export function setPromptShown(id) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, {useEffect, useState} from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import {useTranslation} from 'react-i18next';
|
||||||
import { Card, Grid } from 'semantic-ui-react';
|
import {Card, Grid} from 'semantic-ui-react';
|
||||||
import {
|
import {
|
||||||
Bar,
|
Bar,
|
||||||
BarChart,
|
BarChart,
|
||||||
@@ -122,11 +122,11 @@ const Dashboard = () => {
|
|||||||
? new Date(Math.min(...dates.map((d) => new Date(d))))
|
? new Date(Math.min(...dates.map((d) => new Date(d))))
|
||||||
: new Date();
|
: new Date();
|
||||||
|
|
||||||
// 确保至少显示5天的数据
|
// 确保至少显示7天的数据
|
||||||
const fiveDaysAgo = new Date();
|
const sevenDaysAgo = new Date();
|
||||||
fiveDaysAgo.setDate(fiveDaysAgo.getDate() - 4); // -4是因为包含今天
|
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 6); // -6是因为包含今天
|
||||||
if (minDate > fiveDaysAgo) {
|
if (minDate > sevenDaysAgo) {
|
||||||
minDate = fiveDaysAgo;
|
minDate = sevenDaysAgo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成所有日期
|
// 生成所有日期
|
||||||
@@ -164,11 +164,11 @@ const Dashboard = () => {
|
|||||||
? new Date(Math.min(...dates.map((d) => new Date(d))))
|
? new Date(Math.min(...dates.map((d) => new Date(d))))
|
||||||
: new Date();
|
: new Date();
|
||||||
|
|
||||||
// 确保至少显示5天的数据
|
// 确保至少显示7天的数据
|
||||||
const fiveDaysAgo = new Date();
|
const sevenDaysAgo = new Date();
|
||||||
fiveDaysAgo.setDate(fiveDaysAgo.getDate() - 4); // -4是因为包含今天
|
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 6); // -6是因为包含今天
|
||||||
if (minDate > fiveDaysAgo) {
|
if (minDate > sevenDaysAgo) {
|
||||||
minDate = fiveDaysAgo;
|
minDate = sevenDaysAgo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成所有日期
|
// 生成所有日期
|
||||||
|
|||||||
Reference in New Issue
Block a user