# Playground 移动端优化重构方案 ## 当前问题 1. 移动端代码问题布局显示异常 2. PC端测试区域和问题区域混杂 3. 移动端编辑器高度不够 4. 缺少URL历史记录功能 5. 悬浮按钮组功能单一 ## 改进方案 ### 1. PC端 - Tab页签模式 - 右侧面板改为Tab页签 - 测试 (Debug图标) - 问题 (感叹号图标) - 统一的折叠/展开按钮 ### 2. 移动端 - 模态框模式 - 移除底部固定的测试参数区域 - 添加两个悬浮模态框触发按钮: - 运行测试 (三角形图标) - 查看问题 (感叹号图标) - 测试模态框包含: - URL输入(带历史记录下拉) - 密码输入 - 方法选择 - 执行按钮 - 结果展示 ### 3. URL历史记录 - LocalStorage存储最近10条 - 下拉选择历史URL - 点击快速填充 ### 4. 悬浮按钮组优化 - 增大按钮尺寸 - 添加运行按钮 - 位置:右下角 - 按钮:撤销、重做、格式化、全选、运行 ### 5. 编辑器高度优化 - 移动端:calc(100vh - 顶部导航 - 按钮区域 - 10px) - PC端:保持当前分屏模式 ## 实现步骤 ### 步骤1:添加状态变量 ```javascript // URL历史记录 const urlHistory = ref([]); const HISTORY_KEY = 'playground_url_history'; // 模态框状态 const mobileTestDialogVisible = ref(false); const mobileResultDialogVisible = ref(false); // Tab页签 const rightPanelTab = ref('test'); // 'test' | 'problems' ``` ### 步骤2:URL历史记录功能 ```javascript // 加载历史 onMounted(() => { const history = localStorage.getItem(HISTORY_KEY); if (history) { urlHistory.value = JSON.parse(history); } }); // 添加到历史 const addToHistory = (url) => { if (!url || !url.trim()) return; // 去重 const filtered = urlHistory.value.filter(item => item !== url); filtered.unshift(url); // 限制数量 if (filtered.length > MAX_HISTORY) { filtered.length = MAX_HISTORY; } urlHistory.value = filtered; localStorage.setItem(HISTORY_KEY, JSON.stringify(filtered)); }; ``` ### 步骤3:PC端Tab页签 替换当前右侧面板的3个独立卡片为: ```vue ``` ### 步骤4:移动端模态框 ```vue ``` ### 步骤5:优化悬浮按钮 ```vue
``` CSS: ```css .mobile-editor-actions.large .el-button { width: 48px !important; height: 48px !important; font-size: 20px !important; } ``` ### 步骤6:编辑器高度 ```css /* 移动端编辑器高度 */ @media screen and (max-width: 768px) { .mobile-layout .editor-section { height: calc(100vh - 120px) !important; } .mobile-layout .editor-section :deep(.monaco-editor-container) { height: 100% !important; } } ``` ## 文件修改清单 ### 需要修改的部分: 1. `