refactor: 统一 Playground 上下文目录与引用路径

This commit is contained in:
zhanjunhao
2026-10-27 17:25:25 +08:00
parent a44590a6ab
commit e91077a7f2
7 changed files with 10 additions and 16 deletions
+1 -2
View File
@@ -117,8 +117,7 @@ monkey-ai-web/
│ ├── components/ # 通用及业务组件,含 layout、auth、settings
│ ├── pages/ # 页面和业务模块
│ ├── hooks/ # 按业务拆分的数据与交互逻辑
│ ├── context/ # User、Status、Theme、Org 等状态
│ ├── contexts/ # PlaygroundContext;与 context/ 均为现有目录
│ ├── context/ # User、Status、Theme、Org、Playground 等状态
│ ├── helpers/ # API 实例、鉴权、配置、主题、通用工具
│ ├── services/ # 会话、安全验证等服务封装
│ ├── constants/ # 业务常量和接口定义
+2 -3
View File
@@ -205,8 +205,7 @@ monkey-ai-web/
│ ├── pages/ 业务页面;部分包含自己的组件和子路由
│ ├── components/ 公共组件及跨页面业务组件
│ ├── hooks/ 按业务分类的数据、状态与交互逻辑
│ ├── context/ User、Status、Theme、Org 等 Context 定义
│ ├── contexts/ PlaygroundContext,现有独立目录
│ ├── context/ User、Status、Theme、Org、Playground 等 Context 定义
│ ├── services/ 会话、安全验证等可复用服务调用
│ ├── helpers/ API、权限、配置、主题和工具函数
│ ├── constants/ 接口地址、消息状态、菜单和业务常量
@@ -555,7 +554,7 @@ npm run preview
| 依赖管理已统一 | 删除旧 Bun 锁并保留匹配清单的 npm 锁 | npm ci 已验证,依赖更新须同步提交锁文件 |
| 运行时约束 | engines 与 packageManager 已声明 Node/npm 要求 | CI 应使用已验证版本 |
| 部分说明落后于源码 | 体验中心子目录 README 仍使用 `web/src` 并描述图片、视频为占位功能 | 阅读时以当前入口、Hook 和接口调用为准 |
| 分层与命名存在历史差异 | `context/` 与 `contexts/` 并存,部分页面直接请求接口 | 新改动保持局部一致,按业务收益渐进整理,避免无目标的大规模搬迁 |
| 分层与命名存在历史差异 | Context 已统一至 `context/`,部分页面仍直接请求接口 | 新改动保持局部一致,按业务收益渐进整理,避免无目标的大规模搬迁 |
统计脚本由 Vite 的 `loadEnv` 按当前 mode 读取 `VITE_UMAMI_WEBSITE_ID`、`VITE_UMAMI_SCRIPT_URL`、`VITE_GOOGLE_ANALYTICS_ID`;支持开发/生产环境文件与本地覆盖文件,终端或 CI 的同名变量优先,ID 留空时禁用注入。
+1 -1
View File
@@ -61,7 +61,7 @@ import {
selectFilter,
countRounds,
} from '../../helpers';
import { usePlayground } from '../../contexts/PlaygroundContext';
import { usePlayground } from '../../context/Playground';
import { StatusContext } from '../../context/Status';
const ChatArea = ({
@@ -35,7 +35,7 @@ import {
} from 'lucide-react';
import { useSpeechRecognition } from '../../hooks/playground/useSpeechRecognition';
import { useTranslation } from 'react-i18next';
import { usePlayground } from '../../contexts/PlaygroundContext';
import { usePlayground } from '../../context/Playground';
import {
getExperienceCenterBool,
getExperienceCenterPositiveInt,
+1 -1
View File
@@ -41,7 +41,7 @@ import { useTranslation } from 'react-i18next';
// 同名遮蔽在 Vite/terser 生产构建里会把两者缩成同一个变量名,触发 TDZ 错误:
// "Cannot access 'Oe' before initialization"
// 本地函数签名是 (content) 而非 helpers 里的 (message),调用时记得传 message.content。
import { usePlayground } from '../../contexts/PlaygroundContext';
import { usePlayground } from '../../context/Playground';
import { useSpeechSynthesis } from '../../hooks/playground/useSpeechSynthesis';
const MessageContent = ({
@@ -17,10 +17,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { createContext, useContext } from 'react';
import { createContext, createElement, useContext } from 'react';
/**
* Context for Playground component to share image handling functionality
* Share Playground input, upload, search, and image generation functionality.
*/
const PlaygroundContext = createContext(null);
@@ -73,11 +73,7 @@ export const usePlayground = () => {
* @returns {JSX.Element} Provider component
*/
export const PlaygroundProvider = ({ children, value }) => {
return (
<PlaygroundContext.Provider value={value}>
{children}
</PlaygroundContext.Provider>
);
return createElement(PlaygroundContext.Provider, { value }, children);
};
export default PlaygroundContext;
+1 -1
View File
@@ -95,7 +95,7 @@ import MessageSelectableWrapper from '../../components/playground/MessageSelecta
import FloatingButtons from '../../components/playground/FloatingButtons';
import SessionSidebar from '../../components/playground/SessionSidebar';
import KeyboardShortcutsModal from '../../components/playground/KeyboardShortcutsModal';
import { PlaygroundProvider } from '../../contexts/PlaygroundContext';
import { PlaygroundProvider } from '../../context/Playground';
const Playground = ({ isExperienceMode = false }) => {
const { t } = useTranslation();