接入既有macOS硬件UUID登录恢复并校验产品会话,准备131

这个提交包含在:
mac 于 2026-11-11 19:39:21 +08:00 提交
1 父节点 4830f913c2
当前提交 d979f8958c
10 个文件已更改
+122 -21

没有与搜索条件相匹配的文件

+35 -10
查看文件
@@ -286,20 +286,45 @@ typedef NS_ENUM(NSInteger,DYRegistrationState) { DYChecking, DYRegistering, DYRe
[self.loginTimer invalidate];self.loginTimer=nil;self.loginSessionKey=nil;self.pollingLogin=NO;
self.loginButton.title=@"微信登录";self.loginButton.enabled=YES;self.accessButton.enabled=YES;
}
- (void)showOnlineAccount:(NSDictionary *)value {
self.accessButton.enabled=YES;self.logoutButton.enabled=YES;
BOOL allowed=[value[@"allowed"]isKindOfClass:NSNumber.class]&&[value[@"allowed"]boolValue];
self.accountTitle.stringValue=allowed?@"在线 LUT 已开放":@"账号已登录,尚无在线 LUT 权限";
NSString *name=[value[@"username"]isKindOfClass:NSString.class]?value[@"username"]:@"大鱼用户";
self.accountDetail.stringValue=[NSString stringWithFormat:@"%@\n%@",name,allowed?@"已识别本机绑定账号。在 FCP 的 LUT 浏览器切换“在线 LUT”即可使用。":@"需要有效会员,或购买文章 14421 / 15792。购买后点击刷新权限。"];
}
- (void)restoreBoundOnlineAccount {
NSUInteger generation=++self.accountGeneration;[self.accountTask cancel];
NSString *device=[DYOnlineLUTClient deviceUUID];
if(!device){self.accountTitle.stringValue=@"无法识别本机";self.accountDetail.stringValue=@"无法读取 macOS 硬件 UUID,请稍后重试。";return;}
self.accountTitle.stringValue=@"正在识别本机已绑定的大鱼账号…";self.accessButton.enabled=NO;
self.accountTask=[DYOnlineLUTClient request:@"/device-login" body:@{@"device_uuid":device} authenticated:NO completion:^(NSData *data,NSError *error){
if(generation!=self.accountGeneration)return;self.accountTask=nil;self.accessButton.enabled=YES;
NSDictionary *value=[DYOnlineLUTClient JSON:data error:&error];
NSDictionary *identity=[value[@"data"]isKindOfClass:NSDictionary.class]?value[@"data"]:nil;
NSString *token=[identity[@"token"]isKindOfClass:NSString.class]?identity[@"token"]:nil;
if(error||![value[@"success"]boolValue]||!token.length){self.accountTitle.stringValue=@"尚未登录";self.accountDetail.stringValue=error.localizedDescription?:([identity[@"message"]isKindOfClass:NSString.class]?identity[@"message"]:@"本机尚未绑定账号,请点击微信登录。已绑定账号可点击刷新权限重试。");return;}
self.accessButton.enabled=NO;
self.accountTask=[DYOnlineLUTClient request:@"/dayu-color/v1/lut/device" body:@{@"device_uuid":device,@"login_token":token} authenticated:NO completion:^(NSData *bytes,NSError *failure){
if(generation!=self.accountGeneration)return;self.accountTask=nil;self.accessButton.enabled=YES;
NSDictionary *account=[DYOnlineLUTClient JSON:bytes error:&failure];
if(failure||![DYOnlineLUTClient saveCredential:account error:&failure]){self.accountTitle.stringValue=@"暂时无法识别本机账号";self.accountDetail.stringValue=failure.localizedDescription?:@"请刷新权限,或重新微信登录。";return;}
[self showOnlineAccount:account];
}];
}];
}
- (void)refreshOnlineAccount:(id)sender {
if(self.loginSessionKey.length)return;
if(sender)[NSUserDefaults.standardUserDefaults setBool:NO forKey:@"DYOnlineLUTAutomaticLoginDisabled"];
NSUInteger generation=++self.accountGeneration;[self.accountTask cancel];
self.logoutButton.enabled=[DYOnlineLUTClient credential]!=nil;
if(!self.logoutButton.enabled){self.accountTitle.stringValue=@"尚未登录";self.accountDetail.stringValue=@"点击微信登录,在浏览器中完成账号确认后自动返回。";return;}
if(!self.logoutButton.enabled){if(![NSUserDefaults.standardUserDefaults boolForKey:@"DYOnlineLUTAutomaticLoginDisabled"]){[self restoreBoundOnlineAccount];return;}self.accountTitle.stringValue=@"已退出登录";self.accountDetail.stringValue=@"点击刷新权限可识别本机已绑定账号,也可以重新微信登录。";return;}
self.accountTitle.stringValue=@"正在验证在线 LUT 权限…";self.accessButton.enabled=NO;
self.accountTask=[DYOnlineLUTClient request:@"/dayu-color/v1/lut/status" body:@{} authenticated:YES completion:^(NSData *data,NSError *error){
if(generation!=self.accountGeneration)return;self.accountTask=nil;self.accessButton.enabled=YES;
NSDictionary *value=[DYOnlineLUTClient JSON:data error:&error];
if(error||!value){self.accountTitle.stringValue=@"暂时无法验证权限";self.accountDetail.stringValue=error.localizedDescription?:@"请稍后重试。";return;}
BOOL allowed=[value[@"allowed"]isKindOfClass:NSNumber.class]&&[value[@"allowed"]boolValue];
self.accountTitle.stringValue=allowed?@"在线 LUT 已开放":@"账号已登录,尚无在线 LUT 权限";
NSString *name=[value[@"username"]isKindOfClass:NSString.class]?value[@"username"]:@"大鱼用户";
self.accountDetail.stringValue=[NSString stringWithFormat:@"%@\n%@",name,allowed?@"在 FCP 的 LUT 浏览器切换“在线 LUT”即可使用。":@"需要有效会员,或购买文章 14421 / 15792。购买后点击刷新权限。"];
if(error||!value){if(error.code==401){[DYOnlineLUTClient clearCredential:nil];[self restoreBoundOnlineAccount];return;}self.accountTitle.stringValue=@"暂时无法验证权限";self.accountDetail.stringValue=error.localizedDescription?:@"请稍后重试。";return;}
[self showOnlineAccount:value];
}];
}
- (void)loginOnlineAccount:(id)sender {
@@ -333,15 +358,15 @@ typedef NS_ENUM(NSInteger,DYRegistrationState) { DYChecking, DYRegistering, DYRe
if(error){if(error.code==401||error.code==400){[self stopAccountLogin];self.accountDetail.stringValue=error.localizedDescription;}return;}
if(![value[@"status"]isEqual:@"approved"]){self.accountDetail.stringValue=[value[@"message"]isKindOfClass:NSString.class]?value[@"message"]:@"等待微信登录…";return;}
if(![DYOnlineLUTClient saveCredential:value error:&error]){[self stopAccountLogin];self.accountDetail.stringValue=error.localizedDescription;return;}
[self stopAccountLogin];[self refreshOnlineAccount:nil];
[NSUserDefaults.standardUserDefaults setBool:NO forKey:@"DYOnlineLUTAutomaticLoginDisabled"];[self stopAccountLogin];[self refreshOnlineAccount:nil];
}];
}
- (void)logoutOnlineAccount:(id)sender {
[self stopAccountLogin];
[self stopAccountLogin];NSUInteger generation=self.accountGeneration;
self.accountTask=[DYOnlineLUTClient request:@"/dayu-color/v1/lut/logout" body:@{} authenticated:YES completion:^(NSData *data,NSError *error){
self.accountTask=nil;
if(generation!=self.accountGeneration)return;self.accountTask=nil;
if(error&&error.code!=401){self.accountDetail.stringValue=@"暂时无法通知服务器退出,请联网后重试。";return;}
NSError *local=nil;if(![DYOnlineLUTClient clearCredential:&local]){self.accountDetail.stringValue=local.localizedDescription;return;}[self refreshOnlineAccount:nil];
NSError *local=nil;if(![DYOnlineLUTClient clearCredential:&local]){self.accountDetail.stringValue=local.localizedDescription;return;}[NSUserDefaults.standardUserDefaults setBool:YES forKey:@"DYOnlineLUTAutomaticLoginDisabled"];[self refreshOnlineAccount:nil];
}];
}