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:
parent
6d98fc90eb
commit
31c53cd8d5
@ -7,7 +7,7 @@
|
|||||||
<title>BuhApp</title>
|
<title>BuhApp</title>
|
||||||
<script src="https://telegram.org/js/telegram-web-app.js"></script>
|
<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">
|
<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">
|
<link rel="stylesheet" href="/css/app.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@ -160,4 +160,17 @@ const ReviewApi = {
|
|||||||
async stats(userId) { return api('/api/v1/users/' + userId + '/stats'); },
|
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 };
|
||||||
@ -75,12 +75,17 @@ const App = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async checkConsent() {
|
async checkConsent() {
|
||||||
// показываем согласия при первом входе
|
// проверяем на бэкенде — если все 4 уже приняты, не показываем
|
||||||
if (API.Store.user && !API.Store.user.consents_given) {
|
try {
|
||||||
|
const s = await API.ConsentApi.status();
|
||||||
|
if (s.all_accepted) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('consent status check failed', e);
|
||||||
|
}
|
||||||
this.showConsent();
|
this.showConsent();
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
showConsent() {
|
showConsent() {
|
||||||
|
|||||||
@ -39,7 +39,7 @@ const MapView = {
|
|||||||
|
|
||||||
if (!this.map) {
|
if (!this.map) {
|
||||||
this.map = L.map('map').setView([55.7558, 37.6173], 12);
|
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',
|
attribution: '© OpenStreetMap',
|
||||||
maxZoom: 19,
|
maxZoom: 19,
|
||||||
}).addTo(this.map);
|
}).addTo(this.map);
|
||||||
|
|||||||
6
public/vendor/leaflet.js
vendored
Normal file
6
public/vendor/leaflet.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user