asdasd
This commit is contained in:
@@ -1,32 +1,33 @@
|
||||
(function () {
|
||||
const root = document.getElementById('mining-checker-app');
|
||||
if (!root || !window.React || !window.ReactDOM) {
|
||||
return;
|
||||
}
|
||||
function boot(root) {
|
||||
if (!root || !window.React || !window.ReactDOM) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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 configuredSections = (() => {
|
||||
try {
|
||||
const parsed = JSON.parse(root.dataset.sectionsJson || '[]');
|
||||
if (!Array.isArray(parsed)) {
|
||||
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 configuredSections = (() => {
|
||||
try {
|
||||
const parsed = JSON.parse(root.dataset.sectionsJson || '[]');
|
||||
if (!Array.isArray(parsed)) {
|
||||
return [];
|
||||
}
|
||||
return parsed
|
||||
.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);
|
||||
} catch (error) {
|
||||
return [];
|
||||
}
|
||||
return parsed
|
||||
.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);
|
||||
} catch (error) {
|
||||
return [];
|
||||
}
|
||||
})();
|
||||
const initialDebugMode = document.body && document.body.dataset.moduleDebugEnabled === '1';
|
||||
})();
|
||||
const initialDebugMode = root.dataset.moduleDebugEnabled === '1'
|
||||
|| (document.body && document.body.dataset.moduleDebugEnabled === '1');
|
||||
function getCookie(name) {
|
||||
const pattern = `; ${document.cookie}`;
|
||||
const parts = pattern.split(`; ${name}=`);
|
||||
@@ -3184,5 +3185,47 @@
|
||||
}
|
||||
}
|
||||
|
||||
ReactDOM.createRoot(root).render(h(App));
|
||||
ReactDOM.createRoot(root).render(h(App));
|
||||
return true;
|
||||
}
|
||||
|
||||
window.initMiningCheckerApp = function initMiningCheckerApp(root, options) {
|
||||
if (!(root instanceof HTMLElement)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const config = options && typeof options === 'object' ? options : {};
|
||||
|
||||
if (config.apiBase) {
|
||||
root.dataset.apiBase = String(config.apiBase);
|
||||
}
|
||||
if (config.defaultProjectKey) {
|
||||
root.dataset.defaultProjectKey = String(config.defaultProjectKey);
|
||||
}
|
||||
if (config.activeView) {
|
||||
root.dataset.activeView = String(config.activeView);
|
||||
}
|
||||
if (config.sections) {
|
||||
root.dataset.sectionsJson = JSON.stringify(config.sections);
|
||||
}
|
||||
if (config.moduleDebugEnabled !== undefined) {
|
||||
root.dataset.moduleDebugEnabled = config.moduleDebugEnabled ? '1' : '0';
|
||||
}
|
||||
|
||||
if (root.dataset.miningCheckerMounted === '1') {
|
||||
return true;
|
||||
}
|
||||
|
||||
const mounted = boot(root);
|
||||
if (mounted) {
|
||||
root.dataset.miningCheckerMounted = '1';
|
||||
}
|
||||
|
||||
return mounted;
|
||||
};
|
||||
|
||||
const root = document.getElementById('mining-checker-app');
|
||||
if (root) {
|
||||
window.initMiningCheckerApp(root);
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user