debug(library): ajouter console.log pour tracer init + loadTab + flatItems
Ajoute des logs dans init(), loadTab() et _recomputeFlatItems() pour identifier pourquoi flatItems reste vide malgré le chargement API. CSP: ajout fonts.googleapis.com/gstatic.com pour débloquer Google Fonts.
This commit is contained in:
@@ -65,9 +65,9 @@ class ContentSecurityPolicyMiddleware(BaseHTTPMiddleware):
|
||||
CSP_VALUE = (
|
||||
"default-src 'self'; "
|
||||
"script-src 'self' 'unsafe-inline' 'unsafe-eval'; "
|
||||
"style-src 'self' 'unsafe-inline'; "
|
||||
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; "
|
||||
"img-src 'self' data: blob: https:; "
|
||||
"font-src 'self' data:; "
|
||||
"font-src 'self' data: https://fonts.gstatic.com; "
|
||||
"connect-src 'self' https: wss:; "
|
||||
"media-src 'self' blob:; "
|
||||
"frame-src 'self'; "
|
||||
|
||||
@@ -420,18 +420,21 @@ function libraryPage() {
|
||||
|
||||
// ── Init ──
|
||||
init() {
|
||||
console.log('[Library] init start');
|
||||
var wsEl = document.getElementById('lib-workspace-id');
|
||||
this.workspaceId = parseInt(wsEl ? wsEl.textContent : '0') || 0;
|
||||
var giteaEl = document.getElementById('lib-gitea-active');
|
||||
this.isGiteaActive = (giteaEl ? giteaEl.textContent : '0') === '1';
|
||||
this.giteaOwner = (document.getElementById('lib-gitea-owner') || {}).textContent || '';
|
||||
this.giteaRepo = (document.getElementById('lib-gitea-repo') || {}).textContent || '';
|
||||
console.log('[Library] workspaceId=' + this.workspaceId + ' isGitea=' + this.isGiteaActive);
|
||||
var params = new URLSearchParams(window.location.search);
|
||||
var t = params.get('tab');
|
||||
if (t && ['recents','favorites','shared','published','private','workspace','repository'].indexOf(t) !== -1) {
|
||||
this.tab = t;
|
||||
}
|
||||
this._recomputeEmpty();
|
||||
console.log('[Library] loading tab: ' + this.tab);
|
||||
this.loadTab();
|
||||
},
|
||||
|
||||
@@ -461,6 +464,7 @@ function libraryPage() {
|
||||
// ── Load ──
|
||||
async loadTab() {
|
||||
this.loading = true;
|
||||
console.log('[Library] loadTab: ' + this.tab + ' workspaceId=' + this.workspaceId);
|
||||
try {
|
||||
var url = '/api/library/' + this.tab;
|
||||
var sep = '?';
|
||||
@@ -471,13 +475,16 @@ function libraryPage() {
|
||||
url += sep + 'gitea_owner=' + encodeURIComponent(this.giteaOwner) + '&gitea_repo=' + encodeURIComponent(this.giteaRepo);
|
||||
sep = '&';
|
||||
}
|
||||
console.log('[Library] fetching: ' + url);
|
||||
var r = await fetch(url);
|
||||
var d = await r.json();
|
||||
this.items = d.items || [];
|
||||
console.log('[Library] loaded ' + this.items.length + ' items');
|
||||
this._markTree(this.items, 0);
|
||||
this._recomputeFlatItems();
|
||||
console.log('[Library] flatItems after recompute: ' + this.flatItems.length);
|
||||
} catch(e) {
|
||||
console.error('Library load:', e);
|
||||
console.error('[Library] load error:', e);
|
||||
this.items = [];
|
||||
}
|
||||
this.loading = false;
|
||||
|
||||
Reference in New Issue
Block a user