asdsd
All checks were successful
Deploy / deploy-staging (push) Successful in 23s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-06-21 00:42:49 +02:00
parent b81de785ac
commit dedd235ec2
3 changed files with 70 additions and 30 deletions

View File

@@ -1,15 +1,35 @@
(function () {
const root = document.getElementById('mining-checker-app');
window.initMiningCheckerApp = function initMiningCheckerApp(rootNode, options) {
const root = rootNode || document.getElementById('mining-checker-app');
if (!root || !window.React || !window.ReactDOM) {
return;
}
if (root.dataset.moduleInitialized === '1') {
return;
}
root.dataset.moduleInitialized = '1';
const React = window.React;
const ReactDOM = window.ReactDOM;
const h = React.createElement;
const { useEffect, useMemo, useRef, useState } = React;
const apiBase = root.dataset.apiBase || '/api/mining-checker/v1';
const initialProjectKey = root.dataset.defaultProjectKey || 'doge-main';
const initialActiveTab = String(root.dataset.activeView || 'overview').trim() || 'overview';
const normalizedOptions = options && typeof options === 'object' ? options : {};
const apiBase = normalizedOptions.apiBase || root.dataset.apiBase || '/api/mining-checker/v1';
const initialProjectKey = normalizedOptions.defaultProjectKey || root.dataset.defaultProjectKey || 'doge-main';
const initialActiveTab = String(normalizedOptions.activeView || root.dataset.activeView || 'overview').trim() || 'overview';
const configuredSections = (() => {
const optionSections = Array.isArray(normalizedOptions.sections) ? normalizedOptions.sections : null;
if (optionSections) {
return optionSections
.map((section) => {
const key = section && typeof section.key === 'string' ? section.key.trim() : '';
const label = section && typeof section.label === 'string' ? section.label.trim() : '';
return key && label ? [key, label] : null;
})
.filter(Boolean);
}
try {
const parsed = JSON.parse(root.dataset.sectionsJson || '[]');
if (!Array.isArray(parsed)) {
@@ -26,7 +46,8 @@
return [];
}
})();
const initialDebugMode = document.body && document.body.dataset.moduleDebugEnabled === '1';
const initialDebugMode = normalizedOptions.moduleDebugEnabled === true
|| (document.body && document.body.dataset.moduleDebugEnabled === '1');
function getCookie(name) {
const pattern = `; ${document.cookie}`;
const parts = pattern.split(`; ${name}=`);
@@ -3264,4 +3285,10 @@
}
ReactDOM.createRoot(root).render(h(App));
};
const standaloneRoot = document.getElementById('mining-checker-app');
if (standaloneRoot) {
window.initMiningCheckerApp(standaloneRoot);
}
})();

View File

@@ -21,6 +21,13 @@ $sections = array_values(array_filter(
static fn (mixed $section): bool => is_array($section)
));
$assetVersion = static function (string $relativePath): string {
$fullPath = __DIR__ . '/' . ltrim($relativePath, '/');
$mtime = is_file($fullPath) ? filemtime($fullPath) : false;
return $mtime === false ? '0' : (string) $mtime;
};
return [
'app_id' => 'mining-checker',
'title' => (string) ($manifest['title'] ?? 'Mining-Checker'),
@@ -45,12 +52,12 @@ return [
],
'assets' => [
'styles' => [
['href' => '/module-assets/index.php?module=mining-checker&path=assets/css/app.css'],
['href' => '/module-assets/index.php?module=mining-checker&path=assets/css/app.css&v=' . rawurlencode($assetVersion('assets/css/app.css'))],
],
'scripts' => [
['src' => 'https://unpkg.com/react@18/umd/react.production.min.js', 'crossorigin' => true],
['src' => 'https://unpkg.com/react-dom@18/umd/react-dom.production.min.js', 'crossorigin' => true],
['src' => '/module-assets/index.php?module=mining-checker&path=assets/js/app.js'],
['src' => '/module-assets/index.php?module=mining-checker&path=assets/js/app.js&v=' . rawurlencode($assetVersion('assets/js/app.js'))],
],
],
],

View File

@@ -21,6 +21,12 @@ if ($designRaw !== false) {
$moduleConfig = require dirname(__DIR__) . '/config/module.php';
$defaultProjectKey = (string) ($moduleConfig['default_project_key'] ?? 'doge-main');
$assetVersion = static function (string $relativePath): string {
$fullPath = dirname(__DIR__) . '/' . ltrim($relativePath, '/');
$mtime = is_file($fullPath) ? filemtime($fullPath) : false;
return $mtime === false ? '0' : (string) $mtime;
};
$sections = is_array($design['sections'] ?? null) ? $design['sections'] : [];
$activeView = trim((string) ($_GET['view'] ?? 'overview'));
$sectionKeys = array_values(array_filter(array_map(
@@ -77,7 +83,7 @@ $sectionsJson = json_encode($sections, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_S
padding: 18px;
}
</style>
<link rel="stylesheet" href="/module-assets/index.php?module=mining-checker&amp;path=assets/css/app.css">
<link rel="stylesheet" href="/module-assets/index.php?module=mining-checker&amp;path=assets/css/app.css&amp;v=<?= htmlspecialchars($assetVersion('assets/css/app.css'), ENT_QUOTES) ?>">
</head>
<body data-module-debug-enabled="0">
<div class="mining-module-shell">
@@ -92,6 +98,6 @@ $sectionsJson = json_encode($sections, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_S
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<script src="/module-assets/index.php?module=mining-checker&amp;path=assets/js/app.js"></script>
<script src="/module-assets/index.php?module=mining-checker&amp;path=assets/js/app.js&amp;v=<?= htmlspecialchars($assetVersion('assets/js/app.js'), ENT_QUOTES) ?>"></script>
</body>
</html>