fix: ai conclusion

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-02-15 14:23:15 +08:00
parent be03377449
commit fc6ff44471
2 changed files with 102 additions and 91 deletions

View File

@@ -651,7 +651,15 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
final res = final res =
await videoIntroController.aiConclusion(); await videoIntroController.aiConclusion();
if (res['status']) { if (res['status']) {
widget.showAiBottomSheet(); if (videoIntroController.modelResult.summary
.isNullOrEmpty &&
videoIntroController
.modelResult.outline ==
null) {
SmartDialog.showToast("当前视频不支持AI视频总结");
} else {
widget.showAiBottomSheet();
}
} }
}, },
child: Image.asset('assets/images/ai.png', child: Image.asset('assets/images/ai.png',

View File

@@ -8,11 +8,11 @@ import 'package:PiliPlus/pages/video/detail/index.dart';
import 'package:PiliPlus/utils/utils.dart'; import 'package:PiliPlus/utils/utils.dart';
class AiDetail extends StatelessWidget { class AiDetail extends StatelessWidget {
final ModelResult? modelResult; final ModelResult modelResult;
const AiDetail({ const AiDetail({
super.key, super.key,
this.modelResult, required this.modelResult,
}); });
@override @override
@@ -24,7 +24,7 @@ class AiDetail extends StatelessWidget {
child: Column( child: Column(
children: [ children: [
InkWell( InkWell(
onTap: () => Get.back(), onTap: Get.back,
child: Container( child: Container(
height: 35, height: 35,
padding: const EdgeInsets.only(bottom: 2), padding: const EdgeInsets.only(bottom: 2),
@@ -44,115 +44,118 @@ class AiDetail extends StatelessWidget {
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
if (modelResult!.summary != null && if (modelResult.summary?.isNotEmpty == true) ...[
modelResult!.summary!.isNotEmpty) ...[
SelectableText( SelectableText(
'总结: ${modelResult!.summary!}', '总结: ${modelResult.summary}',
style: const TextStyle( style: const TextStyle(
fontSize: 15, fontSize: 15,
height: 1.5, height: 1.5,
), ),
), ),
if (modelResult!.outline!.isNotEmpty) if (modelResult.outline?.isNotEmpty == true)
Divider( Divider(
height: 20, height: 20,
color: Theme.of(context).dividerColor.withOpacity(0.1), color: Theme.of(context).dividerColor.withOpacity(0.1),
thickness: 6, thickness: 6,
) )
], ],
ListView.builder( if (modelResult.outline?.isNotEmpty == true)
shrinkWrap: true, ListView.builder(
itemCount: modelResult!.outline!.length, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), itemCount: modelResult.outline!.length,
itemBuilder: (context, index) { physics: const NeverScrollableScrollPhysics(),
return Column( itemBuilder: (context, index) {
children: [ return Column(
SelectableText( children: [
modelResult!.outline![index].title!, SelectableText(
style: const TextStyle( modelResult.outline![index].title!,
fontSize: 14, style: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 14,
height: 1.5, fontWeight: FontWeight.bold,
height: 1.5,
),
), ),
), const SizedBox(height: 6),
const SizedBox(height: 6), if (modelResult
ListView.builder( .outline![index].partOutline?.isNotEmpty ==
shrinkWrap: true, true)
physics: const NeverScrollableScrollPhysics(), ListView.builder(
itemCount: modelResult! shrinkWrap: true,
.outline![index].partOutline!.length, physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, i) { itemCount: modelResult
return Column( .outline![index].partOutline!.length,
crossAxisAlignment: CrossAxisAlignment.start, itemBuilder: (context, i) {
children: [ return Column(
Wrap( crossAxisAlignment:
CrossAxisAlignment.start,
children: [ children: [
SelectableText.rich( Wrap(
TextSpan( children: [
style: TextStyle( SelectableText.rich(
fontSize: 13,
color: Theme.of(context)
.colorScheme
.onSurface,
height: 1.5,
),
children: [
TextSpan( TextSpan(
text: Utils.tampToSeektime(
modelResult!
.outline![index]
.partOutline![i]
.timestamp!),
style: TextStyle( style: TextStyle(
fontSize: 13,
color: Theme.of(context) color: Theme.of(context)
.colorScheme .colorScheme
.primary, .onSurface,
height: 1.5,
), ),
recognizer: TapGestureRecognizer() children: [
..onTap = () { TextSpan(
// 跳转到指定位置 text: Utils.tampToSeektime(
try { modelResult
Get.find<VideoDetailController>( .outline![index]
tag: Get.arguments[ .partOutline![i]
'heroTag']) .timestamp!),
.plPlayerController style: TextStyle(
.seekTo( color: Theme.of(context)
Duration( .colorScheme
seconds: .primary,
Utils.duration( ),
Utils.tampToSeektime(modelResult! recognizer:
.outline![ TapGestureRecognizer()
index] ..onTap = () {
.partOutline![ // 跳转到指定位置
i] try {
.timestamp!) Get.find<VideoDetailController>(
.toString(), tag: Get.arguments[
), 'heroTag'])
), .plPlayerController
); .seekTo(
} catch (_) {} Duration(
}, seconds: Utils
.duration(
Utils.tampToSeektime(modelResult
.outline![index]
.partOutline![i]
.timestamp!)
.toString(),
),
),
);
} catch (_) {}
},
),
const TextSpan(text: ' '),
TextSpan(
text: modelResult
.outline![index]
.partOutline![i]
.content!),
],
), ),
const TextSpan(text: ' '), ),
TextSpan( ],
text: modelResult!
.outline![index]
.partOutline![i]
.content!),
],
),
), ),
], ],
), );
], },
); ),
}, const SizedBox(height: 20),
), ],
const SizedBox(height: 20), );
], },
); )
},
)
], ],
), ),
), ),