Skip to content

[Feature] Replace hardcoded backend URL with environment config #12

Description

@lechan775

Problem

ApiConfig.ets 中后端地址硬编码为 http://172.18.32.1:8080,切换环境需手动修改代码。

Proposed Solution

提供多环境配置方案:

// ApiConfig.ets
export const API_BASE_URL: string = getApiBaseUrl();

function getApiBaseUrl(): string {
  // 优先级:本地存储 > 默认值
  const stored = preferences.getSync("api_base_url", "");
  return stored || "http://10.0.2.2:8080"; // 模拟器默认
}

同时在 App 设置页提供 "服务器地址" 配置入口,方便真机调试时切换。

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions