mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: ai translate
Closes #1285 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -247,13 +247,15 @@ class VideoDetailController extends GetxController
|
||||
imageStatus = false;
|
||||
}
|
||||
|
||||
final isLoginVideo = Accounts.get(AccountType.video).isLogin;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
args = Get.arguments;
|
||||
videoType = args['videoType'];
|
||||
if (videoType == VideoType.pgc) {
|
||||
if (!Accounts.get(AccountType.video).isLogin) {
|
||||
if (!isLoginVideo) {
|
||||
_actualVideoType = VideoType.ugc;
|
||||
}
|
||||
} else if (args['pgcApi'] == true) {
|
||||
@@ -1112,6 +1114,17 @@ class VideoDetailController extends GetxController
|
||||
|
||||
bool isQuerying = false;
|
||||
|
||||
final Rx<List<LanguageItem>?> languages = Rx<List<LanguageItem>?>(null);
|
||||
final Rx<String?> currLang = Rx(null);
|
||||
void setLanguage(String language) {
|
||||
if (!isLoginVideo) {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
return;
|
||||
}
|
||||
currLang.value = language;
|
||||
queryVideoUrl(defaultST: playedTime);
|
||||
}
|
||||
|
||||
// 视频链接
|
||||
Future<void> queryVideoUrl({
|
||||
Duration? defaultST,
|
||||
@@ -1142,11 +1155,15 @@ class VideoDetailController extends GetxController
|
||||
seasonId: seasonId,
|
||||
tryLook: plPlayerController.tryLook,
|
||||
videoType: _actualVideoType ?? videoType,
|
||||
language: currLang.value,
|
||||
);
|
||||
|
||||
if (result.isSuccess) {
|
||||
data = result.data;
|
||||
|
||||
languages.value = data.language?.items;
|
||||
currLang.value = data.curLanguage;
|
||||
|
||||
if (data.acceptDesc?.contains('试看') == true) {
|
||||
SmartDialog.showToast(
|
||||
'该视频为专属视频,仅提供试看',
|
||||
@@ -1564,6 +1581,10 @@ class VideoDetailController extends GetxController
|
||||
videoUrl = null;
|
||||
audioUrl = null;
|
||||
|
||||
// language
|
||||
languages.value = null;
|
||||
currLang.value = null;
|
||||
|
||||
if (scrollRatio.value != 0) {
|
||||
scrollRatio.refresh();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user