asdsd
This commit is contained in:
@@ -1,32 +1,53 @@
|
||||
(function () {
|
||||
const root = document.getElementById('mining-checker-app');
|
||||
if (!root || !window.React || !window.ReactDOM) {
|
||||
return;
|
||||
}
|
||||
window.initMiningCheckerApp = function initMiningCheckerApp(rootNode, options) {
|
||||
const root = rootNode || document.getElementById('mining-checker-app');
|
||||
if (!root || !window.React || !window.ReactDOM) {
|
||||
return;
|
||||
}
|
||||
|
||||
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)) {
|
||||
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 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)) {
|
||||
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 = normalizedOptions.moduleDebugEnabled === true
|
||||
|| (document.body && document.body.dataset.moduleDebugEnabled === '1');
|
||||
function getCookie(name) {
|
||||
const pattern = `; ${document.cookie}`;
|
||||
const parts = pattern.split(`; ${name}=`);
|
||||
@@ -3263,5 +3284,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
ReactDOM.createRoot(root).render(h(App));
|
||||
ReactDOM.createRoot(root).render(h(App));
|
||||
};
|
||||
|
||||
const standaloneRoot = document.getElementById('mining-checker-app');
|
||||
if (standaloneRoot) {
|
||||
window.initMiningCheckerApp(standaloneRoot);
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user