diff --git a/src-electron/electron-preload.ts b/src-electron/electron-preload.ts index 012ce53..caec32b 100644 --- a/src-electron/electron-preload.ts +++ b/src-electron/electron-preload.ts @@ -123,6 +123,9 @@ const executionEngineAPI = { async stopListeningForStatistics (callback: (_e: IpcRendererEvent, data: ModuleExecutionStatisticsEventData) => void): Promise { await ipcRenderer.invoke('executionEngine:stopListeningForStatistics') ipcRenderer.off('executionEngine:statistics', callback) + }, + async deleteStatistics (): Promise { + return await ipcRenderer.invoke('executionEngine:deleteStatistics') } } diff --git a/src-electron/handlers/engine.ts b/src-electron/handlers/engine.ts index ecd79fc..87700df 100644 --- a/src-electron/handlers/engine.ts +++ b/src-electron/handlers/engine.ts @@ -290,6 +290,13 @@ export class ExecutionEngine { this.statisticsListeners.splice(index, 1) } } + + public async deleteStatistics() { + const config = await this.getState() + config.statistics = [] + config.statisticsTotals.totalBytesSent = 0 + await this.setState(config) + } } export function handleExecutionEngine(modules: Array): ExecutionEngine { @@ -344,6 +351,10 @@ export function handleExecutionEngine(modules: Array { engine.stopListeningForStatistics(e.sender) }) + ipcMain.handle('executionEngine:deleteStatistics', async () => { + await engine.deleteStatistics() + }) + void engine.init() diff --git a/src/i18n/en-US/index.ts b/src/i18n/en-US/index.ts index 5e6bc5b..dd6a10e 100644 --- a/src/i18n/en-US/index.ts +++ b/src/i18n/en-US/index.ts @@ -172,10 +172,12 @@ export default { idDescription: "How to get ID ? Look on", data: "Storage", dataDescription: "Currently your modules are located in the folder:", + warnDelStatistics: "Are you sure you want to delete the statistics?", warnDelCache: "Are you sure you want to delete the modules cache? The app will close after this action and may not restart automatically.", warnDelData: "Do you really want to delete all data, including cache, settings, and modules? The app will close after this action and may not restart automatically.", openDataFolder: "Open Data Folder", changeModulesDataLocation: "Change Modules Data Location", + deleteStatistics: "Delete Statistics", deleteModulesCache: "Delete Modules Cache", deleteAllTheData: "Factory Settings", diff --git a/src/i18n/ua-UA/index.ts b/src/i18n/ua-UA/index.ts index 0d35c85..a78a90f 100644 --- a/src/i18n/ua-UA/index.ts +++ b/src/i18n/ua-UA/index.ts @@ -173,10 +173,12 @@ export default { idDescription: "Де взяти ID ? Загляньте до", data: "Сховище", dataDescription: "Наразі ваші модулі знаходяться в папці:", + warnDelStatistics: "Ви справді хочете видалити всю статистику?", warnDelCache: "Ви справді хочете видалити кеш модулів? Програма закриється після цієї дії та може не перезапуститися автоматично.", warnDelData: "Ви справді бажаєте видалити всі дані, включаючи кеш налаштувань і модулів? Програма закриється після цієї дії та може не перезапуститися автоматично.", openDataFolder: "Відкрити папку з даними", changeModulesDataLocation: "Змінити розташування даних модулів", + deleteStatistics: "Видалити статистику", deleteModulesCache: "Видалити кеш модулів", deleteAllTheData: "Заводські налаштування", diff --git a/src/layouts/snowEffect/SnowEffectComponent.vue b/src/layouts/snowEffect/SnowEffectComponent.vue index d1f3721..e4a5349 100644 --- a/src/layouts/snowEffect/SnowEffectComponent.vue +++ b/src/layouts/snowEffect/SnowEffectComponent.vue @@ -23,7 +23,7 @@ let bodyHeightPx = null; let pageHeightVh = null; function setHeightVariables() { - bodyHeightPx = document.body.offsetHeight - 70; + bodyHeightPx = document.body.offsetHeight - 100; pageHeightVh = (100 * bodyHeightPx) / window.innerHeight; } @@ -92,7 +92,7 @@ function generateSnowCSS(snowDensity = 200) { let rule = baseCSS; for (let i = 1; i < snowDensity; i++) { - let randomX = Math.random() * 70; // vw + let randomX = Math.random() * 60; // vw let randomOffset = Math.random() * 10; // vw; let randomXEnd = randomX + randomOffset; let randomXEndYoyo = randomX + randomOffset / 2; diff --git a/src/layouts/snowEffect/pure-snow.js b/src/layouts/snowEffect/pure-snow.js deleted file mode 100644 index 960d242..0000000 --- a/src/layouts/snowEffect/pure-snow.js +++ /dev/null @@ -1,139 +0,0 @@ -let snowflakesCount = 20; // Snowflake count, can be overwritten by attrs -let baseCSS = ` -.snowflake { - position: absolute; - width: 10px; - height: 10px; - background: white; - border-radius: 50%; - filter: drop-shadow(0 0 10px white); -} -`; - -let bodyHeightPx = null; -let pageHeightVh = null; - -function setHeightVariables() { - bodyHeightPx = document.body.offsetHeight; - pageHeightVh = (100 * bodyHeightPx / window.innerHeight); -} - -// get params set in snow div -function getSnowAttributes() { - const snowWrapper = document.getElementById('snow'); - snowflakesCount = Number( - snowWrapper?.dataset?.count || snowflakesCount - ); -} - -// This function allows you to turn on and off the snow -function showSnow(value) { - if (value) { - document.getElementById('snow').style.display = "block"; - } - else { - document.getElementById('snow').style.display = "none"; - } -} - -// Creating snowflakes -function generateSnow(snowDensity = 200) { - snowDensity -= 1; - const snowWrapper = document.getElementById('snow'); - snowWrapper.innerHTML = ''; - for (let i = 0; i < snowDensity; i++) { - let board = document.createElement('div'); - board.className = "snowflake"; - snowWrapper.appendChild(board); - } -} - -function getOrCreateCSSElement() { - let cssElement = document.getElementById("psjs-css"); - if (cssElement) return cssElement; - - cssElement = document.createElement('style'); - cssElement.id = 'psjs-css'; - document.head.appendChild(cssElement); - return cssElement; -} - -// Append style for each snowflake to the head -function addCSS(rule) { - const cssElement = getOrCreateCSSElement(); - cssElement.innerHTML = rule; // safe to use innerHTML - document.head.appendChild(cssElement); -} - -// Math -function randomInt(value = 100) { - return Math.floor(Math.random() * value) + 1; -} - -function randomIntRange(min, max) { - min = Math.ceil(min); - max = Math.floor(max); - return Math.floor(Math.random() * (max - min + 1)) + min; -} - -function getRandomArbitrary(min, max) { - return Math.random() * (max - min) + min; -} - -// Create style for snowflake -function generateSnowCSS(snowDensity = 200) { - let snowflakeName = "snowflake"; - let rule = baseCSS; - - for (let i = 1; i < snowDensity; i++) { - let randomX = Math.random() * 100; // vw - let randomOffset = Math.random() * 10 // vw; - let randomXEnd = randomX + randomOffset; - let randomXEndYoyo = randomX + (randomOffset / 2); - let randomYoyoTime = getRandomArbitrary(0.3, 0.8); - let randomYoyoY = randomYoyoTime * pageHeightVh; // vh - let randomScale = Math.random(); - let fallDuration = randomIntRange(10, pageHeightVh / 10 * 3); // s - let fallDelay = randomInt(pageHeightVh / 10 * 3) * -1; // s - let opacity = Math.random(); - - rule += ` - .${snowflakeName}:nth-child(${i}) { - opacity: ${opacity}; - transform: translate(${randomX}vw, -10px) scale(${randomScale}); - animation: fall-${i} ${fallDuration}s ${fallDelay}s linear infinite; - } - @keyframes fall-${i} { - ${randomYoyoTime * 100}% { - transform: translate(${randomXEnd}vw, ${randomYoyoY}vh) scale(${randomScale}); - } - to { - transform: translate(${randomXEndYoyo}vw, ${pageHeightVh}vh) scale(${randomScale}); - } - } - ` - } - addCSS(rule); -} - -// Load the rules and execute after the DOM loads -function createSnow() { - setHeightVariables(); - getSnowAttributes(); - generateSnowCSS(snowflakesCount); - generateSnow(snowflakesCount); -}; - - -window.addEventListener('resize', createSnow); - -// export createSnow function if using node or CommonJS environment -if (typeof module !== 'undefined') { - module.exports = { - createSnow, - showSnow, - }; -} -else { - window.onload = createSnow; -} \ No newline at end of file diff --git a/src/pages/SettingsPage.vue b/src/pages/SettingsPage.vue index 96849b8..af847e0 100644 --- a/src/pages/SettingsPage.vue +++ b/src/pages/SettingsPage.vue @@ -1,52 +1,82 @@