|
|
@@ -2,10 +2,10 @@ import { ReviewPage, reviewOverview } from '../../core/review-page';
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
import { ChangeDetectionStrategy, Component, computed, inject, OnDestroy, OnInit, signal } from '@angular/core';
|
|
|
import { Router, RouterLink } from '@angular/router';
|
|
|
-import { AlertCircle, BarChart3, BookOpen, CalendarDays, Check, ChevronRight, Clock3, Eye, EyeOff, GraduationCap, Headphones, Info, LucideAngularModule, RefreshCw, Search, Sparkles, UserRound, Zap } from 'lucide-angular';
|
|
|
+import { AlertCircle, BarChart3, BookMarked, BookOpen, CalendarDays, Check, ChevronRight, Clock3, Eye, EyeOff, GraduationCap, Info, LucideAngularModule, RefreshCw, Search, UserRound, Zap } from 'lucide-angular';
|
|
|
import { finalize } from 'rxjs';
|
|
|
import { antiForgetCompleted, antiForgetDate, buildAntiForgetView, findAntiForgetList } from '../../core/anti-forget';
|
|
|
-import { ApiError, ApiService } from '../../core/api.service';
|
|
|
+import { ApiService } from '../../core/api.service';
|
|
|
import { PlatformService } from '../../core/platform.service';
|
|
|
import { SessionService } from '../../core/session.service';
|
|
|
import { LiveDataRefreshService } from '../../core/live-data-refresh.service';
|
|
|
@@ -25,8 +25,6 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|
|
readonly stats = signal<Record<string, number>>({});
|
|
|
readonly statsLoading = signal(false);
|
|
|
readonly coachStatsError = signal('');
|
|
|
- readonly recommendations = signal<Item[]>([]);
|
|
|
- readonly recommendationError = signal('');
|
|
|
readonly commissionHidden = signal(true);
|
|
|
readonly antiForgetItems = signal<Item[]>([]);
|
|
|
readonly antiForgetLoading = signal(false);
|
|
|
@@ -42,7 +40,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|
|
return stateOrder(left) === 1 ? dateDifference : -dateDifference;
|
|
|
}));
|
|
|
readonly coachReviewSummary=computed(()=>this.reviewData()?.summary||{today:0,due:0,completed:0});
|
|
|
- readonly icons = { AlertCircle, BarChart3, BookOpen, CalendarDays, Check, ChevronRight, Clock3, Eye, EyeOff, GraduationCap, Headphones, Info, RefreshCw, Search, Sparkles, UserRound, Zap };
|
|
|
+ readonly icons = { AlertCircle, BarChart3, BookMarked, BookOpen, CalendarDays, Check, ChevronRight, Clock3, Eye, EyeOff, GraduationCap, Info, RefreshCw, Search, UserRound, Zap };
|
|
|
|
|
|
private readonly api = inject(ApiService);
|
|
|
private readonly router = inject(Router);
|
|
|
@@ -66,8 +64,6 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|
|
},
|
|
|
});
|
|
|
}
|
|
|
- if (this.isCoach()) return;
|
|
|
- this.loadRecommendations();
|
|
|
}
|
|
|
|
|
|
ngOnDestroy(): void {
|
|
|
@@ -79,23 +75,6 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|
|
if (uid) this.loadStats(uid);
|
|
|
}
|
|
|
|
|
|
- loadRecommendations(): void {
|
|
|
- this.recommendationError.set('');
|
|
|
- this.api.get<unknown>('product_list', { nodes: '15,16', hot: 1, cpage: 1, psize: 8 }).subscribe({
|
|
|
- next: ({ result }) => this.recommendations.set(this.toList(result)),
|
|
|
- error: (error: ApiError) => this.recommendationError.set(error.message),
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- openProduct(item: Item): void {
|
|
|
- const id = item['ID'] ?? item['id'] ?? item['GeneralID'];
|
|
|
- if (id) void this.router.navigate(['/pages/shop/shop_item'], { queryParams: { id } });
|
|
|
- }
|
|
|
-
|
|
|
- image(item: Item): string { return this.api.assetUrl(item['Thumbnails'] ?? item['Pic']); }
|
|
|
- name(item: Item): string { return String(item['Proname'] ?? item['Title'] ?? '学习内容'); }
|
|
|
- price(item: Item): string { return Number(item['LinPrice'] ?? item['Price'] ?? 0).toFixed(2); }
|
|
|
-
|
|
|
retryAntiForget(): void {
|
|
|
const uid = this.session.user()?.userId;
|
|
|
if (uid) this.loadAntiForget(uid);
|
|
|
@@ -189,11 +168,4 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|
|
return `${value('year')}-${value('month')}-${value('day')}`;
|
|
|
}
|
|
|
|
|
|
- private toList(value: unknown): Item[] {
|
|
|
- if (Array.isArray(value)) return value as Item[];
|
|
|
- if (value && typeof value === 'object') {
|
|
|
- for (const nested of Object.values(value)) if (Array.isArray(nested)) return nested as Item[];
|
|
|
- }
|
|
|
- return [];
|
|
|
- }
|
|
|
}
|