feat(ccw): 智能识别运行中的服务器,支持工作空间切换

- ccw view 自动检测服务器是否已运行
- 已运行时切换工作空间并打开浏览器,无需重启服务器
- 新增 /api/switch-path 和 /api/health 端点
- Dashboard 支持 URL path 参数加载指定工作空间

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
catlog22
2025-12-08 09:56:35 +08:00
parent 0f469e225b
commit a80953527b
4 changed files with 144 additions and 9 deletions

View File

@@ -20,7 +20,17 @@ document.addEventListener('DOMContentLoaded', async () => {
// Server mode: load data from API
try {
if (window.SERVER_MODE) {
await switchToPath(window.INITIAL_PATH || projectPath);
// Check URL for path parameter (from ccw view command)
const urlParams = new URLSearchParams(window.location.search);
const urlPath = urlParams.get('path');
const initialPath = urlPath || window.INITIAL_PATH || projectPath;
await switchToPath(initialPath);
// Clean up URL after loading (remove query param)
if (urlPath && window.history.replaceState) {
window.history.replaceState({}, '', window.location.pathname);
}
} else {
renderDashboard();
}