Refactor HomepageService to remove caching and simplify pageData method; disable SSR in Inertia config; improve service worker registration in app.ts; fix URL parameters in Analysis.vue router call.
This commit is contained in:
parent
2e578cd976
commit
bb17bf6ad4
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,6 @@
|
||||
use App\Models\Category;
|
||||
use App\Models\Product;
|
||||
use App\Models\SystemConfiguration;
|
||||
use App\Services\Concerns\CachesQuery;
|
||||
use App\Services\Manage\CuttingResultPriceResolver;
|
||||
use App\Services\System\Setting\HomepageSettingService;
|
||||
use App\Settings\SocialMediaSettings;
|
||||
@ -15,8 +14,6 @@
|
||||
|
||||
class HomepageService
|
||||
{
|
||||
use CachesQuery;
|
||||
|
||||
public function __construct(
|
||||
private readonly CuttingResultPriceResolver $cuttingResultPriceResolver,
|
||||
private readonly HomepageSettingService $homepageSettingService,
|
||||
@ -24,32 +21,30 @@ public function __construct(
|
||||
|
||||
public function pageData(): array
|
||||
{
|
||||
return $this->cacheRemember('homepage:page_data', 900, function () {
|
||||
$categories = Category::getActiveWithProducts();
|
||||
$products = $this->getProducts();
|
||||
$categories = Category::getActiveWithProducts();
|
||||
$products = $this->getProducts();
|
||||
|
||||
$configuration = SystemConfiguration::instance();
|
||||
$logo = MediaPresenter::first($configuration, 'logo');
|
||||
$logoUrl = $logo['url'] ?? null;
|
||||
$configuration = SystemConfiguration::instance();
|
||||
$logo = MediaPresenter::first($configuration, 'logo');
|
||||
$logoUrl = $logo['url'] ?? null;
|
||||
|
||||
$settings = app(SystemSettings::class);
|
||||
$socialSettings = app(SocialMediaSettings::class);
|
||||
$settings = app(SystemSettings::class);
|
||||
$socialSettings = app(SocialMediaSettings::class);
|
||||
|
||||
return [
|
||||
'categories' => $categories,
|
||||
'products' => $products,
|
||||
'appName' => $settings->app_name ?? 'DST Collection',
|
||||
'aboutApp' => $settings->about_app ?? '',
|
||||
'contactEmail' => $settings->email ?? '',
|
||||
'contactPhone' => $settings->phone ?? '',
|
||||
'contactAddress' => $settings->address ?? '',
|
||||
'logoUrl' => $logoUrl,
|
||||
'instagramUrl' => $socialSettings->instagram_url ?? null,
|
||||
'facebookUrl' => $socialSettings->facebook_url ?? null,
|
||||
'tiktokUrl' => $socialSettings->tiktok_url ?? null,
|
||||
'homepage' => $this->homepageSettingService->homepageData(),
|
||||
];
|
||||
});
|
||||
return [
|
||||
'categories' => $categories,
|
||||
'products' => $products,
|
||||
'appName' => $settings->app_name ?? 'DST Collection',
|
||||
'aboutApp' => $settings->about_app ?? '',
|
||||
'contactEmail' => $settings->email ?? '',
|
||||
'contactPhone' => $settings->phone ?? '',
|
||||
'contactAddress' => $settings->address ?? '',
|
||||
'logoUrl' => $logoUrl,
|
||||
'instagramUrl' => $socialSettings->instagram_url ?? null,
|
||||
'facebookUrl' => $socialSettings->facebook_url ?? null,
|
||||
'tiktokUrl' => $socialSettings->tiktok_url ?? null,
|
||||
'homepage' => $this->homepageSettingService->homepageData(),
|
||||
];
|
||||
}
|
||||
|
||||
private function getProducts(): array
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
'ssr' => [
|
||||
'enabled' => true,
|
||||
'enabled' => false,
|
||||
'url' => 'http://127.0.0.1:13714',
|
||||
// 'bundle' => base_path('bootstrap/ssr/ssr.mjs'),
|
||||
|
||||
|
||||
@ -5,24 +5,26 @@ import { Toaster } from '@/components/ui/sonner';
|
||||
import { useFlashToast } from '@/composables/useFlashToast';
|
||||
import { restoreConnection } from '@/lib/thermal-printer/stable-transport';
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker
|
||||
.register('/sw.js', { scope: '/' })
|
||||
.then((reg) => {
|
||||
console.log('[SW] Registered:', reg.scope);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('[SW] Registration failed:', err);
|
||||
});
|
||||
if (typeof window !== 'undefined') {
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker
|
||||
.register('/sw.js', { scope: '/' })
|
||||
.then((reg) => {
|
||||
console.log('[SW] Registered:', reg.scope);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('[SW] Registration failed:', err);
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('beforeinstallprompt', (e) => {
|
||||
e.preventDefault();
|
||||
(window as any).deferredPwaPrompt = e;
|
||||
});
|
||||
|
||||
void restoreConnection();
|
||||
}
|
||||
|
||||
window.addEventListener('beforeinstallprompt', (e) => {
|
||||
e.preventDefault();
|
||||
(window as any).deferredPwaPrompt = e;
|
||||
});
|
||||
|
||||
void restoreConnection();
|
||||
|
||||
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
|
||||
|
||||
createInertiaApp({
|
||||
|
||||
@ -529,11 +529,11 @@ const productBarData = computed<ProductData[]>(() => {
|
||||
|
||||
function applyFilters() {
|
||||
router.get(
|
||||
admin.analysis.url({
|
||||
admin.analysis.url(),
|
||||
{
|
||||
start_date: startDate.value,
|
||||
end_date: endDate.value,
|
||||
}),
|
||||
{},
|
||||
},
|
||||
{
|
||||
preserveState: true,
|
||||
preserveScroll: true,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user