From 374cc654d7074de0af1c073f266b6419ed381337 Mon Sep 17 00:00:00 2001 From: AI Health Developer Date: Sun, 27 Apr 2025 15:13:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0NIMConfigurationManag?= =?UTF-8?q?er=E5=92=8CAppConfig=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加NIMConfigurationManager用于初始化NIM SDK,并创建AppConfig以管理应用环境配置,包括基础URL和Analytics Key等 --- yana/Configs/AppConfig.swift | 36 +++++++++++++++++++++ yana/Managers/NIMConfigurationManager.swift | 10 ++++++ 2 files changed, 46 insertions(+) create mode 100644 yana/Configs/AppConfig.swift create mode 100644 yana/Managers/NIMConfigurationManager.swift diff --git a/yana/Configs/AppConfig.swift b/yana/Configs/AppConfig.swift new file mode 100644 index 0000000..e4ba840 --- /dev/null +++ b/yana/Configs/AppConfig.swift @@ -0,0 +1,36 @@ +enum Environment { + case development + case production +} + +struct AppConfig { + static var current: Environment = { + #if DEBUG + return .development + #else + return .production + #endif + }() + + static var baseURL: String { + switch current { + case .development: + return "https://dev-api.yourdomain.com/v1" + case .production: + return "https://api.yourdomain.com/v1" + } + } + + // 添加更多环境变量 + static var analyticsKey: String { + switch current { + case .development: return "dev_analytics_key" + case .production: return "prod_analytics_key" + } + } + + // 运行时切换环境(用于测试) + static func switchEnvironment(to env: Environment) { + current = env + } +} \ No newline at end of file diff --git a/yana/Managers/NIMConfigurationManager.swift b/yana/Managers/NIMConfigurationManager.swift new file mode 100644 index 0000000..44fe559 --- /dev/null +++ b/yana/Managers/NIMConfigurationManager.swift @@ -0,0 +1,10 @@ +import NIMSDK + +struct NIMConfigurationManager { + static func setupSDK() { + NIMSDK.shared().register( + withAppID: "79bc37000f4018a2a24ea9dc6ca08d32", + cerName: "pikoDevelopPush" + ) + } +} \ No newline at end of file