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-10-31 13:05:34 +08:00
|
|
|
|
// 基础baseUrl
|
|
|
|
|
|
#ifndef KB_BASE_URL
|
|
|
|
|
|
#define KB_BASE_URL @"https://m1.apifoxmock.com/m1/5438099-5113192-default/"
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// Universal Links 通用链接
|
|
|
|
|
|
#ifndef KB_UL_BASE
|
2025-11-05 18:10:56 +08:00
|
|
|
|
#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,并添加访问组:
|
2025-11-03 21:04:39 +08:00
|
|
|
|
// $(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
|
2025-11-03 21:04:39 +08:00
|
|
|
|
#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
|
2025-11-03 21:04:39 +08:00
|
|
|
|
#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
|
|
|
|
|
2025-11-05 18:10:56 +08:00
|
|
|
|
// --- 应用自定义 Scheme ---
|
|
|
|
|
|
// 主 App 在 Info.plist 中注册的 URL Scheme,用于从键盘扩展唤起容器 App。
|
|
|
|
|
|
// 注意:AppDelegate 中对 scheme 做了小写化比较(kbkeyboardappextension),iOS 对大小写不敏感;
|
|
|
|
|
|
// 这里统一通过宏引用,避免出现与 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
|
2025-11-06 15:16:03 +08:00
|
|
|
|
|