/
githubmirror
/
ChatGPT
Обзор
Документация
Войти
/
githubmirror
/
ChatGPT
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v2-dev
src-tauri/src/core/constant.rs
45 строк
1 KB
lencx
chore: window
15 июл 2024, 21:05
15 июл 2024, 21:05
ef74c4a
Код
Авторство
О чём код?
pub static TITLEBAR_HEIGHT: f64 = 28.0; pub static ASK_HEIGHT: f64 = 120.0; pub static WINDOW_SETTINGS: &str = "settings"; pub static INIT_SCRIPT: &str = r#" window.addEventListener('DOMContentLoaded', function() { function handleUrlChange() { const url = window.location.href; if (url !== 'about:blank') { console.log('URL changed:', url); window.__TAURI__.webviewWindow.WebviewWindow.getByLabel('titlebar').emit('navigation:change', { url }); } } function handleLinkClick(event) { const target = event.target; if (target.tagName === 'A' && target.target && target.target !== '_blank') { target.target = '_blank'; } } document.addEventListener('click', handleLinkClick, true); window.addEventListener('popstate', handleUrlChange); window.addEventListener('pushState', handleUrlChange); window.addEventListener('replaceState', handleUrlChange); const originalPushState = history.pushState; const originalReplaceState = history.replaceState; history.pushState = function() { originalPushState.apply(this, arguments); console.log('pushState called'); handleUrlChange(); }; history.replaceState = function() { originalReplaceState.apply(this, arguments); console.log('replaceState called'); handleUrlChange(); }; handleUrlChange(); }); "#;