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

View File

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

View File

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

View File

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