Files
keyboard/Shared/KBConfig.h

94 lines
2.9 KiB
C
Raw Normal View History

2025-10-31 13:05:34 +08:00
//
// KBConfig.h
2025-10-31 16:06:54 +08:00
// 主 App 与键盘扩展共用的配置/宏。
2025-10-31 13:05:34 +08:00
//
2025-10-31 16:06:54 +08:00
// 在此处修改后,会通过 PCH 被两个 target 同步引用。
2025-10-31 13:05:34 +08:00
//
#ifndef KBConfig_h
#define KBConfig_h
2025-11-06 14:02:22 +08:00
// UIKit is needed for CGFloat and UIScreen used by size-adaptation helpers
#if __OBJC__
#import <UIKit/UIKit.h>
#endif
2025-11-18 14:41:35 +08:00
/// APP名称
2025-11-15 14:27:41 +08:00
#define AppName @"Key of Love"
2025-11-18 14:41:35 +08:00
/// APP Groups
#define AppGroup @"group.com.loveKey.nyx"
2025-11-18 20:53:47 +08:00
/// 皮肤图标加载模式:
/// 0 = 使用本地 Assets 图片名key_icons 的 value 写成图片名,例如 "kb_q_melon"
2025-11-19 14:54:45 +08:00
/// 1 = 使用远程 Zip 皮肤包skinJSON 中提供 zip_urlkey_icons 的 value 写成 Zip 内图标文件名,例如 "key_a"
2025-11-18 20:53:47 +08:00
#ifndef KB_SKIN_ICON_USE_REMOTE
2025-11-19 15:39:47 +08:00
#define KB_SKIN_ICON_USE_REMOTE 1
2025-11-18 20:53:47 +08:00
#endif
2025-11-18 14:41:35 +08:00
2025-10-31 13:05:34 +08:00
// 基础baseUrl
#ifndef KB_BASE_URL
2025-11-13 14:11:44 +08:00
//#define KB_BASE_URL @"https://m1.apifoxmock.com/m1/5438099-5113192-default/"
#define KB_BASE_URL @"http://192.168.1.144:7529/api"
2025-10-31 13:05:34 +08:00
#endif
// Universal Links 通用链接
#ifndef KB_UL_BASE
#define KB_UL_BASE @"https://app.tknb.net/ul"
2025-10-31 13:05:34 +08:00
#endif
#define KB_UL_LOGIN KB_UL_BASE @"/login"
#define KB_UL_SETTINGS KB_UL_BASE @"/settings"
#endif /* KBConfig_h */
2025-10-31 16:06:54 +08:00
// --- 认证/共享钥匙串 配置 ---
// 若已在 Capabilities 中启用 Keychain Sharing并添加访问组
// $(AppIdentifierPrefix)com.loveKey.nyx.shared
// 运行时会展开为TN6HHV45BB.com.loveKey.nyx.shared
2025-10-31 16:06:54 +08:00
// KBAuthManager 通过下面的宏定位访问组;如需修改,可在 Build Settings 或前缀头中覆盖该宏。
#ifndef KB_KEYCHAIN_ACCESS_GROUP
#define KB_KEYCHAIN_ACCESS_GROUP @"TN6HHV45BB.com.loveKey.nyx.shared"
2025-10-31 16:06:54 +08:00
#endif
2025-11-03 13:25:41 +08:00
// 键盘扩展的 Bundle Identifier用于 App 侧检测是否已添加该键盘)
#ifndef KB_KEYBOARD_EXTENSION_BUNDLE_ID
#define KB_KEYBOARD_EXTENSION_BUNDLE_ID @"com.loveKey.nyx.CustomKeyboard"
2025-11-03 13:25:41 +08:00
#endif
2025-11-03 18:45:06 +08:00
// --- 应用自定义 Scheme ---
// 主 App 在 Info.plist 中注册的 URL Scheme用于从键盘扩展唤起容器 App。
// 注意AppDelegate 中对 scheme 做了小写化比较kbkeyboardappextensioniOS 对大小写不敏感;
// 这里统一通过宏引用,避免出现与 App 端不一致的字符串。
#ifndef KB_APP_SCHEME
#define KB_APP_SCHEME @"kbkeyboardAppExtension"
#endif
2025-11-06 14:02:22 +08:00
// --- 尺寸适配(以 375 设计稿为基准) ---
// 用法:传入设计稿上的数值,返回按当前屏幕宽度缩放后的值。
// 例如CGFloat padding = KBFit(16);
#ifndef KB_DESIGN_WIDTH
#define KB_DESIGN_WIDTH 375.0
#endif
#if __OBJC__
static inline CGFloat KBScreenWidth(void) {
return [UIScreen mainScreen].bounds.size.width;
}
static inline CGFloat KBScaleFactor(void) {
return KBScreenWidth() / (CGFloat)KB_DESIGN_WIDTH;
}
static inline CGFloat KBFit(CGFloat designValue) {
return designValue * KBScaleFactor();
}
#endif
2025-11-03 18:45:06 +08:00
// --- 常用宏 ---
// 弱引用 self在 block 中避免循环引用):使用处直接写 KBWeakSelf;
#ifndef KBWeakSelf
#define KBWeakSelf __weak __typeof(self) weakSelf = self;
#endif