6277e86d0f
Deploy Server / deploy-server (push) Successful in 2m56s
SSO: web_launch.openWebUserCenter → POST /v1/auth/web-ticket → 打开 app.yanmeiai.com/sso?t=…; 设置页加「用户中心(网页)」入口。自动更新: update_provider 查 /version 语义比对 + update_dialog 「发现新版本」;设置页「检查更新」由空 onTap 接上。加 url_launcher(原缺)。flutter analyze 通过。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
30 lines
1.4 KiB
Dart
30 lines
1.4 KiB
Dart
// web_launch.dart — App→Web 单点登录跳转(SSO 换票)。
|
|
//
|
|
// 「用户中心(网页)」入口:先向控制面签一张短时单次票据
|
|
// (POST /v1/auth/web-ticket,需登录),再打开 用户中心网页版 的
|
|
// /sso?t=<票>&redirect=<路径> 落地页兑票登录——避免用户在网页端重新输入密码。
|
|
// 签票失败(未登录/网络异常)时降级为直接打开目标页(未登录态浏览)。
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
import '../state/account_providers.dart';
|
|
|
|
/// 用户中心(网页版)基址。
|
|
const String kWebUserCenterBaseUrl = 'https://app.yanmeiai.com';
|
|
|
|
/// 打开用户中心网页版 [path](默认首页),尝试免登录(SSO 换票)。
|
|
Future<void> openWebUserCenter(WidgetRef ref, {String path = '/'}) async {
|
|
Uri target = Uri.parse('$kWebUserCenterBaseUrl$path');
|
|
try {
|
|
final resp = await ref.read(apiClientProvider).postJson('/v1/auth/web-ticket');
|
|
final ticket = resp['ticket'] as String?;
|
|
if (ticket != null && ticket.isNotEmpty) {
|
|
target = Uri.parse(
|
|
'$kWebUserCenterBaseUrl/sso?t=$ticket&redirect=${Uri.encodeComponent(path)}');
|
|
}
|
|
} catch (_) {
|
|
// 签票失败(未登录/网络异常)降级:直接打开目标页(未登录态浏览)。
|
|
}
|
|
await launchUrl(target, mode: LaunchMode.externalApplication);
|
|
}
|