|
|
@@ -17,6 +17,7 @@ use Dcat\Admin\Grid;
|
|
|
use Dcat\Admin\Show;
|
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
|
use Spatie\RouteAttributes\Attributes\Resource;
|
|
|
+use UCore\Helper\Color;
|
|
|
|
|
|
/**
|
|
|
* 奖励组管理控制器
|
|
|
@@ -126,7 +127,7 @@ class GameRewardGroupController extends AdminController
|
|
|
$tagHtml[] = sprintf(
|
|
|
'<span class="badge" style="background-color: %s; color: %s;">%s</span>',
|
|
|
$tag['color'],
|
|
|
- $this->getContrastColor($tag['color']),
|
|
|
+ Color::getContrastColor($tag['coler']),
|
|
|
$tag['name']
|
|
|
);
|
|
|
}
|
|
|
@@ -401,19 +402,5 @@ class GameRewardGroupController extends AdminController
|
|
|
return (string)$item->quantity;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 根据背景色获取对比色
|
|
|
- *
|
|
|
- * @param string $hexColor
|
|
|
- * @return string
|
|
|
- */
|
|
|
- private function getContrastColor(string $hexColor): string
|
|
|
- {
|
|
|
- $hexColor = ltrim($hexColor, '#');
|
|
|
- $r = hexdec(substr($hexColor, 0, 2));
|
|
|
- $g = hexdec(substr($hexColor, 2, 2));
|
|
|
- $b = hexdec(substr($hexColor, 4, 2));
|
|
|
- $brightness = ($r * 299 + $g * 587 + $b * 114) / 1000;
|
|
|
- return $brightness > 128 ? '#000000' : '#ffffff';
|
|
|
- }
|
|
|
+
|
|
|
}
|