feat/获取用户信息+展示用户名称

This commit is contained in:
Roe-xin
2026-01-09 15:26:33 +08:00
parent 4037e9e2d7
commit 940584e1ea
9 changed files with 423 additions and 8 deletions

View File

@ -17,6 +17,8 @@ export type ServiceTier = "lite" | "syntaxic" | "max" | "auto";
export interface IccoderConfig {
/** 后端服务地址 */
backendUrl: string;
/** 后端服务地址strangeLoop */
backendUrlStrongeLoop: string;
/** 请求超时时间(毫秒) */
timeout: number;
/** 用户ID临时使用后续对接认证 */
@ -30,6 +32,7 @@ const ENV_CONFIG: Record<Environment, IccoderConfig> = {
/** 本地开发环境 */
dev: {
backendUrl: "http://localhost:2233",
backendUrlStrongeLoop: "http://192.168.1.108:2029",
timeout: 300000,
userId: "default-user",
serviceTier: "max", // 默认使用 max
@ -37,6 +40,7 @@ const ENV_CONFIG: Record<Environment, IccoderConfig> = {
/** 测试服务器环境 */
test: {
backendUrl: "http://192.168.1.108:2233",
backendUrlStrongeLoop: "http://192.168.1.108:2029",
timeout: 60000,
userId: "default-user",
serviceTier: "max",
@ -44,6 +48,7 @@ const ENV_CONFIG: Record<Environment, IccoderConfig> = {
/** 生产环境 */
prod: {
backendUrl: "https://api.iccoder.com",
backendUrlStrongeLoop: "http://api.iccoder.com:2029",
timeout: 60000,
userId: "default-user",
serviceTier: "auto",
@ -75,3 +80,15 @@ export function getApiUrl(path: string): string {
const apiPath = path.startsWith("/") ? path : `/${path}`;
return `${baseUrl}${apiPath}`;
}
/**
* 获取 StrangeLoop 服务 API 地址(用于用户信息等)
*/
export function getStrangeLoopApiUrl(path: string): string {
const { backendUrlStrongeLoop } = getConfig();
const baseUrl = backendUrlStrongeLoop.endsWith("/")
? backendUrlStrongeLoop.slice(0, -1)
: backendUrlStrongeLoop;
const apiPath = path.startsWith("/") ? path : `/${path}`;
return `${baseUrl}${apiPath}`;
}