Files
vServer/Backend/admin/frontend/assets/js/utils/helpers.js
Falknat 02ae56b78c Большое обновление GUI интерфейс
Большое обновление GUI интерфейс

- Добавлен фраемворr Walles
- Удалена консольная версия
- Проработан интерфейс и дизайн
- Добавлено кеширование для быстрой реакции.
- Сделан .ps1 сборщик для удобной сборки проекта.
- Обновлён Readme
2025-11-14 08:40:25 +07:00

58 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* ============================================
Helper Utilities
Вспомогательные функции
============================================ */
/**
* Ждёт указанное время
* @param {number} ms - Миллисекунды
* @returns {Promise}
*/
export function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
/**
* Debounce функция
* @param {Function} func - Функция для debounce
* @param {number} wait - Время задержки
* @returns {Function}
*/
export function debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
/**
* Проверяет доступность Wails API
* @returns {boolean}
*/
export function isWailsAvailable() {
return typeof window.go !== 'undefined' &&
window.go?.admin?.App !== undefined;
}
/**
* Логирование с префиксом
* @param {string} message - Сообщение
* @param {string} type - Тип (log, error, warn, info)
*/
export function log(message, type = 'log') {
const prefix = '🚀 vServer:';
const styles = {
log: '✅',
error: '❌',
warn: '⚠️',
info: ''
};
console[type](`${prefix} ${styles[type]} ${message}`);
}