Fix: leaflet.js local, consent status check, OSM direct tile URL

- vendor/leaflet.js (no more CDN dependency for JS)
- direct tile.openstreetmap.org (was {s}.tile)
- backend GET /api/v1/auth/consents (check if all accepted)
- frontend ConsentApi.status() before showing overlay
- only show overlay once
This commit is contained in:
root 2026-08-20 18:43:19 +00:00
parent 6d98fc90eb
commit 31c53cd8d5
5 changed files with 32 additions and 8 deletions

View File

@ -7,7 +7,7 @@
<title>BuhApp</title>
<script src="https://telegram.org/js/telegram-web-app.js"></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script src="/vendor/leaflet.js"></script>
<link rel="stylesheet" href="/css/app.css">
</head>
<body>

View File

@ -160,4 +160,17 @@ const ReviewApi = {
async stats(userId) { return api('/api/v1/users/' + userId + '/stats'); },
};
window.API = { api, Auth, ChatApi, ReviewApi, Store };
const ConsentApi = {
async status() {
try {
return await api('/api/v1/auth/consents');
} catch (e) {
return { all_accepted: false, accepted: {} };
}
},
async accept(payload) {
return api('/api/v1/auth/consents', { method: 'POST', body: payload });
},
};
window.API = { api, Auth, ChatApi, ReviewApi, ConsentApi, Store };

View File

@ -75,12 +75,17 @@ const App = {
},
async checkConsent() {
// показываем согласия при первом входе
if (API.Store.user && !API.Store.user.consents_given) {
// проверяем на бэкенде — если все 4 уже приняты, не показываем
try {
const s = await API.ConsentApi.status();
if (s.all_accepted) {
return true;
}
} catch (e) {
console.warn('consent status check failed', e);
}
this.showConsent();
return false;
}
return true;
},
showConsent() {

View File

@ -39,7 +39,7 @@ const MapView = {
if (!this.map) {
this.map = L.map('map').setView([55.7558, 37.6173], 12);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap',
maxZoom: 19,
}).addTo(this.map);

6
public/vendor/leaflet.js vendored Normal file

File diff suppressed because one or more lines are too long