94 lines
2.9 KiB
Objective-C
94 lines
2.9 KiB
Objective-C
//
|
||
// KBConfig.h
|
||
// 主 App 与键盘扩展共用的配置/宏。
|
||
//
|
||
// 在此处修改后,会通过 PCH 被两个 target 同步引用。
|
||
//
|
||
|
||
#ifndef KBConfig_h
|
||
#define KBConfig_h
|
||
|
||
// UIKit is needed for CGFloat and UIScreen used by size-adaptation helpers
|
||
#if __OBJC__
|
||
#import <UIKit/UIKit.h>
|
||
#endif
|
||
|
||
/// APP名称
|
||
#define AppName @"Key of Love"
|
||
|
||
/// APP Groups
|
||
#define AppGroup @"group.com.loveKey.nyx"
|
||
|
||
/// 皮肤图标加载模式:
|
||
/// 0 = 使用本地 Assets 图片名(key_icons 的 value 写成图片名,例如 "kb_q_melon")
|
||
/// 1 = 使用远程 Zip 皮肤包(skinJSON 中提供 zip_url;key_icons 的 value 写成 Zip 内图标文件名,例如 "key_a")
|
||
#ifndef KB_SKIN_ICON_USE_REMOTE
|
||
#define KB_SKIN_ICON_USE_REMOTE 1
|
||
#endif
|
||
|
||
|
||
// 基础baseUrl
|
||
#ifndef KB_BASE_URL
|
||
//#define KB_BASE_URL @"https://m1.apifoxmock.com/m1/5438099-5113192-default/"
|
||
#define KB_BASE_URL @"http://192.168.1.144:7529/api"
|
||
#endif
|
||
|
||
// Universal Links 通用链接
|
||
#ifndef KB_UL_BASE
|
||
#define KB_UL_BASE @"https://app.tknb.net/ul"
|
||
#endif
|
||
|
||
#define KB_UL_LOGIN KB_UL_BASE @"/login"
|
||
#define KB_UL_SETTINGS KB_UL_BASE @"/settings"
|
||
|
||
#endif /* KBConfig_h */
|
||
|
||
// --- 认证/共享钥匙串 配置 ---
|
||
// 若已在 Capabilities 中启用 Keychain Sharing,并添加访问组:
|
||
// $(AppIdentifierPrefix)com.loveKey.nyx.shared
|
||
// 运行时会展开为:TN6HHV45BB.com.loveKey.nyx.shared
|
||
// KBAuthManager 通过下面的宏定位访问组;如需修改,可在 Build Settings 或前缀头中覆盖该宏。
|
||
#ifndef KB_KEYCHAIN_ACCESS_GROUP
|
||
#define KB_KEYCHAIN_ACCESS_GROUP @"TN6HHV45BB.com.loveKey.nyx.shared"
|
||
#endif
|
||
|
||
// 键盘扩展的 Bundle Identifier(用于 App 侧检测是否已添加该键盘)
|
||
#ifndef KB_KEYBOARD_EXTENSION_BUNDLE_ID
|
||
#define KB_KEYBOARD_EXTENSION_BUNDLE_ID @"com.loveKey.nyx.CustomKeyboard"
|
||
#endif
|
||
|
||
// --- 应用自定义 Scheme ---
|
||
// 主 App 在 Info.plist 中注册的 URL Scheme,用于从键盘扩展唤起容器 App。
|
||
// 注意:AppDelegate 中对 scheme 做了小写化比较(kbkeyboardappextension),iOS 对大小写不敏感;
|
||
// 这里统一通过宏引用,避免出现与 App 端不一致的字符串。
|
||
#ifndef KB_APP_SCHEME
|
||
#define KB_APP_SCHEME @"kbkeyboardAppExtension"
|
||
#endif
|
||
|
||
// --- 尺寸适配(以 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
|
||
|
||
// --- 常用宏 ---
|
||
// 弱引用 self(在 block 中避免循环引用):使用处直接写 KBWeakSelf;
|
||
#ifndef KBWeakSelf
|
||
#define KBWeakSelf __weak __typeof(self) weakSelf = self;
|
||
#endif
|