* [pref] Add build dot style method.

This commit is contained in:
wangyidong
2024-08-02 15:29:30 +08:00
committed by 孙广明
parent 908e279701
commit f22816cdfd
2 changed files with 17 additions and 10 deletions
+1 -10
View File
@@ -255,18 +255,9 @@ class header extends wg
if(!$config->message->browser->turnon) return null;
$showCount = $config->message->browser->count;
$dotStyle = array('top' => '-3px', 'right' => '-10px', 'aspect-ratio' => '0', 'padding' => '2px');
$unreadCount = $app->dbh->query("SELECT COUNT(1) as count FROM " . TABLE_NOTIFY . " WHERE `objectType` = 'message' AND status != 'read' AND `toList` = ',{$app->user->account},'")->fetch()->count;
$dotStyle = commonModel::getDotStyle($showCount != '0', $unreadCount);
if($unreadCount > 99) $unreadCount = '99+';
if($unreadCount < 10) $dotStyle['right'] = '-5px';
if(!$showCount)
{
$dotStyle['aspect-ratio'] = '1 / 1';
$dotStyle['width'] = '5px';
$dotStyle['height'] = '5px';
$dotStyle['right'] = '-2px';
$dotStyle['top'] = '-2px';
}
return dropdown
(
+16
View File
@@ -3750,6 +3750,22 @@ $(function()
</script>
EOF;
}
public static function getDotStyle(bool $showCount, int $unreadCount): array
{
$dotStyle = array('top' => '-3px', 'right' => '-10px', 'aspect-ratio' => '0', 'padding' => '2px');
if($unreadCount < 10) $dotStyle['right'] = '-5px';
if(!$showCount)
{
$dotStyle['aspect-ratio'] = '1 / 1';
$dotStyle['width'] = '5px';
$dotStyle['height'] = '5px';
$dotStyle['right'] = '-2px';
$dotStyle['top'] = '-2px';
}
return $dotStyle;
}
}
class common extends commonModel