Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import type express from 'express' import * as vscode from 'vscode' import { userInfoService } from '../../services/user-info-service' import { getCurrentIDE } from '../../utils/dispatch-agent-call' import { logger } from '../../utils/logger-adapter' export function registerProjectRoutes(app: express.Express, actualPort: number) { // 返回当前项目名称、端口和工作区路径 app.get('/project-name', async (_req, res) => { try { const workspaceFolder = vscode.workspace.workspaceFolders?.[0] const workspaceRoot = workspaceFolder?.uri.fsPath const projectName = workspaceFolder ? workspaceFolder.name : vscode.workspace.name || 'Unknown Project' try { const { userInfo: userInfoString } = _req.query const userInfo = JSON.parse(userInfoString as string) await userInfoService.setUserInfo(userInfo, 'web') logger.info('[UserInfo API] 用户信息已设置', { uid: userInfo.uid, uname: userInfo.uname, }) } catch (error) { logger.warn('[UserInfo API] 设置用户信息失败', error) } res.json({ success: true, projectName, port: actualPort, workspaceRoot, ide: getCurrentIDE() }) } catch (error) { res.status(500).json({ success: false, error: error instanceof Error ? error.message : String(error) }) } }) } |