import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class UserService { private apiUrl = 'http://127.0.0.1:4040/apps/DevServer/browser/survey'; // 替换为你的 API URL constructor(private http: HttpClient) {} // 获取当前用户信息 getCurrentUser(): Observable { return this.http.get(`${this.apiUrl}/current-user`); // 假设这个 API 返回当前用户的信息 } }