更改Tile对齐

master
落雨楓 2 months ago
parent b7b0a6f490
commit be5ad56fe4

@ -21,12 +21,14 @@ class PreviewPageListWidget {
$pageListHtml = []; $pageListHtml = [];
foreach ($pageList as $pageTitle) { foreach ($pageList as $pageTitle) {
$title = Title::newFromText($pageTitle); $title = Title::newFromText($pageTitle);
if ($title) {
$pageListHtml[] = Html::rawElement('a', ['class' => 'isekai-list-item', 'href' => $title->getLocalURL()], $pageListHtml[] = Html::rawElement('a', ['class' => 'isekai-list-item', 'href' => $title->getLocalURL()],
Html::rawElement('div', ['class' => 'isekai-list-item-content'], Html::rawElement('div', ['class' => 'isekai-list-item-content'],
Html::element('div', ['class' => 'isekai-list-item-title'], $title->getPrefixedText()) Html::element('div', ['class' => 'isekai-list-item-title'], $title->getPrefixedText())
) )
); );
} }
}
return return
Html::openElement('div', [ Html::openElement('div', [
@ -61,6 +63,7 @@ class PreviewPageListWidget {
$lazyLoad = true; $lazyLoad = true;
} }
$resultHtml = null;
switch ($loader) { switch ($loader) {
case 'pages': case 'pages':
$pageList = explode("\n", trim($text)); $pageList = explode("\n", trim($text));
@ -68,18 +71,21 @@ class PreviewPageListWidget {
return trim($page); return trim($page);
}, $pageList); }, $pageList);
return Html::openElement('div', [ $resultHtml = Html::openElement('div', [
'class' => self::CONTAINER_CLASS_NAME, 'class' => self::CONTAINER_CLASS_NAME,
'data-loader' => $loader, 'data-loader' => $loader,
'data-autofocus' => $autoFocus, 'data-autofocus' => $autoFocus,
'data-lazyload' => $lazyLoad, 'data-lazyload' => $lazyLoad,
]) . ]) .
Html::element('script', [ Html::openElement('script', [
'type' => 'application/json', 'type' => 'application/json',
'data-pages' => true, 'data-pages' => true,
], json_encode($pageList)) . ]) .
json_encode($pageList) .
Html::closeElement('script') .
self::buildFallbackPageList($pageList) . self::buildFallbackPageList($pageList) .
Html::closeElement('div'); Html::closeElement('div');
break;
case 'category': case 'category':
$category = $params['category'] ?? null; $category = $params['category'] ?? null;
if (!$category) { if (!$category) {
@ -118,7 +124,7 @@ class PreviewPageListWidget {
]); ]);
} }
return Html::openElement('div', [ $resultHtml = Html::openElement('div', [
'class' => self::CONTAINER_CLASS_NAME, 'class' => self::CONTAINER_CLASS_NAME,
'data-loader' => $loader, 'data-loader' => $loader,
'data-category' => $categoryTitleText, 'data-category' => $categoryTitleText,
@ -127,10 +133,15 @@ class PreviewPageListWidget {
]) . ]) .
self::buildFallbackPageList($pageList) . self::buildFallbackPageList($pageList) .
Html::closeElement('div'); Html::closeElement('div');
break;
} }
return Html::element('span', [ if (!$resultHtml) {
$resultHtml = Html::element('span', [
'class' => 'error' 'class' => 'error'
], wfMessage('isekai-preview-page-list-error-invalid-loader', $loader)->parse()); ], wfMessage('isekai-preview-page-list-error-invalid-loader', $loader)->parse());
} }
return $resultHtml;
}
} }

@ -138,6 +138,11 @@ class CategoryPageListLoader extends BasePageListLoader {
} }
} }
function htmlDecode(input) {
var doc = new DOMParser().parseFromString(input, "text/html");
return doc.documentElement.textContent;
}
let previewPageList = document.querySelectorAll('.isekai-preview-page-list-card'); let previewPageList = document.querySelectorAll('.isekai-preview-page-list-card');
if (previewPageList.length > 0) { if (previewPageList.length > 0) {
const App = require("./PreviewPageList.vue"); const App = require("./PreviewPageList.vue");
@ -154,7 +159,8 @@ if (previewPageList.length > 0) {
let pagesJsonEl = document.querySelector('script[type="application/json"][data-pages]'); let pagesJsonEl = document.querySelector('script[type="application/json"][data-pages]');
let pageList = []; let pageList = [];
if (pagesJsonEl) { if (pagesJsonEl) {
pageList = JSON.parse(pagesJsonEl.innerText); let jsonStr = htmlDecode(pagesJsonEl.innerText);
pageList = JSON.parse(jsonStr);
} }
props.pageListLoader = new PresetPageListLoader(pageList); props.pageListLoader = new PresetPageListLoader(pageList);
break; break;

@ -1186,6 +1186,7 @@
width: 100%; width: 100%;
float: left; float: left;
overflow: visible; overflow: visible;
justify-content: center;
} }
.tiles-group::before { .tiles-group::before {
content: attr(data-group-title); content: attr(data-group-title);

Loading…
Cancel
Save