Merge pull request #98 from songquanpeng/main

Fork Sync: Update from parent repository
This commit is contained in:
quzard 2023-07-02 16:21:47 +08:00 committed by GitHub
commit 3f3b549ec6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"github.com/gin-gonic/gin"
"net/http"
"one-api/common"
"os"
"strings"
)
@ -14,6 +15,10 @@ func SetRouter(router *gin.Engine, buildFS embed.FS, indexPage []byte) {
SetDashboardRouter(router)
SetRelayRouter(router)
frontendBaseUrl := os.Getenv("FRONTEND_BASE_URL")
if common.IsMasterNode && frontendBaseUrl != "" {
frontendBaseUrl = ""
common.SysLog("FRONTEND_BASE_URL is ignored on master node")
}
if frontendBaseUrl == "" {
SetWebRouter(router, buildFS, indexPage)
} else {

View File

@ -60,8 +60,8 @@ const ChannelsTable = () => {
if (startIdx === 0) {
setChannels(data);
} else {
let newChannels = channels;
newChannels.push(...data);
let newChannels = [...channels];
newChannels.splice(startIdx * ITEMS_PER_PAGE, data.length, ...data);
setChannels(newChannels);
}
} else {
@ -82,7 +82,7 @@ const ChannelsTable = () => {
const refresh = async () => {
setLoading(true);
await loadChannels(0);
await loadChannels(activePage - 1);
};
useEffect(() => {
@ -240,7 +240,7 @@ const ChannelsTable = () => {
if (channels.length === 0) return;
setLoading(true);
let sortedChannels = [...channels];
if (typeof sortedChannels[0][key] === 'string'){
if (typeof sortedChannels[0][key] === 'string') {
sortedChannels.sort((a, b) => {
return ('' + a[key]).localeCompare(b[key]);
});

View File

@ -109,7 +109,7 @@ const LogsTable = () => {
setLogs(data);
} else {
let newLogs = [...logs];
newLogs.push(...data);
newLogs.splice(startIdx * ITEMS_PER_PAGE, data.length, ...data);
setLogs(newLogs);
}
} else {

View File

@ -45,8 +45,8 @@ const TokensTable = () => {
if (startIdx === 0) {
setTokens(data);
} else {
let newTokens = tokens;
newTokens.push(...data);
let newTokens = [...tokens];
newTokens.splice(startIdx * ITEMS_PER_PAGE, data.length, ...data);
setTokens(newTokens);
}
} else {
@ -67,7 +67,7 @@ const TokensTable = () => {
const refresh = async () => {
setLoading(true);
await loadTokens(0);
await loadTokens(activePage - 1);
}
useEffect(() => {