♻️ refactor(helpers): standardize file naming conventions and improve code organization
- Rename files to follow camelCase naming convention: • auth-header.js → authUtils.js • other.js → logUtils.js • rehypeSplitWordsIntoSpans.js → textAnimationUtils.js - Update import paths in affected components: • Update exports in helpers/index.js • Fix import in LogsTable.js for logUtils • Fix import in MarkdownRenderer.js for textAnimationUtils - Remove old files after successful migration - Improve file naming clarity: • authUtils.js better describes authentication utilities • logUtils.js clearly indicates log processing functions • textAnimationUtils.js concisely describes text animation functionality This refactoring enhances code maintainability and follows consistent naming patterns throughout the helpers directory.
This commit is contained in:
@@ -6,15 +6,15 @@ import {
|
||||
API_ENDPOINTS,
|
||||
MESSAGE_STATUS,
|
||||
DEBUG_TABS
|
||||
} from '../utils/constants';
|
||||
} from '../constants/playground.constants';
|
||||
import {
|
||||
buildApiPayload,
|
||||
handleApiError
|
||||
} from '../utils/apiUtils';
|
||||
} from '../helpers/apiUtils';
|
||||
import {
|
||||
processThinkTags,
|
||||
processIncompleteThinkTags
|
||||
} from '../utils/messageUtils';
|
||||
} from '../helpers/messageUtils';
|
||||
|
||||
export const useApiRequest = (
|
||||
setMessage,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { API, showError } from '../helpers/index.js';
|
||||
import { API_ENDPOINTS } from '../utils/constants';
|
||||
import { processModelsData, processGroupsData } from '../utils/apiUtils';
|
||||
import { API } from '../helpers/api';
|
||||
import { API_ENDPOINTS } from '../constants/playground.constants';
|
||||
import { processModelsData, processGroupsData } from '../helpers/apiUtils';
|
||||
|
||||
export const useDataLoader = (
|
||||
userState,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useCallback } from 'react';
|
||||
import { Toast, Modal } from '@douyinfe/semi-ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { getTextContent } from '../utils/messageUtils';
|
||||
import { ERROR_MESSAGES } from '../utils/constants';
|
||||
import { getTextContent } from '../helpers/messageUtils';
|
||||
import { ERROR_MESSAGES } from '../constants/playground.constants';
|
||||
|
||||
export const useMessageActions = (message, setMessage, onMessageSend, saveMessages) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useCallback, useState, useRef } from 'react';
|
||||
import { Toast, Modal } from '@douyinfe/semi-ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { getTextContent, buildApiPayload, createLoadingAssistantMessage } from '../utils/messageUtils';
|
||||
import { MESSAGE_ROLES } from '../utils/constants';
|
||||
import { getTextContent, buildApiPayload, createLoadingAssistantMessage } from '../helpers/messageUtils';
|
||||
import { MESSAGE_ROLES } from '../constants/playground.constants';
|
||||
|
||||
export const useMessageEdit = (
|
||||
setMessage,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, useCallback, useRef, useEffect } from 'react';
|
||||
import { DEFAULT_MESSAGES, DEFAULT_CONFIG, DEBUG_TABS, MESSAGE_STATUS } from '../utils/constants';
|
||||
import { DEFAULT_MESSAGES, DEFAULT_CONFIG, DEBUG_TABS, MESSAGE_STATUS } from '../constants/playground.constants';
|
||||
import { loadConfig, saveConfig, loadMessages, saveMessages } from '../components/playground/configStorage';
|
||||
import { processIncompleteThinkTags } from '../utils/messageUtils';
|
||||
import { processIncompleteThinkTags } from '../helpers/messageUtils';
|
||||
|
||||
export const usePlaygroundState = () => {
|
||||
// 使用惰性初始化,确保只在组件首次挂载时加载配置和消息
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useRef } from 'react';
|
||||
import { MESSAGE_ROLES } from '../utils/constants';
|
||||
import { MESSAGE_ROLES } from '../constants/playground.constants';
|
||||
|
||||
export const useSyncMessageAndCustomBody = (
|
||||
customRequestMode,
|
||||
|
||||
Reference in New Issue
Block a user