♻️ refactor(helpers): refactor the helpers folder and related imports

This commit is contained in:
Apple\Apple
2025-06-03 23:56:39 +08:00
parent a7535aab99
commit 64b565dc15
39 changed files with 523 additions and 589 deletions

View File

@@ -5,14 +5,12 @@ import {
showInfo,
showSuccess,
timestamp2string,
renderGroup,
renderNumberWithPoint,
renderQuota
} from '../helpers';
import { CHANNEL_OPTIONS, ITEMS_PER_PAGE } from '../constants';
import {
renderGroup,
renderNumberWithPoint,
renderQuota,
} from '../helpers/render';
import {
Button,
Divider,
@@ -29,7 +27,7 @@ import {
Typography,
Checkbox,
Card,
Select,
Select
} from '@douyinfe/semi-ui';
import EditChannel from '../pages/Channel/EditChannel';
import {

View File

@@ -3,7 +3,7 @@ import { Link, useNavigate, useLocation } from 'react-router-dom';
import { UserContext } from '../context/User';
import { useSetTheme, useTheme } from '../context/Theme';
import { useTranslation } from 'react-i18next';
import { API, getLogo, getSystemName, showSuccess } from '../helpers';
import { API, getLogo, getSystemName, showSuccess, stringToColor } from '../helpers';
import fireworks from 'react-fireworks';
import { CN, GB } from 'country-flag-icons/react/3x2';
import NoticeModal from './NoticeModal';
@@ -29,7 +29,6 @@ import {
Typography,
Skeleton,
} from '@douyinfe/semi-ui';
import { stringToColor } from '../helpers/render';
import { StatusContext } from '../context/Status/index.js';
import { useStyle, styleActions } from '../context/Style/index.js';

View File

@@ -9,6 +9,7 @@ import {
showSuccess,
updateAPI,
getSystemName,
setUserData
} from '../helpers';
import {
onGitHubOAuthClicked,
@@ -31,7 +32,6 @@ import TelegramLoginButton from 'react-telegram-login';
import { IconGithubLogo, IconMail, IconLock } from '@douyinfe/semi-icons';
import OIDCIcon from './common/logo/OIDCIcon.js';
import WeChatIcon from './common/logo/WeChatIcon.js';
import { setUserData } from '../helpers/data.js';
import LinuxDoIcon from './common/logo/LinuxDoIcon.js';
import { useTranslation } from 'react-i18next';
import Background from '../images/example.png';

View File

@@ -8,6 +8,18 @@ import {
showError,
showSuccess,
timestamp2string,
renderAudioModelPrice,
renderClaudeLogContent,
renderClaudeModelPrice,
renderClaudeModelPriceSimple,
renderGroup,
renderLogContent,
renderModelPrice,
renderModelPriceSimple,
renderNumber,
renderQuota,
stringToColor,
getLogOther
} from '../helpers';
import {
@@ -30,21 +42,7 @@ import {
DatePicker,
} from '@douyinfe/semi-ui';
import { ITEMS_PER_PAGE } from '../constants';
import {
renderAudioModelPrice,
renderClaudeLogContent,
renderClaudeModelPrice,
renderClaudeModelPriceSimple,
renderGroup,
renderLogContent,
renderModelPrice,
renderModelPriceSimple,
renderNumber,
renderQuota,
stringToColor,
} from '../helpers/render';
import Paragraph from '@douyinfe/semi-ui/lib/es/typography/paragraph';
import { getLogOther } from '../helpers/logUtils.js';
import {
IconRefresh,
IconSetting,

View File

@@ -1,9 +1,8 @@
import React, { useContext, useEffect, useState } from 'react';
import { Spin, Typography, Space } from '@douyinfe/semi-ui';
import { useNavigate, useSearchParams } from 'react-router-dom';
import { API, showError, showSuccess, updateAPI } from '../helpers';
import { API, showError, showSuccess, updateAPI, setUserData } from '../helpers';
import { UserContext } from '../context/User';
import { setUserData } from '../helpers/data.js';
const OAuth2Callback = (props) => {
const [searchParams, setSearchParams] = useSearchParams();

View File

@@ -7,8 +7,7 @@ import { ToastContainer } from 'react-toastify';
import React, { useContext, useEffect } from 'react';
import { useStyle } from '../context/Style/index.js';
import { useTranslation } from 'react-i18next';
import { API, getLogo, getSystemName, showError } from '../helpers/index.js';
import { setStatusData } from '../helpers/data.js';
import { API, getLogo, getSystemName, showError, setStatusData } from '../helpers';
import { UserContext } from '../context/User/index.js';
import { StatusContext } from '../context/Status/index.js';
import { useLocation } from 'react-router-dom';

View File

@@ -8,6 +8,10 @@ import {
showError,
showInfo,
showSuccess,
getQuotaPerUnit,
renderQuota,
renderQuotaWithPrompt,
stringToColor
} from '../helpers';
import Turnstile from 'react-turnstile';
import { UserContext } from '../context/User';
@@ -54,12 +58,6 @@ import {
} from '@douyinfe/semi-icons';
import { SiTelegram, SiWechat, SiLinux } from 'react-icons/si';
import { Bell, Shield, Webhook, Globe, Settings, UserPlus, ShieldCheck } from 'lucide-react';
import {
getQuotaPerUnit,
renderQuota,
renderQuotaWithPrompt,
stringToColor,
} from '../helpers/render';
import TelegramLoginButton from 'react-telegram-login';
import { useTranslation } from 'react-i18next';

View File

@@ -5,10 +5,10 @@ import {
showError,
showSuccess,
timestamp2string,
renderQuota
} from '../helpers';
import { ITEMS_PER_PAGE } from '../constants';
import { renderQuota } from '../helpers/render';
import {
Button,
Card,

View File

@@ -8,6 +8,7 @@ import {
showSuccess,
updateAPI,
getSystemName,
setUserData
} from '../helpers';
import Turnstile from 'react-turnstile';
import {
@@ -30,7 +31,6 @@ import OIDCIcon from './common/logo/OIDCIcon.js';
import LinuxDoIcon from './common/logo/LinuxDoIcon.js';
import WeChatIcon from './common/logo/WeChatIcon.js';
import TelegramLoginButton from 'react-telegram-login/src';
import { setUserData } from '../helpers/data.js';
import { UserContext } from '../context/User/index.js';
import { useTranslation } from 'react-i18next';
import Background from '../images/example.png';

View File

@@ -5,12 +5,8 @@ import { StatusContext } from '../context/Status';
import { useTranslation } from 'react-i18next';
import {
API,
getLogo,
getSystemName,
isAdmin,
isMobile,
showError,
showError
} from '../helpers';
import '../index.css';
@@ -39,8 +35,6 @@ import {
Switch,
Divider,
} from '@douyinfe/semi-ui';
import { setStatusData } from '../helpers/data.js';
import { stringToColor } from '../helpers/render.js';
import { useSetTheme, useTheme } from '../context/Theme/index.js';
import { useStyle, styleActions } from '../context/Style/index.js';
import Text from '@douyinfe/semi-ui/lib/es/typography/text';

View File

@@ -13,12 +13,12 @@ import {
} from '@douyinfe/semi-ui';
const { Text } = Typography;
import {
API,
removeTrailingSlash,
showError,
showSuccess,
verifyJSON,
} from '../helpers/utils';
import { API } from '../helpers/api';
verifyJSON
} from '../helpers';
import axios from 'axios';
const SystemSetting = () => {

View File

@@ -6,10 +6,11 @@ import {
showError,
showSuccess,
timestamp2string,
renderGroup,
renderQuota
} from '../helpers';
import { ITEMS_PER_PAGE } from '../constants';
import { renderGroup, renderQuota } from '../helpers/render';
import {
Button,
Card,

View File

@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { API, showError, showSuccess } from '../helpers';
import { API, showError, showSuccess, renderGroup, renderNumber, renderQuota } from '../helpers';
import {
Button,
Card,
@@ -26,7 +26,6 @@ import {
IconArrowDown,
} from '@douyinfe/semi-icons';
import { ITEMS_PER_PAGE } from '../constants';
import { renderGroup, renderNumber, renderQuota } from '../helpers/render';
import AddUser from '../pages/User/AddUser';
import EditUser from '../pages/User/EditUser';
import { useTranslation } from 'react-i18next';

View File

@@ -13,10 +13,9 @@ import React from 'react';
import { useDebouncedCallback } from 'use-debounce';
import clsx from 'clsx';
import { Button, Tooltip, Toast } from '@douyinfe/semi-ui';
import { copy } from '../../../helpers/utils';
import { copy, rehypeSplitWordsIntoSpans } from '../../../helpers';
import { IconCopy } from '@douyinfe/semi-icons';
import { useTranslation } from 'react-i18next';
import { rehypeSplitWordsIntoSpans } from '../../../helpers/textAnimationUtils';
mermaid.initialize({
startOnLoad: false,

View File

@@ -2,7 +2,7 @@ import React, { useState, useMemo, useCallback } from 'react';
import { Button, Tooltip, Toast } from '@douyinfe/semi-ui';
import { Copy, ChevronDown, ChevronUp } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { copy } from '../../helpers/utils';
import { copy } from '../../helpers';
const PERFORMANCE_CONFIG = {
MAX_DISPLAY_LENGTH: 50000, // 最大显示字符数

View File

@@ -14,7 +14,7 @@ import {
Settings,
} from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { renderGroupOption } from '../../helpers/render.js';
import { renderGroupOption } from '../../helpers';
import ParameterControl from './ParameterControl';
import ImageUrlInput from './ImageUrlInput';
import ConfigManager from './ConfigManager';