From 4b0a75560edcb7a76be39ee1114fab69df628bd2 Mon Sep 17 00:00:00 2001 From: filesite Date: Thu, 16 May 2024 12:22:45 +0800 Subject: [PATCH] improve task add, handle failed task --- themes/tajian/controller/FrontapiController.php | 17 ++++++++++++----- www/js/tajian.js | 6 +++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/themes/tajian/controller/FrontapiController.php b/themes/tajian/controller/FrontapiController.php index 9029cdc..71ecd85 100644 --- a/themes/tajian/controller/FrontapiController.php +++ b/themes/tajian/controller/FrontapiController.php @@ -130,10 +130,14 @@ Class FrontApiController extends SiteController { if ($code == 1) { //保存视频 $done = $this->saveShareVideo($shareUrl, $title, $tagName); - $msg = $done ? '视频保存完成,系统开始自动处理,1 - 3 分钟后刷新就能看到新添加的视频了。' : '视频保存失败,请稍后重试!'; - - //更新统计数据 - if ($done) { + $msg = '保存完成,系统开始自动处理,1 - 3 分钟后刷新就能看到新添加的收藏了。'; + + if (!$done) { + $msg = ''; + $err = '收藏保存失败,请确认分享网址格式正确并稍后重试!'; + $code = 0; + }else { + //更新统计数据 $stats = TajianStats::init(); TajianStats::increase('video'); $saved = TajianStats::save(); @@ -174,7 +178,10 @@ Class FrontApiController extends SiteController { if (!empty(FSC::$app['config']['heroUnionEnable'])) { $platformName = Html::getShareVideosPlatform($shareUrl); $heroUnionConfig = FSC::$app['config']['heroUnion']; - $this->addHeroUnionTask($shareUrl, $heroUnionConfig['supportedPlatforms'][$platformName]); + $addTaskRes = $this->addHeroUnionTask($shareUrl, $heroUnionConfig['supportedPlatforms'][$platformName]); + if (empty($addTaskRes['code'])) { + $done = false; + } } } diff --git a/www/js/tajian.js b/www/js/tajian.js index 1c8551a..4a71e75 100644 --- a/www/js/tajian.js +++ b/www/js/tajian.js @@ -151,7 +151,11 @@ if ($('#add_video_form').get(0)) { btText.text('提交'); btLoading.addClass('elementNone'); if (data.code == 1) { - $(inputList[0]).val(''); + if (data.err) { + alert(data.err); + }else { + $(inputList[0]).val(''); + } //alert(data.msg || data.err); } else { alert(data.err);