🚀 مُصادَق: تحديث برمجي جديد 2026-05-03 01:26
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* مُصادَق — API Client with JWT Auth & Refresh Flow
|
* مُصادَق — API Client with JWT Auth & Refresh Flow
|
||||||
*/
|
*/
|
||||||
const API = {
|
window.API = {
|
||||||
baseUrl: '/Application/public/api.php',
|
baseUrl: '/Application/public/api.php',
|
||||||
accessToken: localStorage.getItem('access_token'),
|
accessToken: localStorage.getItem('access_token'),
|
||||||
|
|
||||||
|
|||||||
@@ -231,13 +231,13 @@
|
|||||||
const errorEl = document.getElementById('login-error');
|
const errorEl = document.getElementById('login-error');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await API.post('/auth/login', { email, password });
|
const result = await window.API.post('/auth/login', { email, password });
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
localStorage.setItem('access_token', result.data.access_token);
|
localStorage.setItem('access_token', result.data.access_token);
|
||||||
if (result.data.refresh_token) {
|
if (result.data.refresh_token) {
|
||||||
localStorage.setItem('refresh_token', result.data.refresh_token);
|
localStorage.setItem('refresh_token', result.data.refresh_token);
|
||||||
}
|
}
|
||||||
API.accessToken = result.data.access_token;
|
window.API.accessToken = result.data.access_token;
|
||||||
navigate();
|
navigate();
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -250,6 +250,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── AI Query Handler ─────────────────────────────────────
|
||||||
|
document.getElementById('ai-query').addEventListener('keydown', async (e) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
const query = e.target.value;
|
||||||
|
const answerEl = document.getElementById('ai-answer');
|
||||||
|
if (!query) return;
|
||||||
|
|
||||||
|
answerEl.textContent = 'جاري التحليل...';
|
||||||
|
e.target.value = '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await window.API.post('/ai/query', { query });
|
||||||
|
answerEl.textContent = res.data.answer;
|
||||||
|
} catch (err) {
|
||||||
|
answerEl.textContent = 'عذراً، حدث خطأ أثناء معالجة طلبك.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// ── Start the app ────────────────────────────────────────
|
// ── Start the app ────────────────────────────────────────
|
||||||
navigate();
|
navigate();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user