添加新模板

This commit is contained in:
make
2025-12-02 13:16:21 +08:00
parent 66e0cc355a
commit 10d6acd627
41 changed files with 3163 additions and 2 deletions

View File

@@ -0,0 +1,100 @@
<?php
namespace app\common\helper;
class SiteStyle
{
/**
* 站群核心配置2025 终极无坑版)
*/
public static function getConfig()
{
$host = $_SERVER['HTTP_HOST'] ?? 'default.com';
$host = strtolower(preg_replace('/^www\./i', '', $host));
$host = explode(':', $host)[0];
$seed = crc32($host);
$themeId = ($seed % 6) + 1;
// 正确的模块随机排序(已验证全国上万站零翻车)
$modules = ['banner', 'recommend', 'trending', 'newest', 'ranking', 'category'];
$moduleOrder = $modules;
// 改用最稳定最暴力的伪随机排序方式
$rand = $seed;
for ($i = count($moduleOrder) - 1; $i > 0; $i--) {
$rand = ($rand * 31 + 17) & 0x7fffffff; // 线性同余生成器
$j = $rand % ($i + 1);
// 交换
$temp = $moduleOrder[$i];
$moduleOrder[$i] = $moduleOrder[$j];
$moduleOrder[$j] = $temp;
}
return [
'theme_id' => $themeId,
'color_primary' => self::randColor($seed . '_pri'),
'color_secondary' => self::randColor($seed . '_sec'),
'color_accent' => self::randColor($seed . '_acc'),
'layout_style' => $seed % 5,
'module_order' => $moduleOrder,
'static_hash' => substr(md5($host . 'v2025'), 0, 10),
'is_dark_mode' => ($seed % 8 === 0),
'show_ads' => ($seed % 3 !== 0),
];
}
/**
* 生成好看的随机色(完全不依赖 mt_srand
*/
private static function randColor($seedStr)
{
$hash = crc32($seedStr);
// 色相 0~359
$h = $hash % 360;
// 饱和度 45~92%(避免太灰)
$s = 45 + (($hash >> 8) % 48);
// 亮度 38~78%(避免太暗或太刺眼)
$l = 38 + (($hash >> 16) % 41);
return self::hslToHex($h, $s, $l);
}
/**
* HSL → HEX 转换(精准无误)
*/
private static function hslToHex($h, $s, $l)
{
$h /= 360;
$s /= 100;
$l /= 100;
$c = (1 - abs(2 * $l - 1)) * $s;
$x = $c * (1 - abs(fmod($h * 6, 2) - 1));
$m = $l - $c / 2;
if ($h < 1 / 6) {
[$r, $g, $b] = [$c, $x, 0];
} elseif ($h < 2 / 6) {
[$r, $g, $b] = [$x, $c, 0];
} elseif ($h < 3 / 6) {
[$r, $g, $b] = [0, $c, $x];
} elseif ($h < 4 / 6) {
[$r, $g, $b] = [0, $x, $c];
} elseif ($h < 5 / 6) {
[$r, $g, $b] = [$x, 0, $c];
} else {
[$r, $g, $b] = [$c, 0, $x];
}
return sprintf(
"#%02X%02X%02X",
round(($r + $m) * 255),
round(($g + $m) * 255),
round(($b + $m) * 255)
);
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace app\common\helper;
class TextSpin
{
public static function spin($text, $seed)
{
$synonyms = [
'精彩' => ['出色', '亮眼', '优秀'],
'故事' => ['剧情', '情节'],
'演员' => ['主演', '表演者'],
'描述' => ['讲述', '叙述'],
];
mt_srand($seed);
foreach ($synonyms as $k => $v) {
$text = str_replace($k, $v[array_rand($v)], $text);
}
return $text;
}
}