From 01dba5acbb4ed20c5f3a3223869ef18f7dc2144d Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 19 Jun 2025 08:55:33 +0800 Subject: [PATCH] * [perf story #75384] Adjust product dynamic page. --- module/product/control.php | 4 ++-- module/product/ui/dynamic.html.php | 31 ++++++++++++++++++++---------- module/product/zen.php | 5 ++--- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/module/product/control.php b/module/product/control.php index 5a606ae10a..c58843f1df 100755 --- a/module/product/control.php +++ b/module/product/control.php @@ -517,8 +517,8 @@ class product extends control } /* Get actions. */ - list($actions, $dateGroups) = $this->productZen->getActionsForDynamic($account, $orderBy, $productID, $type, $recTotal, $date, $direction); - if(empty($recTotal)) $recTotal = count($dateGroups) < 2 ? count($dateGroups, 1) - count($dateGroups) : $this->action->getDynamicCount(); + list($actions, $dateGroups) = $this->productZen->getActionsForDynamic($account, $orderBy, $productID, $type, $date, $direction); + if(empty($recTotal) && $dateGroups) $recTotal = $this->action->getDynamicCount(); /* Assign. */ $this->view->title = $this->products[$productID] . $this->lang->hyphen . $this->lang->product->dynamic; diff --git a/module/product/ui/dynamic.html.php b/module/product/ui/dynamic.html.php index 50f7b371f4..7eb5be3c52 100644 --- a/module/product/ui/dynamic.html.php +++ b/module/product/ui/dynamic.html.php @@ -17,6 +17,7 @@ featureBar ( set::current($type), set::linkParams("productID={$productID}&type={key}"), + set::labelCount($recTotal < \actionModel::MAXCOUNT ? $recTotal : (\actionModel::MAXCOUNT - 1) . '+'), li ( setClass('w-40'), @@ -53,10 +54,9 @@ $firstAction = null; $lastAction = null; foreach($dateGroups as $date => $actions) { - $isToday = date(DT_DATE4) == $date; - + $lastAction = end($actions); + $isToday = date(DT_DATE4) == $date; if(empty($firstAction)) $firstAction = reset($actions); - $dynamicsGroup[] = li ( div @@ -84,15 +84,26 @@ foreach($dateGroups as $date => $actions) ) ) ); - - $lastAction = end($actions); } -$content = ul -( - setClass('timeline list-none pl-0'), - $dynamicsGroup -); +global $app; +$hasMore = $app->control->loadModel('action')->hasMoreAction($lastAction); +if($hasMore) +{ + $dynamicsGroup[] = li + ( + a + ( + setID('showMoreDynamic'), + setClass('block text-center'), + setData(array('lastid' => $lastAction->id)), + set::href('###'), + on::click('showMore'), + icon('chevron-double-down') + ) + ); +} +$content = ul(setClass('timeline list-none pl-0'), $dynamicsGroup); panel($content); diff --git a/module/product/zen.php b/module/product/zen.php index c3972d2e3e..ad15b3d8e8 100644 --- a/module/product/zen.php +++ b/module/product/zen.php @@ -1322,18 +1322,17 @@ class productZen extends product * @param string $orderBy * @param int $productID * @param string $type - * @param int $recTotal * @param string $date * @param string $direction next|pre * @access protected * @return [array, object] */ - protected function getActionsForDynamic(string $account, string $orderBy, int $productID, string $type, int $recTotal, string $date, string $direction): array + protected function getActionsForDynamic(string $account, string $orderBy, int $productID, string $type, string $date, string $direction): array { /* Build parameters. */ $period = $type == 'account' ? 'all' : $type; $date = empty($date) ? '' : date('Y-m-d', (int)$date); - $actions = $this->loadModel('action')->getDynamic($account, $period, $orderBy, 50, $productID, 'all', 'all', $date, $direction); + $actions = $this->loadModel('action')->getDynamicByProduct($productID, $account, $period, $orderBy, 50, $date, $direction); $dateGroups = $this->action->buildDateGroup($actions, $direction); return array($actions, $dateGroups);