From 72142b0b710c0a7ee84886873320c1271b968e12 Mon Sep 17 00:00:00 2001 From: CodeST <694468528@qq.com> Date: Tue, 10 Mar 2026 11:25:10 +0800 Subject: [PATCH] 1 --- CustomKeyboard/Utils/KBExtensionAppLauncher.h | 1 - CustomKeyboard/Utils/KBExtensionAppLauncher.m | 1 - keyBoard/Class/Pay/VC/KBJfPay.m | 56 ++++++++++++++++++- keyBoard/Class/Pay/VC/KBPayMainVC.m | 56 ++++++++++++++++++- .../Class/WebView/KBWebViewViewController.m | 12 +--- 5 files changed, 109 insertions(+), 17 deletions(-) diff --git a/CustomKeyboard/Utils/KBExtensionAppLauncher.h b/CustomKeyboard/Utils/KBExtensionAppLauncher.h index 87c32b3..97be5ad 100644 --- a/CustomKeyboard/Utils/KBExtensionAppLauncher.h +++ b/CustomKeyboard/Utils/KBExtensionAppLauncher.h @@ -14,7 +14,6 @@ NS_ASSUME_NONNULL_BEGIN /// 通用入口:优先尝试 primaryURL,失败后尝试 fallbackURL, /// 均通过 `extensionContext openURL` 发起跳转(避免使用扩展禁用 API/响应链绕行)。 /// 若开启 `KB_URL_BRIDGE_ENABLE=1`,会在两次 `extensionContext openURL` 均失败时, -/// 再尝试一次“响应链 openURL”兜底(上架有风险,请谨慎开启)。 /// - Parameters: /// - primaryURL: 第一优先尝试的 URL(可为 Scheme 或 UL) /// - fallbackURL: 失败时的备用 URL(可为 nil) diff --git a/CustomKeyboard/Utils/KBExtensionAppLauncher.m b/CustomKeyboard/Utils/KBExtensionAppLauncher.m index c640415..8472c12 100644 --- a/CustomKeyboard/Utils/KBExtensionAppLauncher.m +++ b/CustomKeyboard/Utils/KBExtensionAppLauncher.m @@ -121,7 +121,6 @@ } #if KB_URL_BRIDGE_ENABLE - // 注意:上架有风险。仅当确实存在“宿主 App 拦截 extensionContext openURL” // 的场景且业务强依赖时才开启此兜底。 UIResponder *start = (source ?: (UIResponder *)ivc.view ?: (UIResponder *)ivc); [self kb_openURLViaResponderChain:second diff --git a/keyBoard/Class/Pay/VC/KBJfPay.m b/keyBoard/Class/Pay/VC/KBJfPay.m index d7c49dc..d05e4ee 100644 --- a/keyBoard/Class/Pay/VC/KBJfPay.m +++ b/keyBoard/Class/Pay/VC/KBJfPay.m @@ -34,6 +34,9 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId"; // 底部按钮/协议 @property (nonatomic, strong) UIButton *payButton; // 充值按钮 @property (nonatomic, strong) UILabel *agreementLabel; // 协议提示 +@property (nonatomic, strong) UIView *documentContainer; +@property (nonatomic, strong) UIButton *privacyButton; +@property (nonatomic, strong) UILabel *documentSeparatorLabel; @property (nonatomic, strong) UIButton *agreementButton; // 数据 @@ -77,7 +80,10 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId"; [self.listContainerView addSubview:self.collectionView]; [self.view addSubview:self.payButton]; [self.view addSubview:self.agreementLabel]; - [self.view addSubview:self.agreementButton]; + [self.view addSubview:self.documentContainer]; + [self.documentContainer addSubview:self.privacyButton]; + [self.documentContainer addSubview:self.documentSeparatorLabel]; + [self.documentContainer addSubview:self.agreementButton]; // 布局(mas) @@ -120,13 +126,24 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId"; make.top.equalTo(self.smallLeftIcon.mas_bottom).offset(19); }]; - [self.agreementButton mas_makeConstraints:^(MASConstraintMaker *make) { + [self.documentContainer mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.view); make.bottom.equalTo(self.view).offset(-KB_SAFE_BOTTOM - 15); }]; + [self.privacyButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.top.bottom.equalTo(self.documentContainer); + }]; + [self.documentSeparatorLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.equalTo(self.privacyButton.mas_right).offset(6); + make.centerY.equalTo(self.documentContainer); + }]; + [self.agreementButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.equalTo(self.documentSeparatorLabel.mas_right).offset(6); + make.top.right.bottom.equalTo(self.documentContainer); + }]; [self.agreementLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.view); - make.bottom.equalTo(self.agreementButton.mas_top).offset(0); + make.bottom.equalTo(self.documentContainer.mas_top).offset(0); }]; // 底部按钮 @@ -361,6 +378,10 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId"; [KBWebViewViewController presentLegalDocumentType:KBLegalDocumentTypeMembershipAgreement fromViewController:self]; } +- (void)privacyButtonAction { + [KBWebViewViewController presentLegalDocumentType:KBLegalDocumentTypePrivacyPolicy fromViewController:self]; +} + #pragma mark - Lazy UI - (UILabel *)myPointsTitleLabel { if (!_myPointsTitleLabel) { @@ -464,6 +485,35 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId"; } return _agreementLabel; } + +- (UIView *)documentContainer { + if (!_documentContainer) { + _documentContainer = [UIView new]; + } + return _documentContainer; +} + +- (UIButton *)privacyButton { + if (!_privacyButton) { + _privacyButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_privacyButton setTitle:KBLocalized(@"Privacy Policy") forState:UIControlStateNormal]; + [_privacyButton setTitleColor:[UIColor colorWithHex:KBColorValue] forState:UIControlStateNormal]; + _privacyButton.titleLabel.font = [KBFont regular:12]; + [_privacyButton addTarget:self action:@selector(privacyButtonAction) forControlEvents:UIControlEventTouchUpInside]; + } + return _privacyButton; +} + +- (UILabel *)documentSeparatorLabel { + if (!_documentSeparatorLabel) { + _documentSeparatorLabel = [UILabel new]; + _documentSeparatorLabel.text = @"|"; + _documentSeparatorLabel.textColor = [UIColor colorWithWhite:0.45 alpha:1.0]; + _documentSeparatorLabel.font = [KBFont regular:12]; + } + return _documentSeparatorLabel; +} + - (UIButton *)agreementButton { if (!_agreementButton) { _agreementButton = [UIButton buttonWithType:UIButtonTypeCustom]; diff --git a/keyBoard/Class/Pay/VC/KBPayMainVC.m b/keyBoard/Class/Pay/VC/KBPayMainVC.m index 0eb3d98..fdb08ac 100644 --- a/keyBoard/Class/Pay/VC/KBPayMainVC.m +++ b/keyBoard/Class/Pay/VC/KBPayMainVC.m @@ -50,6 +50,9 @@ static const CGFloat JXheightForHeaderInSection = 39; @property (nonatomic, strong) UIView *bottomContainer; @property (nonatomic, strong) UIButton *payButton; @property (nonatomic, strong) UILabel *agreementLabel; +@property (nonatomic, strong) UIView *documentContainer; +@property (nonatomic, strong) UIButton *privacyButton; +@property (nonatomic, strong) UILabel *documentSeparatorLabel; @property (nonatomic, strong) UIButton *agreementButton; /// Deep link pending config (透传给 VIP 页面) @@ -214,16 +217,33 @@ static const CGFloat JXheightForHeaderInSection = 39; [self.view addSubview:self.bottomContainer]; [self.bottomContainer addSubview:self.payButton]; [self.bottomContainer addSubview:self.agreementLabel]; - [self.bottomContainer addSubview:self.agreementButton]; + [self.bottomContainer addSubview:self.documentContainer]; + [self.documentContainer addSubview:self.privacyButton]; + [self.documentContainer addSubview:self.documentSeparatorLabel]; + [self.documentContainer addSubview:self.agreementButton]; [self.bottomContainer mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.equalTo(self.view); }]; - [self.agreementButton mas_makeConstraints:^(MASConstraintMaker *make) { + [self.documentContainer mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.bottomContainer); make.bottom.equalTo(self.bottomContainer).offset(-KB_SAFE_BOTTOM - 15); }]; + + [self.privacyButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.top.bottom.equalTo(self.documentContainer); + }]; + + [self.documentSeparatorLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.equalTo(self.privacyButton.mas_right).offset(6); + make.centerY.equalTo(self.documentContainer); + }]; + + [self.agreementButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.equalTo(self.documentSeparatorLabel.mas_right).offset(6); + make.top.right.bottom.equalTo(self.documentContainer); + }]; [self.agreementLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.bottomContainer); @@ -354,6 +374,10 @@ static const CGFloat JXheightForHeaderInSection = 39; [KBWebViewViewController presentLegalDocumentType:KBLegalDocumentTypeMembershipAgreement fromViewController:self]; } +- (void)onTapPrivacyButton { + [KBWebViewViewController presentLegalDocumentType:KBLegalDocumentTypePrivacyPolicy fromViewController:self]; +} + - (void)onTapRestoreButton { [[KBMaiPointReporter sharedReporter] reportClickWithEventName:@"click_vip_restore_btn" pageId:@"vip_pay" @@ -436,6 +460,34 @@ static const CGFloat JXheightForHeaderInSection = 39; return _agreementLabel; } +- (UIView *)documentContainer { + if (!_documentContainer) { + _documentContainer = [UIView new]; + } + return _documentContainer; +} + +- (UIButton *)privacyButton { + if (!_privacyButton) { + _privacyButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_privacyButton setTitle:KBLocalized(@"Privacy Policy") forState:UIControlStateNormal]; + [_privacyButton setTitleColor:[UIColor colorWithHex:KBColorValue] forState:UIControlStateNormal]; + _privacyButton.titleLabel.font = [KBFont regular:12]; + [_privacyButton addTarget:self action:@selector(onTapPrivacyButton) forControlEvents:UIControlEventTouchUpInside]; + } + return _privacyButton; +} + +- (UILabel *)documentSeparatorLabel { + if (!_documentSeparatorLabel) { + _documentSeparatorLabel = [UILabel new]; + _documentSeparatorLabel.text = @"|"; + _documentSeparatorLabel.textColor = [UIColor colorWithHex:KBBlackValue]; + _documentSeparatorLabel.font = [KBFont regular:12]; + } + return _documentSeparatorLabel; +} + - (UIButton *)agreementButton { if (!_agreementButton) { _agreementButton = [UIButton buttonWithType:UIButtonTypeCustom]; diff --git a/keyBoard/Class/WebView/KBWebViewViewController.m b/keyBoard/Class/WebView/KBWebViewViewController.m index a6b9a00..487ee1b 100644 --- a/keyBoard/Class/WebView/KBWebViewViewController.m +++ b/keyBoard/Class/WebView/KBWebViewViewController.m @@ -23,7 +23,6 @@ + (instancetype)legalViewControllerWithType:(KBLegalDocumentType)type { KBWebViewViewController *vc = [[KBWebViewViewController alloc] init]; - vc.pageTitle = [self kb_titleForLegalDocumentType:type]; NSString *remoteURL = [self kb_remoteURLForLegalDocumentType:type]; if (remoteURL.length > 0) { vc.url = remoteURL; @@ -72,15 +71,13 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - if (self.pageTitle.length > 0) { - self.title = self.pageTitle; - } } - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = UIColor.whiteColor; [self configUI]; + self.kb_titleLabel.hidden = true; } - (void)configUI { @@ -128,9 +125,6 @@ // 5. 加载内容 if (self.htmlString.length > 0) { [self.webView loadHTMLString:self.htmlString baseURL:nil]; - if (self.pageTitle.length > 0) { - self.title = self.pageTitle; - } return; } @@ -191,9 +185,7 @@ // 加载完成 - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { NSLog(@"页面加载成功"); - if (self.pageTitle.length > 0) { - self.title = self.pageTitle; - } else if (webView.title.length > 0) { + if (webView.title.length > 0) { self.title = webView.title; } }