diff --git a/controller/misc.go b/controller/misc.go
index 6219676e7..e76ca51bb 100644
--- a/controller/misc.go
+++ b/controller/misc.go
@@ -115,7 +115,7 @@ func GetStatus(c *gin.Context) {
"user_agreement_enabled": legalSetting.UserAgreement != "",
"privacy_policy_enabled": legalSetting.PrivacyPolicy != "",
"checkin_enabled": operation_setting.GetCheckinSetting().Enabled,
- "_qn": "new-api",
+ "_qn": "new-api",
}
// 根据启用状态注入可选内容
diff --git a/controller/performance.go b/controller/performance.go
index c7e853548..a6fedc46c 100644
--- a/controller/performance.go
+++ b/controller/performance.go
@@ -91,11 +91,11 @@ func GetPerformanceStats(c *gin.Context) {
// 获取配置信息
diskConfig := common.GetDiskCacheConfig()
config := PerformanceConfig{
- DiskCacheEnabled: diskConfig.Enabled,
- DiskCacheThresholdMB: diskConfig.ThresholdMB,
- DiskCacheMaxSizeMB: diskConfig.MaxSizeMB,
- DiskCachePath: diskConfig.Path,
- IsRunningInContainer: common.IsRunningInContainer(),
+ DiskCacheEnabled: diskConfig.Enabled,
+ DiskCacheThresholdMB: diskConfig.ThresholdMB,
+ DiskCacheMaxSizeMB: diskConfig.MaxSizeMB,
+ DiskCachePath: diskConfig.Path,
+ IsRunningInContainer: common.IsRunningInContainer(),
}
// 获取磁盘空间信息
@@ -199,4 +199,3 @@ func getDiskCacheInfo() DiskCacheInfo {
return info
}
-
diff --git a/controller/subscription.go b/controller/subscription.go
index 5a6f88d66..b4561fe45 100644
--- a/controller/subscription.go
+++ b/controller/subscription.go
@@ -15,8 +15,8 @@ import (
// ---- Shared types ----
type SubscriptionPlanDTO struct {
- Plan model.SubscriptionPlan `json:"plan"`
- Items []model.SubscriptionPlanItem `json:"items"`
+ Plan model.SubscriptionPlan `json:"plan"`
+ Items []model.SubscriptionPlanItem `json:"items"`
}
type BillingPreferenceRequest struct {
diff --git a/controller/subscription_payment_creem.go b/controller/subscription_payment_creem.go
index 5927a7002..f5888b8e9 100644
--- a/controller/subscription_payment_creem.go
+++ b/controller/subscription_payment_creem.go
@@ -97,4 +97,3 @@ func SubscriptionRequestCreemPay(c *gin.Context) {
},
})
}
-
diff --git a/controller/subscription_payment_epay.go b/controller/subscription_payment_epay.go
index 0e287a211..fc24337b1 100644
--- a/controller/subscription_payment_epay.go
+++ b/controller/subscription_payment_epay.go
@@ -7,12 +7,12 @@ import (
"strconv"
"time"
+ "github.com/Calcium-Ion/go-epay/epay"
"github.com/QuantumNous/new-api/common"
"github.com/QuantumNous/new-api/model"
"github.com/QuantumNous/new-api/service"
"github.com/QuantumNous/new-api/setting/operation_setting"
"github.com/QuantumNous/new-api/setting/system_setting"
- "github.com/Calcium-Ion/go-epay/epay"
"github.com/gin-gonic/gin"
"github.com/samber/lo"
)
@@ -151,4 +151,3 @@ func SubscriptionEpayReturn(c *gin.Context) {
}
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/topup?pay=pending")
}
-
diff --git a/controller/subscription_payment_stripe.go b/controller/subscription_payment_stripe.go
index 367fca9dc..b7ffde46e 100644
--- a/controller/subscription_payment_stripe.go
+++ b/controller/subscription_payment_stripe.go
@@ -116,4 +116,3 @@ func genStripeSubscriptionLink(referenceId string, customerId string, email stri
}
return result.URL, nil
}
-
diff --git a/controller/topup_stripe.go b/controller/topup_stripe.go
index 3fa605f17..4a4c4102c 100644
--- a/controller/topup_stripe.go
+++ b/controller/topup_stripe.go
@@ -169,10 +169,10 @@ func sessionCompleted(event stripe.Event) {
// Subscription order takes precedence
if model.GetSubscriptionOrderByTradeNo(referenceId) != nil {
payload := map[string]any{
- "customer": customerId,
+ "customer": customerId,
"amount_total": event.GetObjectValue("amount_total"),
- "currency": strings.ToUpper(event.GetObjectValue("currency")),
- "event_type": string(event.Type),
+ "currency": strings.ToUpper(event.GetObjectValue("currency")),
+ "event_type": string(event.Type),
}
if err := model.CompleteSubscriptionOrder(referenceId, jsonString(payload)); err != nil {
log.Println("complete subscription order failed:", err.Error(), referenceId)
diff --git a/main.go b/main.go
index ae391ac3c..23953b877 100644
--- a/main.go
+++ b/main.go
@@ -19,8 +19,8 @@ import (
"github.com/QuantumNous/new-api/model"
"github.com/QuantumNous/new-api/router"
"github.com/QuantumNous/new-api/service"
- "github.com/QuantumNous/new-api/setting/ratio_setting"
_ "github.com/QuantumNous/new-api/setting/performance_setting" // 注册性能设置
+ "github.com/QuantumNous/new-api/setting/ratio_setting"
"github.com/bytedance/gopkg/util/gopool"
"github.com/gin-contrib/sessions"
diff --git a/model/subscription.go b/model/subscription.go
index 26518512a..fcbd4d00b 100644
--- a/model/subscription.go
+++ b/model/subscription.go
@@ -36,7 +36,7 @@ type SubscriptionPlan struct {
Enabled bool `json:"enabled" gorm:"default:true"`
SortOrder int `json:"sort_order" gorm:"type:int;default:0"`
- StripePriceId string `json:"stripe_price_id" gorm:"type:varchar(128);default:''"`
+ StripePriceId string `json:"stripe_price_id" gorm:"type:varchar(128);default:''"`
CreemProductId string `json:"creem_product_id" gorm:"type:varchar(128);default:''"`
CreatedAt int64 `json:"created_at" gorm:"bigint"`
@@ -69,9 +69,9 @@ type SubscriptionPlanItem struct {
// Subscription order (payment -> webhook -> create UserSubscription)
type SubscriptionOrder struct {
- Id int `json:"id"`
- UserId int `json:"user_id" gorm:"index"`
- PlanId int `json:"plan_id" gorm:"index"`
+ Id int `json:"id"`
+ UserId int `json:"user_id" gorm:"index"`
+ PlanId int `json:"plan_id" gorm:"index"`
Money float64 `json:"money"`
TradeNo string `json:"trade_no" gorm:"unique;type:varchar(255);index"`
@@ -134,8 +134,8 @@ func (s *UserSubscription) BeforeUpdate(tx *gorm.DB) error {
}
type UserSubscriptionItem struct {
- Id int `json:"id"`
- UserSubscriptionId int `json:"user_subscription_id" gorm:"index"`
+ Id int `json:"id"`
+ UserSubscriptionId int `json:"user_subscription_id" gorm:"index"`
ModelName string `json:"model_name" gorm:"type:varchar(128);index"`
QuotaType int `json:"quota_type" gorm:"type:int;index"`
AmountTotal int64 `json:"amount_total" gorm:"type:bigint;not null;default:0"`
@@ -211,14 +211,14 @@ func CreateUserSubscriptionFromPlanTx(tx *gorm.DB, userId int, plan *Subscriptio
return nil, err
}
sub := &UserSubscription{
- UserId: userId,
- PlanId: plan.Id,
- StartTime: now.Unix(),
- EndTime: endUnix,
- Status: "active",
- Source: source,
- CreatedAt: common.GetTimestamp(),
- UpdatedAt: common.GetTimestamp(),
+ UserId: userId,
+ PlanId: plan.Id,
+ StartTime: now.Unix(),
+ EndTime: endUnix,
+ Status: "active",
+ Source: source,
+ CreatedAt: common.GetTimestamp(),
+ UpdatedAt: common.GetTimestamp(),
}
if err := tx.Create(sub).Error; err != nil {
return nil, err
@@ -586,4 +586,3 @@ func PostConsumeUserSubscriptionDelta(itemId int, delta int64) error {
return tx.Save(&item).Error
})
}
-
diff --git a/relay/channel/ali/adaptor.go b/relay/channel/ali/adaptor.go
index 23ef5f4be..17869a06d 100644
--- a/relay/channel/ali/adaptor.go
+++ b/relay/channel/ali/adaptor.go
@@ -13,8 +13,8 @@ import (
"github.com/QuantumNous/new-api/relay/channel/openai"
relaycommon "github.com/QuantumNous/new-api/relay/common"
"github.com/QuantumNous/new-api/relay/constant"
- "github.com/QuantumNous/new-api/setting/model_setting"
"github.com/QuantumNous/new-api/service"
+ "github.com/QuantumNous/new-api/setting/model_setting"
"github.com/QuantumNous/new-api/types"
"github.com/gin-gonic/gin"
diff --git a/relay/common/relay_info.go b/relay/common/relay_info.go
index 8363b6040..7a3aad333 100644
--- a/relay/common/relay_info.go
+++ b/relay/common/relay_info.go
@@ -113,7 +113,7 @@ type RelayInfo struct {
UserQuota int
RelayFormat types.RelayFormat
SendResponseCount int
- FinalPreConsumedQuota int // 最终预消耗的配额
+ FinalPreConsumedQuota int // 最终预消耗的配额
// BillingSource indicates whether this request is billed from wallet quota or subscription.
// "" or "wallet" => wallet; "subscription" => subscription
BillingSource string
@@ -130,10 +130,10 @@ type RelayInfo struct {
SubscriptionPlanId int
SubscriptionPlanTitle string
// SubscriptionAmountTotal / SubscriptionAmountUsedAfterPreConsume are used to compute remaining in logs.
- SubscriptionAmountTotal int64
+ SubscriptionAmountTotal int64
SubscriptionAmountUsedAfterPreConsume int64
- IsClaudeBetaQuery bool // /v1/messages?beta=true
- IsChannelTest bool // channel test request
+ IsClaudeBetaQuery bool // /v1/messages?beta=true
+ IsChannelTest bool // channel test request
PriceData types.PriceData
diff --git a/service/billing.go b/service/billing.go
index 7a7be40fc..84b329f72 100644
--- a/service/billing.go
+++ b/service/billing.go
@@ -114,4 +114,3 @@ func PreConsumeBilling(c *gin.Context, preConsumedQuota int, relayInfo *relaycom
return nil
}
}
-
diff --git a/web/i18next.config.js b/web/i18next.config.js
index 4e138bdfc..40808629b 100644
--- a/web/i18next.config.js
+++ b/web/i18next.config.js
@@ -21,77 +21,66 @@ import { defineConfig } from 'i18next-cli';
/** @type {import('i18next-cli').I18nextToolkitConfig} */
export default defineConfig({
- locales: [
- "zh",
- "en",
- "fr",
- "ru",
- "ja",
- "vi"
- ],
+ locales: ['zh', 'en', 'fr', 'ru', 'ja', 'vi'],
extract: {
- input: [
- "src/**/*.{js,jsx,ts,tsx}"
- ],
- ignore: [
- "src/i18n/**/*"
- ],
- output: "src/i18n/locales/{{language}}.json",
+ input: ['src/**/*.{js,jsx,ts,tsx}'],
+ ignore: ['src/i18n/**/*'],
+ output: 'src/i18n/locales/{{language}}.json',
ignoredAttributes: [
- "accept",
- "align",
- "aria-label",
- "autoComplete",
- "className",
- "clipRule",
- "color",
- "crossOrigin",
- "data-index",
- "data-name",
- "data-testid",
- "data-type",
- "defaultActiveKey",
- "direction",
- "editorType",
- "field",
- "fill",
- "fillRule",
- "height",
- "hoverStyle",
- "htmlType",
- "id",
- "itemKey",
- "key",
- "keyPrefix",
- "layout",
- "margin",
- "maxHeight",
- "mode",
- "name",
- "overflow",
- "placement",
- "position",
- "rel",
- "role",
- "rowKey",
- "searchPosition",
- "selectedStyle",
- "shape",
- "size",
- "style",
- "theme",
- "trigger",
- "uploadTrigger",
- "validateStatus",
- "value",
- "viewBox",
- "width"
+ 'accept',
+ 'align',
+ 'aria-label',
+ 'autoComplete',
+ 'className',
+ 'clipRule',
+ 'color',
+ 'crossOrigin',
+ 'data-index',
+ 'data-name',
+ 'data-testid',
+ 'data-type',
+ 'defaultActiveKey',
+ 'direction',
+ 'editorType',
+ 'field',
+ 'fill',
+ 'fillRule',
+ 'height',
+ 'hoverStyle',
+ 'htmlType',
+ 'id',
+ 'itemKey',
+ 'key',
+ 'keyPrefix',
+ 'layout',
+ 'margin',
+ 'maxHeight',
+ 'mode',
+ 'name',
+ 'overflow',
+ 'placement',
+ 'position',
+ 'rel',
+ 'role',
+ 'rowKey',
+ 'searchPosition',
+ 'selectedStyle',
+ 'shape',
+ 'size',
+ 'style',
+ 'theme',
+ 'trigger',
+ 'uploadTrigger',
+ 'validateStatus',
+ 'value',
+ 'viewBox',
+ 'width',
],
sort: true,
disablePlurals: false,
removeUnusedKeys: false,
nsSeparator: false,
keySeparator: false,
- mergeNamespaces: true
- }
-});
\ No newline at end of file
+ mergeNamespaces: true,
+ },
+});
diff --git a/web/src/components/auth/LoginForm.jsx b/web/src/components/auth/LoginForm.jsx
index 5111f1f68..134451ec3 100644
--- a/web/src/components/auth/LoginForm.jsx
+++ b/web/src/components/auth/LoginForm.jsx
@@ -39,7 +39,15 @@ import {
isPasskeySupported,
} from '../../helpers';
import Turnstile from 'react-turnstile';
-import { Button, Card, Checkbox, Divider, Form, Icon, Modal } from '@douyinfe/semi-ui';
+import {
+ Button,
+ Card,
+ Checkbox,
+ Divider,
+ Form,
+ Icon,
+ Modal,
+} from '@douyinfe/semi-ui';
import Title from '@douyinfe/semi-ui/lib/es/typography/title';
import Text from '@douyinfe/semi-ui/lib/es/typography/text';
import TelegramLoginButton from 'react-telegram-login';
@@ -55,7 +63,7 @@ import WeChatIcon from '../common/logo/WeChatIcon';
import LinuxDoIcon from '../common/logo/LinuxDoIcon';
import TwoFAVerification from './TwoFAVerification';
import { useTranslation } from 'react-i18next';
-import { SiDiscord }from 'react-icons/si';
+import { SiDiscord } from 'react-icons/si';
const LoginForm = () => {
let navigate = useNavigate();
@@ -126,7 +134,7 @@ const LoginForm = () => {
setTurnstileEnabled(true);
setTurnstileSiteKey(status.turnstile_site_key);
}
-
+
// 从 status 获取用户协议和隐私政策的启用状态
setHasUserAgreement(status?.user_agreement_enabled || false);
setHasPrivacyPolicy(status?.privacy_policy_enabled || false);
@@ -514,7 +522,15 @@ const LoginForm = () => {
theme='outline'
className='w-full h-12 flex items-center justify-center !rounded-full border border-gray-200 hover:bg-gray-50 transition-colors'
type='tertiary'
- icon={}
+ icon={
+
+ }
onClick={handleDiscordClick}
loading={discordLoading}
>
@@ -626,11 +642,11 @@ const LoginForm = () => {
{t('隐私政策')}
>
- )}
-
-
-
- )}
+ )}
+
+
+
+ )}
{!status.self_use_mode_enabled && (
@@ -746,7 +762,9 @@ const LoginForm = () => {
htmlType='submit'
onClick={handleSubmit}
loading={loginLoading}
- disabled={(hasUserAgreement || hasPrivacyPolicy) && !agreedToTerms}
+ disabled={
+ (hasUserAgreement || hasPrivacyPolicy) && !agreedToTerms
+ }
>
{t('继续')}
diff --git a/web/src/components/common/DocumentRenderer/index.jsx b/web/src/components/common/DocumentRenderer/index.jsx
index 383afc11d..68e868c51 100644
--- a/web/src/components/common/DocumentRenderer/index.jsx
+++ b/web/src/components/common/DocumentRenderer/index.jsx
@@ -41,7 +41,7 @@ const isUrl = (content) => {
// 检查是否为 HTML 内容
const isHtmlContent = (content) => {
if (!content || typeof content !== 'string') return false;
-
+
// 检查是否包含HTML标签
const htmlTagRegex = /<\/?[a-z][\s\S]*>/i;
return htmlTagRegex.test(content);
@@ -52,16 +52,16 @@ const sanitizeHtml = (html) => {
// 创建一个临时元素来解析HTML
const tempDiv = document.createElement('div');
tempDiv.innerHTML = html;
-
+
// 提取样式
const styles = Array.from(tempDiv.querySelectorAll('style'))
- .map(style => style.innerHTML)
+ .map((style) => style.innerHTML)
.join('\n');
-
+
// 提取body内容,如果没有body标签则使用全部内容
const bodyContent = tempDiv.querySelector('body');
const content = bodyContent ? bodyContent.innerHTML : html;
-
+
return { content, styles };
};
@@ -129,7 +129,7 @@ const DocumentRenderer = ({ apiEndpoint, title, cacheKey, emptyMessage }) => {
// 处理HTML样式注入
useEffect(() => {
const styleId = `document-renderer-styles-${cacheKey}`;
-
+
if (htmlStyles) {
let styleEl = document.getElementById(styleId);
if (!styleEl) {
@@ -165,8 +165,12 @@ const DocumentRenderer = ({ apiEndpoint, title, cacheKey, emptyMessage }) => {
}
- darkModeImage={}
+ image={
+
+ }
+ darkModeImage={
+
+ }
className='p-8'
/>
@@ -179,7 +183,9 @@ const DocumentRenderer = ({ apiEndpoint, title, cacheKey, emptyMessage }) => {
-
{title}
+
+ {title}
+
{t('管理员设置了外部链接,点击下方按钮访问')}
@@ -202,20 +208,22 @@ const DocumentRenderer = ({ apiEndpoint, title, cacheKey, emptyMessage }) => {
// 如果是 HTML 内容,直接渲染
if (isHtmlContent(content)) {
const { content: htmlContent, styles } = sanitizeHtml(content);
-
+
// 设置样式(如果有的话)
useEffect(() => {
if (styles && styles !== htmlStyles) {
setHtmlStyles(styles);
}
}, [content, styles, htmlStyles]);
-
+
return (
-
{title}
-
+ {title}
+
+
@@ -230,7 +238,9 @@ const DocumentRenderer = ({ apiEndpoint, title, cacheKey, emptyMessage }) => {
-
{title}
+
+ {title}
+
@@ -240,4 +250,4 @@ const DocumentRenderer = ({ apiEndpoint, title, cacheKey, emptyMessage }) => {
);
};
-export default DocumentRenderer;
\ No newline at end of file
+export default DocumentRenderer;
diff --git a/web/src/components/layout/SiderBar.jsx b/web/src/components/layout/SiderBar.jsx
index d544408a7..34971c397 100644
--- a/web/src/components/layout/SiderBar.jsx
+++ b/web/src/components/layout/SiderBar.jsx
@@ -51,7 +51,7 @@ const routerMap = {
personal: '/console/personal',
};
-const SiderBar = ({ onNavigate = () => { } }) => {
+const SiderBar = ({ onNavigate = () => {} }) => {
const { t } = useTranslation();
const [collapsed, toggleCollapsed] = useSidebarCollapsed();
const {
diff --git a/web/src/components/layout/components/SkeletonWrapper.jsx b/web/src/components/layout/components/SkeletonWrapper.jsx
index eec4be9a7..3d4981668 100644
--- a/web/src/components/layout/components/SkeletonWrapper.jsx
+++ b/web/src/components/layout/components/SkeletonWrapper.jsx
@@ -136,9 +136,7 @@ const SkeletonWrapper = ({
loading={true}
active
placeholder={
-
+
}
/>
@@ -186,7 +184,9 @@ const SkeletonWrapper = ({
loading={true}
active
placeholder={
-
+
}
/>
@@ -221,9 +221,7 @@ const SkeletonWrapper = ({
loading={true}
active
placeholder={
-
+
}
/>
);
diff --git a/web/src/components/playground/CustomInputRender.jsx b/web/src/components/playground/CustomInputRender.jsx
index f83d6bcbf..c995773a7 100644
--- a/web/src/components/playground/CustomInputRender.jsx
+++ b/web/src/components/playground/CustomInputRender.jsx
@@ -30,64 +30,67 @@ const CustomInputRender = (props) => {
detailProps;
const containerRef = useRef(null);
- const handlePaste = useCallback(async (e) => {
- const items = e.clipboardData?.items;
- if (!items) return;
+ const handlePaste = useCallback(
+ async (e) => {
+ const items = e.clipboardData?.items;
+ if (!items) return;
- for (let i = 0; i < items.length; i++) {
- const item = items[i];
-
- if (item.type.indexOf('image') !== -1) {
- e.preventDefault();
- const file = item.getAsFile();
-
- if (file) {
- try {
- if (!imageEnabled) {
- Toast.warning({
- content: t('请先在设置中启用图片功能'),
- duration: 3,
- });
- return;
- }
+ for (let i = 0; i < items.length; i++) {
+ const item = items[i];
- const reader = new FileReader();
- reader.onload = (event) => {
- const base64 = event.target.result;
-
- if (onPasteImage) {
- onPasteImage(base64);
- Toast.success({
- content: t('图片已添加'),
- duration: 2,
- });
- } else {
- Toast.error({
- content: t('无法添加图片'),
- duration: 2,
+ if (item.type.indexOf('image') !== -1) {
+ e.preventDefault();
+ const file = item.getAsFile();
+
+ if (file) {
+ try {
+ if (!imageEnabled) {
+ Toast.warning({
+ content: t('请先在设置中启用图片功能'),
+ duration: 3,
});
+ return;
}
- };
- reader.onerror = () => {
- console.error('Failed to read image file:', reader.error);
+
+ const reader = new FileReader();
+ reader.onload = (event) => {
+ const base64 = event.target.result;
+
+ if (onPasteImage) {
+ onPasteImage(base64);
+ Toast.success({
+ content: t('图片已添加'),
+ duration: 2,
+ });
+ } else {
+ Toast.error({
+ content: t('无法添加图片'),
+ duration: 2,
+ });
+ }
+ };
+ reader.onerror = () => {
+ console.error('Failed to read image file:', reader.error);
+ Toast.error({
+ content: t('粘贴图片失败'),
+ duration: 2,
+ });
+ };
+ reader.readAsDataURL(file);
+ } catch (error) {
+ console.error('Failed to paste image:', error);
Toast.error({
content: t('粘贴图片失败'),
duration: 2,
});
- };
- reader.readAsDataURL(file);
- } catch (error) {
- console.error('Failed to paste image:', error);
- Toast.error({
- content: t('粘贴图片失败'),
- duration: 2,
- });
+ }
}
+ break;
}
- break;
}
- }
- }, [onPasteImage, imageEnabled, t]);
+ },
+ [onPasteImage, imageEnabled, t],
+ );
useEffect(() => {
const container = containerRef.current;
diff --git a/web/src/components/playground/CustomRequestEditor.jsx b/web/src/components/playground/CustomRequestEditor.jsx
index 786ccdc4a..68f0ae871 100644
--- a/web/src/components/playground/CustomRequestEditor.jsx
+++ b/web/src/components/playground/CustomRequestEditor.jsx
@@ -140,7 +140,9 @@ const CustomRequestEditor = ({
{/* 提示信息 */}
}
className='!rounded-lg'
closeIcon={null}
@@ -201,7 +203,9 @@ const CustomRequestEditor = ({
)}
- {t('请输入有效的JSON格式的请求体。您可以参考预览面板中的默认请求体格式。')}
+ {t(
+ '请输入有效的JSON格式的请求体。您可以参考预览面板中的默认请求体格式。',
+ )}
>
diff --git a/web/src/components/playground/DebugPanel.jsx b/web/src/components/playground/DebugPanel.jsx
index ee4a0b60d..28de0153b 100644
--- a/web/src/components/playground/DebugPanel.jsx
+++ b/web/src/components/playground/DebugPanel.jsx
@@ -191,10 +191,7 @@ const DebugPanel = ({
itemKey='response'
>
{debugData.sseMessages && debugData.sseMessages.length > 0 ? (
-
+
) : (
{
const stats = useMemo(() => {
const total = parsedSSEData.length;
- const errors = parsedSSEData.filter(item => item.error).length;
- const done = parsedSSEData.filter(item => item.isDone).length;
+ const errors = parsedSSEData.filter((item) => item.error).length;
+ const done = parsedSSEData.filter((item) => item.isDone).length;
const valid = total - errors - done;
return { total, errors, done, valid };
}, [parsedSSEData]);
const handleToggleAll = useCallback(() => {
- setExpandedKeys(prev => {
+ setExpandedKeys((prev) => {
if (prev.length === parsedSSEData.length) {
return [];
} else {
- return parsedSSEData.map(item => item.key);
+ return parsedSSEData.map((item) => item.key);
}
});
}, [parsedSSEData]);
@@ -87,7 +101,9 @@ const SSEViewer = ({ sseData }) => {
const handleCopyAll = useCallback(async () => {
try {
const allData = parsedSSEData
- .map(item => (item.parsed ? JSON.stringify(item.parsed, null, 2) : item.raw))
+ .map((item) =>
+ item.parsed ? JSON.stringify(item.parsed, null, 2) : item.raw,
+ )
.join('\n\n');
await copy(allData);
@@ -100,15 +116,20 @@ const SSEViewer = ({ sseData }) => {
}
}, [parsedSSEData, t]);
- const handleCopySingle = useCallback(async (item) => {
- try {
- const textToCopy = item.parsed ? JSON.stringify(item.parsed, null, 2) : item.raw;
- await copy(textToCopy);
- Toast.success(t('已复制'));
- } catch (err) {
- Toast.error(t('复制失败'));
- }
- }, [t]);
+ const handleCopySingle = useCallback(
+ async (item) => {
+ try {
+ const textToCopy = item.parsed
+ ? JSON.stringify(item.parsed, null, 2)
+ : item.raw;
+ await copy(textToCopy);
+ Toast.success(t('已复制'));
+ } catch (err) {
+ Toast.error(t('复制失败'));
+ }
+ },
+ [t],
+ );
const renderSSEItem = (item) => {
if (item.isDone) {
@@ -158,18 +179,24 @@ const SSEViewer = ({ sseData }) => {
{item.parsed?.choices?.[0] && (
{item.parsed.choices[0].delta?.content && (
-
+
)}
{item.parsed.choices[0].delta?.reasoning_content && (
)}
{item.parsed.choices[0].finish_reason && (
-
+
)}
{item.parsed.usage && (
-
)}
@@ -194,7 +221,9 @@ const SSEViewer = ({ sseData }) => {
{t('SSE数据流')}
- {stats.errors > 0 && }
+ {stats.errors > 0 && (
+
+ )}
@@ -208,14 +237,28 @@ const SSEViewer = ({ sseData }) => {
{copied ? t('已复制') : t('复制全部')}
-
+
: }
+ icon={
+ expandedKeys.length === parsedSSEData.length ? (
+
+ ) : (
+
+ )
+ }
size='small'
onClick={handleToggleAll}
theme='borderless'
>
- {expandedKeys.length === parsedSSEData.length ? t('收起') : t('展开')}
+ {expandedKeys.length === parsedSSEData.length
+ ? t('收起')
+ : t('展开')}
@@ -242,11 +285,16 @@ const SSEViewer = ({ sseData }) => {
) : (
<>
- {item.parsed?.id || item.parsed?.object || t('SSE 事件')}
+ {item.parsed?.id ||
+ item.parsed?.object ||
+ t('SSE 事件')}
{item.parsed?.choices?.[0]?.delta && (
- • {Object.keys(item.parsed.choices[0].delta).filter(k => item.parsed.choices[0].delta[k]).join(', ')}
+ •{' '}
+ {Object.keys(item.parsed.choices[0].delta)
+ .filter((k) => item.parsed.choices[0].delta[k])
+ .join(', ')}
)}
>
diff --git a/web/src/components/settings/HttpStatusCodeRulesInput.jsx b/web/src/components/settings/HttpStatusCodeRulesInput.jsx
index 361bc19e6..5faf93af9 100644
--- a/web/src/components/settings/HttpStatusCodeRulesInput.jsx
+++ b/web/src/components/settings/HttpStatusCodeRulesInput.jsx
@@ -68,4 +68,3 @@ export default function HttpStatusCodeRulesInput(props) {
>
);
}
-
diff --git a/web/src/components/settings/ModelDeploymentSetting.jsx b/web/src/components/settings/ModelDeploymentSetting.jsx
index 941f640a4..c872f631d 100644
--- a/web/src/components/settings/ModelDeploymentSetting.jsx
+++ b/web/src/components/settings/ModelDeploymentSetting.jsx
@@ -40,7 +40,7 @@ const ModelDeploymentSetting = () => {
'model_deployment.ionet.api_key': '',
'model_deployment.ionet.enabled': false,
};
-
+
data.forEach((item) => {
if (item.key.endsWith('Enabled') || item.key.endsWith('enabled')) {
newInputs[item.key] = toBoolean(item.value);
@@ -82,4 +82,4 @@ const ModelDeploymentSetting = () => {
);
};
-export default ModelDeploymentSetting;
\ No newline at end of file
+export default ModelDeploymentSetting;
diff --git a/web/src/components/settings/OperationSetting.jsx b/web/src/components/settings/OperationSetting.jsx
index 9ee5fd007..171c29f26 100644
--- a/web/src/components/settings/OperationSetting.jsx
+++ b/web/src/components/settings/OperationSetting.jsx
@@ -71,7 +71,8 @@ const OperationSetting = () => {
AutomaticEnableChannelEnabled: false,
AutomaticDisableKeywords: '',
AutomaticDisableStatusCodes: '401',
- AutomaticRetryStatusCodes: '100-199,300-399,401-407,409-499,500-503,505-523,525-599',
+ AutomaticRetryStatusCodes:
+ '100-199,300-399,401-407,409-499,500-503,505-523,525-599',
'monitor_setting.auto_test_channel_enabled': false,
'monitor_setting.auto_test_channel_minutes': 10 /* 签到设置 */,
'checkin_setting.enabled': false,
diff --git a/web/src/components/settings/OtherSetting.jsx b/web/src/components/settings/OtherSetting.jsx
index 646d21e74..f8e0b5375 100644
--- a/web/src/components/settings/OtherSetting.jsx
+++ b/web/src/components/settings/OtherSetting.jsx
@@ -378,13 +378,15 @@ const OtherSetting = () => {