gpttemp
This commit is contained in:
0
code/app/common/helper/style/BreadcrumbRule.php
Normal file
0
code/app/common/helper/style/BreadcrumbRule.php
Normal file
154
code/app/common/helper/style/DetailMainRule.php
Normal file
154
code/app/common/helper/style/DetailMainRule.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\helper\style;
|
||||
|
||||
class DetailMainRule
|
||||
{
|
||||
public static function build(int $seed): array
|
||||
{
|
||||
$cover = self::compose(self::coverAtoms(), $seed + 23);
|
||||
$cover['extra'] = self::fillExtra($cover['extra'], $video);
|
||||
|
||||
return [
|
||||
'blocks' => [
|
||||
'title' => self::compose(self::titleAtoms(), $seed + 11),
|
||||
'cover' => $cover,
|
||||
'meta' => self::compose(self::metaAtoms(), $seed + 37),
|
||||
'desc' => self::compose(self::descAtoms(), $seed + 51),
|
||||
'action' => self::compose(self::actionAtoms(), $seed + 67),
|
||||
],
|
||||
'order' => self::pickOrder($seed),
|
||||
];
|
||||
}
|
||||
|
||||
/* ========= 原子池 ========= */
|
||||
|
||||
public static function titleAtoms(): array
|
||||
{
|
||||
return [
|
||||
'tag' => ['h1', 'h2'],
|
||||
'wrap' => ['none', 'header', 'div'],
|
||||
'show_year' => [true, false],
|
||||
'emphasis' => ['none', 'strong', 'em'],
|
||||
];
|
||||
}
|
||||
|
||||
public static function metaAtoms(): array
|
||||
{
|
||||
return [
|
||||
'layout' => ['ul', 'dl', 'inline'],
|
||||
'fields' => [
|
||||
['category', 'year', 'area'],
|
||||
['year', 'category'],
|
||||
['area', 'year'],
|
||||
],
|
||||
'separator' => [' / ', ' · '],
|
||||
];
|
||||
}
|
||||
|
||||
public static function descAtoms(): array
|
||||
{
|
||||
return [
|
||||
'container' => ['p', 'div', 'section'],
|
||||
'mode' => ['full', 'short'],
|
||||
'expandable' => [true, false],
|
||||
];
|
||||
}
|
||||
|
||||
public static function actionAtoms(): array
|
||||
{
|
||||
return [
|
||||
'type' => ['link', 'button', 'nav'],
|
||||
'show_hint' => [true, false],
|
||||
'text' => ['立即播放', '在线观看', '免费播放'],
|
||||
];
|
||||
}
|
||||
|
||||
// Cover Block 原子池
|
||||
public static function coverAtoms(): array
|
||||
{
|
||||
return [
|
||||
// 外层容器结构
|
||||
'container' => [
|
||||
'div.dm-cover',
|
||||
'figure.dm-cover',
|
||||
'div.dm-cover-bg',
|
||||
'section.dm-cover',
|
||||
],
|
||||
|
||||
// 图片表现形式
|
||||
'image' => [
|
||||
'img', // <img>
|
||||
'bg', // background-image
|
||||
],
|
||||
|
||||
// 附加元素
|
||||
'extra' => [
|
||||
'',
|
||||
'<span class="label">{remarks}</span>',
|
||||
'<figcaption>{remarks}</figcaption>',
|
||||
],
|
||||
|
||||
// 比例控制(CSS class)
|
||||
'ratio' => [
|
||||
'r23', // 2:3
|
||||
'r34', // 3:4
|
||||
'r11', // 1:1
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/* ========= 组合器 ========= */
|
||||
|
||||
protected static function compose(array $atoms, int $seed): array
|
||||
{
|
||||
$pick = function (?array $list, int $shift, $default = null) use ($seed) {
|
||||
if (empty($list)) {
|
||||
return $default;
|
||||
}
|
||||
return $list[($seed >> $shift) % count($list)];
|
||||
};
|
||||
|
||||
return [
|
||||
'container' => $pick($atoms['container'] ?? null, 0),
|
||||
'image' => $pick($atoms['image'] ?? null, 2, 'img'),
|
||||
'extra' => $pick($atoms['extra'] ?? null, 4, ''),
|
||||
'ratio' => $pick($atoms['ratio'] ?? null, 6, ''),
|
||||
'fields' => $pick($atoms['fields'] ?? null, 8, []),
|
||||
'mode' => $pick($atoms['mode'] ?? null, 10, 'raw'),
|
||||
'trigger' => $pick($atoms['trigger'] ?? null, 12),
|
||||
'text' => $pick($atoms['text'] ?? null, 14, ''),
|
||||
'separator' => $pick($atoms['separator'] ?? null, 16, ' '),
|
||||
'expand' => $pick($atoms['expand'] ?? null, 18, false),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
protected static function pickOrder(int $seed): array
|
||||
{
|
||||
$orders = [
|
||||
['title', 'cover', 'meta', 'desc', 'action'],
|
||||
['cover', 'title', 'meta', 'desc'],
|
||||
['title', 'meta', 'desc', 'cover', 'action'],
|
||||
['meta', 'title', 'cover', 'desc'],
|
||||
];
|
||||
return $orders[$seed % count($orders)];
|
||||
}
|
||||
|
||||
protected static function fillExtra(string $extra, array $video): string
|
||||
{
|
||||
if ($extra === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return str_replace(
|
||||
['{remarks}', '{year}', '{name}'],
|
||||
[
|
||||
$video['v_remarks'] ?? '',
|
||||
$video['v_year'] ?? '',
|
||||
$video['v_name'] ?? '',
|
||||
],
|
||||
$extra
|
||||
);
|
||||
}
|
||||
}
|
||||
0
code/app/common/helper/style/ListRule.php
Normal file
0
code/app/common/helper/style/ListRule.php
Normal file
0
code/app/common/helper/style/PlayLineRule.php
Normal file
0
code/app/common/helper/style/PlayLineRule.php
Normal file
0
code/app/common/helper/style/SeoWordsRule.php
Normal file
0
code/app/common/helper/style/SeoWordsRule.php
Normal file
Reference in New Issue
Block a user