This commit is contained in:
2025-12-05 21:15:48 +08:00
parent 6fd4a86a7e
commit a26b6b58a9
3 changed files with 51 additions and 39 deletions

View File

@@ -218,19 +218,9 @@ static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center,
[self showFunctionPanel:NO];
return;
}
// // 1. UL Scheme
// // - /login entry=recharge
// // https://app.tknb.net/ul/login?src=keyboard&entry=recharge
// // - 宿 UL 退 kbkeyboardAppExtension://recharge?src=keyboard
// NSString *ulStr = [NSString stringWithFormat:@"%@?src=keyboard&entry=recharge", KB_UL_RECHARGE];
// NSURL *ul = [NSURL URLWithString:ulStr];
//
NSString *schemeStr = [NSString stringWithFormat:@"%@://recharge?src=keyboard", KB_APP_SCHEME];
NSURL *scheme = [NSURL URLWithString:schemeStr];
//
// if (!ul && !scheme) { return; }
//
// UIApplication App
BOOL ok = [KBHostAppLauncher openHostAppURL:scheme fromResponder:self.view];

View File

@@ -238,13 +238,25 @@
#pragma mark - Network Streaming (GET)
// ATS target Info.plist HTTP
static NSString * const kKBStreamDemoURL = @"http://192.168.1.144:7529/api/demo/talk";
//static NSString * const kKBStreamDemoURL = @"http://192.168.1.144:7529/api/demo/talk";
- (void)kb_startNetworkStreamingWithSeed:(NSString *)seedTitle {
[self kb_stopNetworkStreaming];
if (![[KBFullAccessManager shared] hasFullAccess]) { return; }
NSURL *url = [NSURL URLWithString:kKBStreamDemoURL];
NSString *apiUrl = [NSString stringWithFormat:@"%@%@", KB_BASE_URL, API_AI_TALK];
// seed query
if (seedTitle.length > 0) {
NSString *encodedSeed = [seedTitle stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]] ?: @"";
if (encodedSeed.length > 0) {
if ([apiUrl containsString:@"?"]) {
apiUrl = [apiUrl stringByAppendingFormat:@"&userInput=%@", encodedSeed];
} else {
apiUrl = [apiUrl stringByAppendingFormat:@"?userInput=%@", encodedSeed];
}
}
}
NSURL *url = [NSURL URLWithString:apiUrl];
if (!url) { return; }
self.streamHasOutput = NO; //
@@ -332,34 +344,42 @@ static NSString * const kKBStreamDemoURL = @"http://192.168.1.144:7529/api/demo/
// 2) -> App App
if (!KBAuthManager.shared.isLoggedIn) {
UIInputViewController *ivc = KBFindInputViewController(self);
if (!ivc) return;
NSString *encodedTitle = [title stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]] ?: @"";
NSURL *ul = [NSURL URLWithString:[NSString stringWithFormat:@"%@?src=functionView&index=%ld&title=%@", KB_UL_LOGIN, (long)index, encodedTitle]];
if (!ul) return;
// UL ok
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[ivc.extensionContext openURL:ul completionHandler:^(__unused BOOL ok) {}];
});
// 500ms App 退 Scheme宿 UIApplication
self.kb_ulHandledFlag = NO;
NSUInteger token = ++self.kb_ulSeq;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (token != self.kb_ulSeq) return; //
if (self.kb_ulHandledFlag) return; // App
NSURL *scheme = [NSURL URLWithString:[NSString stringWithFormat:@"%@://login?src=functionView&index=%ld&title=%@", KB_APP_SCHEME, (long)index, encodedTitle]];
if (!scheme) return;
UIResponder *start = ivc.view ?: (UIResponder *)self;
//
[ivc dismissKeyboard];
BOOL ok = [KBHostAppLauncher openHostAppURL:scheme fromResponder:start];
if (!ok) {
[KBHUD showInfo:KBLocalized(@"请切换到主App完成登录")];
}else{
}
});
NSString *schemeStr = [NSString stringWithFormat:@"%@://login?src=keyboard", KB_APP_SCHEME];
NSURL *scheme = [NSURL URLWithString:schemeStr];
// UIApplication App
BOOL ok = [KBHostAppLauncher openHostAppURL:scheme fromResponder:ivc.view];
return;
// if (!ivc) return;
// NSString *encodedTitle = [title stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]] ?: @"";
// NSURL *ul = [NSURL URLWithString:[NSString stringWithFormat:@"%@?src=functionView&index=%ld&title=%@", KB_UL_LOGIN, (long)index, encodedTitle]];
// if (!ul) return;
// // UL ok
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// [ivc.extensionContext openURL:ul completionHandler:^(__unused BOOL ok) {}];
// });
// // 500ms App 退 Scheme宿 UIApplication
// self.kb_ulHandledFlag = NO;
// NSUInteger token = ++self.kb_ulSeq;
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// if (token != self.kb_ulSeq) return; //
// if (self.kb_ulHandledFlag) return; // App
// NSURL *scheme = [NSURL URLWithString:[NSString stringWithFormat:@"%@://login?src=functionView&index=%ld&title=%@", KB_APP_SCHEME, (long)index, encodedTitle]];
// if (!scheme) return;
// UIResponder *start = ivc.view ?: (UIResponder *)self;
// //
// [ivc dismissKeyboard];
// BOOL ok = [KBHostAppLauncher openHostAppURL:scheme fromResponder:start];
// if (!ok) {
// [KBHUD showInfo:KBLocalized(@"请切换到主App完成登录")];
// }else{
//
// }
// });
// return;
}
// 3)

View File

@@ -43,6 +43,8 @@
/// pay
#define API_VALIDATE_RECEIPT @"/api/apple/validate-receipt" // 排行榜标签列表
/// AI
#define API_AI_TALK @"/demo/talk" // 排行榜标签列表