refactor: 优化 Android 配置与界面
- 更新 AppConfig、build.gradle.kts - 优化 AboutScreen、ConversationListScreen、NicknameSetupScreen、AuthViewModel - 更新 strings 资源,移除 ic_launcher_foreground.webp Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -59,20 +59,27 @@ android {
|
||||
}
|
||||
|
||||
// 构建类型配置
|
||||
// ⚠️ 只需修改 IS_DEBUG_MODE 即可切换环境
|
||||
// true = 开发模式(显示调试UI,连接开发服务器)
|
||||
// false = 生产模式(隐藏调试UI,连接生产服务器)
|
||||
// URL 地址在 AppConfig.kt 中根据此值自动选择
|
||||
// IS_DEBUG_MODE = 是否显示调试 UI(ErrorDebugPanel、测试通道等)
|
||||
// USE_PROD_SERVER = 是否连接生产环境 API(lifecho.worldsplats.com)
|
||||
buildTypes {
|
||||
// 默认调试即连公网(https://lifecho.worldsplats.com),便于公网调试
|
||||
debug {
|
||||
buildConfigField("Boolean", "IS_DEBUG_MODE", "true") // 开发模式
|
||||
buildConfigField("Boolean", "IS_DEBUG_MODE", "true")
|
||||
buildConfigField("Boolean", "USE_PROD_SERVER", "true")
|
||||
applicationIdSuffix = ".debug"
|
||||
versionNameSuffix = "-debug"
|
||||
}
|
||||
// 生产环境调试:连接生产服务器 + 可断点/日志 + 保留调试 UI
|
||||
create("debugProd") {
|
||||
buildConfigField("Boolean", "IS_DEBUG_MODE", "true")
|
||||
buildConfigField("Boolean", "USE_PROD_SERVER", "true")
|
||||
applicationIdSuffix = ".debug"
|
||||
versionNameSuffix = "-debugProd"
|
||||
}
|
||||
release {
|
||||
buildConfigField("Boolean", "IS_DEBUG_MODE", "false") // 生产模式
|
||||
buildConfigField("Boolean", "IS_DEBUG_MODE", "false")
|
||||
buildConfigField("Boolean", "USE_PROD_SERVER", "true")
|
||||
|
||||
// 使用 release 签名配置
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
@@ -90,7 +97,7 @@ android {
|
||||
val variant = this
|
||||
variant.outputs.all {
|
||||
val output = this as com.android.build.gradle.internal.api.BaseVariantOutputImpl
|
||||
val appName = "岁月史书"
|
||||
val appName = "岁月时书"
|
||||
val versionName = variant.versionName
|
||||
val buildType = variant.buildType.name
|
||||
output.outputFileName = "${appName}_v${versionName}_${buildType}.apk"
|
||||
|
||||
@@ -5,17 +5,18 @@ import com.huaga.life_echo.BuildConfig
|
||||
/**
|
||||
* 应用配置管理
|
||||
*
|
||||
* 环境切换说明:
|
||||
* - 只需在 build.gradle.kts 中修改 IS_DEBUG_MODE 即可切换环境
|
||||
* - true = 开发模式(显示调试UI,连接开发服务器)
|
||||
* - false = 生产模式(隐藏调试UI,连接生产服务器)
|
||||
* 构建类型与环境:
|
||||
* - debug = 开发环境(内网 API + 调试 UI,日常开发)
|
||||
* - debugProd = 生产环境调试(生产 API + 调试 UI + 可断点,用于联调/排查生产问题)
|
||||
* - release = 生产包(生产 API + 无调试 UI,上架用)
|
||||
*
|
||||
* UI 同步规则:除「仅测试组件」外,所有 UI 与生产一致;仅测试组件由 isDebugMode 控制。
|
||||
*
|
||||
* 默认行为:如果出现异常,默认使用开发环境配置(安全起见)
|
||||
*/
|
||||
object AppConfig {
|
||||
|
||||
// ==================== 服务器地址配置 ====================
|
||||
// 如需修改服务器地址,只需修改下面的常量即可
|
||||
|
||||
// 开发环境(物理机测试使用内网IP)
|
||||
private const val DEV_API_URL = "http://192.168.10.120:8000"
|
||||
@@ -25,36 +26,30 @@ object AppConfig {
|
||||
private const val PROD_API_URL = "https://lifecho.worldsplats.com"
|
||||
private const val PROD_WS_URL = "wss://lifecho.worldsplats.com"
|
||||
|
||||
// Android模拟器备用地址(10.0.2.2 映射到主机 localhost)
|
||||
// private const val EMU_API_URL = "http://10.0.2.2:8000"
|
||||
// private const val EMU_WS_URL = "ws://10.0.2.2:8000"
|
||||
|
||||
// ==================== 环境判断 ====================
|
||||
|
||||
/** 是否使用生产服务器(debugProd / release 为 true) */
|
||||
private val useProdServer: Boolean = try {
|
||||
BuildConfig.USE_PROD_SERVER
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为调试模式
|
||||
* - true: 开发模式,显示调试UI组件
|
||||
* - false: 生产模式,隐藏调试组件
|
||||
*
|
||||
* 默认值:true(出问题时默认开发模式,方便调试)
|
||||
* 是否为调试模式(显示调试 UI:ErrorDebugPanel、WebSocketDebugPanel、测试通道等)
|
||||
* debug / debugProd = true,release = false
|
||||
*/
|
||||
val isDebugMode: Boolean = try {
|
||||
BuildConfig.IS_DEBUG_MODE
|
||||
} catch (e: Exception) {
|
||||
true // 默认开发模式
|
||||
true
|
||||
}
|
||||
|
||||
/**
|
||||
* API 基础 URL
|
||||
* 根据 isDebugMode 自动选择开发或生产服务器
|
||||
*/
|
||||
val BASE_URL: String = if (isDebugMode) DEV_API_URL else PROD_API_URL
|
||||
/** API 基础 URL:由 USE_PROD_SERVER 决定,与 isDebugMode 解耦 */
|
||||
val BASE_URL: String = if (useProdServer) PROD_API_URL else DEV_API_URL
|
||||
|
||||
/**
|
||||
* WebSocket 基础 URL
|
||||
* 根据 isDebugMode 自动选择开发或生产服务器
|
||||
*/
|
||||
val WS_BASE_URL: String = if (isDebugMode) DEV_WS_URL else PROD_WS_URL
|
||||
/** WebSocket 基础 URL */
|
||||
val WS_BASE_URL: String = if (useProdServer) PROD_WS_URL else DEV_WS_URL
|
||||
|
||||
// ==================== 支付配置 ====================
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ fun AboutScreen(
|
||||
|
||||
// 应用名称
|
||||
Text(
|
||||
text = "岁月史书",
|
||||
text = "岁月时书",
|
||||
fontSize = 28.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
@@ -118,7 +118,7 @@ fun AboutScreen(
|
||||
)
|
||||
|
||||
Text(
|
||||
text = "岁月史书是一款专为长辈设计的智能回忆录助手应用,帮助老年人轻松记录和整理一生中的美好回忆。通过简单的AI对话方式,无需复杂操作,就能将珍贵的人生故事转化为精美的个人回忆录。\n\n当然,无论您是什么年龄,都可以使用岁月史书来记录属于自己的故事。",
|
||||
text = "岁月时书是一款专为长辈设计的智能回忆录助手应用,帮助老年人轻松记录和整理一生中的美好回忆。通过简单的AI对话方式,无需复杂操作,就能将珍贵的人生故事转化为精美的个人回忆录。\n\n当然,无论您是什么年龄,都可以使用岁月时书来记录属于自己的故事。",
|
||||
fontSize = 16.sp,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier
|
||||
@@ -196,7 +196,7 @@ fun AboutScreen(
|
||||
|
||||
// 版权信息
|
||||
Text(
|
||||
text = "© 2026 岁月史书. All rights reserved.",
|
||||
text = "© 2026 岁月时书. All rights reserved.",
|
||||
fontSize = 14.sp,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.padding(top = 16.dp)
|
||||
|
||||
@@ -170,7 +170,7 @@ fun ConversationListScreen(
|
||||
)
|
||||
} else {
|
||||
// 正常模式头部
|
||||
ColoredHeader(title = "往事拾遗")
|
||||
ColoredHeader(title = "岁月时书")
|
||||
}
|
||||
|
||||
// 内容区域
|
||||
|
||||
@@ -77,7 +77,7 @@ fun NicknameSetupScreen(
|
||||
|
||||
// 标题
|
||||
Text(
|
||||
text = "欢迎加入岁月史书",
|
||||
text = "欢迎加入岁月时书",
|
||||
fontSize = 24.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
|
||||
@@ -163,7 +163,7 @@ class AuthViewModel(private val context: Context) : ViewModel() {
|
||||
_operationResult.value = OperationResult(
|
||||
success = true,
|
||||
message = "注册成功",
|
||||
details = "账号已创建,欢迎加入岁月史书!正在跳转..."
|
||||
details = "账号已创建,欢迎加入岁月时书!正在跳转..."
|
||||
)
|
||||
},
|
||||
onFailure = { exception ->
|
||||
@@ -378,7 +378,7 @@ class AuthViewModel(private val context: Context) : ViewModel() {
|
||||
success = true,
|
||||
message = if (isNewUser) "注册成功" else "登录成功",
|
||||
details = if (isNewUser) {
|
||||
"账号已创建,欢迎加入岁月史书!正在跳转..."
|
||||
"账号已创建,欢迎加入岁月时书!正在跳转..."
|
||||
} else {
|
||||
"欢迎回来,${userNickname}!正在跳转..."
|
||||
}
|
||||
@@ -440,7 +440,7 @@ class AuthViewModel(private val context: Context) : ViewModel() {
|
||||
_operationResult.value = OperationResult(
|
||||
success = true,
|
||||
message = "注册成功",
|
||||
details = "账号已创建,欢迎加入岁月史书!正在跳转..."
|
||||
details = "账号已创建,欢迎加入岁月时书!正在跳转..."
|
||||
)
|
||||
},
|
||||
onFailure = { exception ->
|
||||
@@ -662,7 +662,7 @@ class AuthViewModel(private val context: Context) : ViewModel() {
|
||||
_operationResult.value = OperationResult(
|
||||
success = true,
|
||||
message = "欢迎",
|
||||
details = "欢迎加入岁月史书,${userResponse.nickname}!"
|
||||
details = "欢迎加入岁月时书,${userResponse.nickname}!"
|
||||
)
|
||||
onSuccess()
|
||||
},
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 58 KiB |
@@ -1,5 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">岁月史书</string>
|
||||
<string name="app_name">岁月时书</string>
|
||||
|
||||
<!-- Navigation -->
|
||||
<string name="nav_chat">Chat</string>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">岁月史书</string>
|
||||
<string name="app_name">岁月时书</string>
|
||||
|
||||
<!-- Navigation -->
|
||||
<string name="nav_chat">聊天</string>
|
||||
|
||||
Reference in New Issue
Block a user