mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-09-27 20:11:15 +02:00
refactor: topbar.js name and order. And remove 'customconfiguration' declaration in index.html
This commit is contained in:
@@ -56,9 +56,9 @@
|
|||||||
<div class="setting-item" id="theme" style="margin-left: 32px;">
|
<div class="setting-item" id="theme" style="margin-left: 32px;">
|
||||||
<div class="setting-info">
|
<div class="setting-info">
|
||||||
<div style="display: flex; align-items: center; gap: 10px;">
|
<div style="display: flex; align-items: center; gap: 10px;">
|
||||||
<span class="setting-title">Thème</span>
|
<span class="setting-title">Theme</span>
|
||||||
|
|
||||||
<select id="themeSelect" data-key="theme" aria-label="Choisir le thème">
|
<select id="themeSelect" data-key="theme" aria-label="Choose the theme">
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
<button id="refresh-themes-btn" title="Refresh themes" class="refresh-themes-btn">
|
<button id="refresh-themes-btn" title="Refresh themes" class="refresh-themes-btn">
|
||||||
@@ -306,7 +306,6 @@
|
|||||||
|
|
||||||
<!-- Scripts -->
|
<!-- Scripts -->
|
||||||
<script src="script/toast.js"></script>
|
<script src="script/toast.js"></script>
|
||||||
<script src="script/customConfiguration.js"></script>
|
|
||||||
<script src="script/clipboardPaste.js"></script>
|
<script src="script/clipboardPaste.js"></script>
|
||||||
<script src="script/custompath.js"></script>
|
<script src="script/custompath.js"></script>
|
||||||
<script src="script/settingsPanel.js"></script>
|
<script src="script/settingsPanel.js"></script>
|
||||||
|
|||||||
@@ -5,53 +5,55 @@
|
|||||||
* This function is safe to call once DOM is ready.
|
* This function is safe to call once DOM is ready.
|
||||||
* It silently aborts if the API or elements are missing.
|
* It silently aborts if the API or elements are missing.
|
||||||
*/
|
*/
|
||||||
function setupTopbarListeners() {
|
export function initTopBar() {
|
||||||
const { topbarAPI } = window;
|
const { topbarAPI } = window;
|
||||||
if (!topbarAPI) return;
|
if (!topbarAPI) return;
|
||||||
|
|
||||||
const minBtn = document.getElementById("minimize-btn");
|
const minBtn = document.getElementById("minimize-btn");
|
||||||
const maxBtn = document.getElementById("maximize-btn");
|
|
||||||
const closeBtn = document.getElementById("close-btn");
|
|
||||||
const devtoolsBtn = document.getElementById("devtools-btn");
|
|
||||||
const logsBtn = document.getElementById("logs-btn");
|
|
||||||
const websiteBtn = document.getElementById("website-btn");
|
|
||||||
const wikiBtn = document.getElementById("wiki-btn");
|
|
||||||
const workshopBtn = document.getElementById("workshop-btn");
|
|
||||||
|
|
||||||
if (minBtn) minBtn.onclick = () => topbarAPI.minimize();
|
if (minBtn) minBtn.onclick = () => topbarAPI.minimize();
|
||||||
|
|
||||||
|
const maxBtn = document.getElementById("maximize-btn");
|
||||||
if (maxBtn) maxBtn.onclick = () => topbarAPI.maximize();
|
if (maxBtn) maxBtn.onclick = () => topbarAPI.maximize();
|
||||||
|
|
||||||
|
const closeBtn = document.getElementById("close-btn");
|
||||||
if (closeBtn) closeBtn.onclick = () => topbarAPI.close();
|
if (closeBtn) closeBtn.onclick = () => topbarAPI.close();
|
||||||
|
|
||||||
|
const devtoolsBtn = document.getElementById("devtools-btn");
|
||||||
if (devtoolsBtn) devtoolsBtn.onclick = () => topbarAPI.openDevTools();
|
if (devtoolsBtn) devtoolsBtn.onclick = () => topbarAPI.openDevTools();
|
||||||
|
|
||||||
|
const logsBtn = document.getElementById("logs-btn");
|
||||||
if (logsBtn) logsBtn.onclick = () => topbarAPI.openLogs();
|
if (logsBtn) logsBtn.onclick = () => topbarAPI.openLogs();
|
||||||
|
|
||||||
|
const websiteBtn = document.getElementById("website-btn");
|
||||||
if (websiteBtn) websiteBtn.onclick = () => topbarAPI.openWebsite();
|
if (websiteBtn) websiteBtn.onclick = () => topbarAPI.openWebsite();
|
||||||
|
|
||||||
|
const wikiBtn = document.getElementById("wiki-btn");
|
||||||
if (wikiBtn) wikiBtn.onclick = () => topbarAPI.openWiki();
|
if (wikiBtn) wikiBtn.onclick = () => topbarAPI.openWiki();
|
||||||
|
|
||||||
|
const workshopBtn = document.getElementById("workshop-btn");
|
||||||
if (workshopBtn) workshopBtn.onclick = () => topbarAPI.openWorkshop();
|
if (workshopBtn) workshopBtn.onclick = () => topbarAPI.openWorkshop();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
async function attachListeners(){
|
||||||
* Registers topbar event listeners after DOM is fully loaded.
|
try{
|
||||||
*/
|
const featuresList = await window.electronAPI.getFeatures();
|
||||||
document.addEventListener("DOMContentLoaded", setupTopbarListeners);
|
|
||||||
|
|
||||||
/**
|
if (!featuresList.customTopBar) {
|
||||||
* Applies UI layout adjustments depending on feature flags
|
const topbar = document.getElementById("topbar");
|
||||||
* provided by the Electron backend.
|
const container = document.getElementById("container");
|
||||||
*
|
const themeSwitcher = document.getElementById("theme-switcher");
|
||||||
* Specifically handles:
|
|
||||||
* - hiding custom topbar
|
|
||||||
* - adjusting layout spacing
|
|
||||||
* - repositioning theme switcher
|
|
||||||
*/
|
|
||||||
(async function applyFeatureLayout() {
|
|
||||||
const features = await window.electronAPI.getFeatures();
|
|
||||||
|
|
||||||
if (!features.customTopBar) {
|
if (topbar) topbar.style.display = "none";
|
||||||
const topbar = document.getElementById("topbar");
|
if (container) container.style.marginTop = "0";
|
||||||
const container = document.getElementById("container");
|
if (themeSwitcher) themeSwitcher.style.top = "30px";
|
||||||
const themeSwitcher = document.getElementById("theme-switcher");
|
}
|
||||||
|
|
||||||
if (topbar) topbar.style.display = "none";
|
} catch (error) {
|
||||||
if (container) container.style.marginTop = "0";
|
console.error("Failed to load layout features for topbar:", error);
|
||||||
if (themeSwitcher) themeSwitcher.style.top = "30px";
|
|
||||||
}
|
}
|
||||||
})();
|
|
||||||
|
}
|
||||||
|
|
||||||
|
initTopBar()
|
||||||
|
document.addEventListener("DOMContentLoaded", attachListeners)
|
||||||
Reference in New Issue
Block a user