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\Category;
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Models\SystemConfiguration;
|
use App\Models\SystemConfiguration;
|
||||||
use App\Services\Concerns\CachesQuery;
|
|
||||||
use App\Services\Manage\CuttingResultPriceResolver;
|
use App\Services\Manage\CuttingResultPriceResolver;
|
||||||
use App\Services\System\Setting\HomepageSettingService;
|
use App\Services\System\Setting\HomepageSettingService;
|
||||||
use App\Settings\SocialMediaSettings;
|
use App\Settings\SocialMediaSettings;
|
||||||
@ -15,8 +14,6 @@
|
|||||||
|
|
||||||
class HomepageService
|
class HomepageService
|
||||||
{
|
{
|
||||||
use CachesQuery;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly CuttingResultPriceResolver $cuttingResultPriceResolver,
|
private readonly CuttingResultPriceResolver $cuttingResultPriceResolver,
|
||||||
private readonly HomepageSettingService $homepageSettingService,
|
private readonly HomepageSettingService $homepageSettingService,
|
||||||
@ -24,32 +21,30 @@ public function __construct(
|
|||||||
|
|
||||||
public function pageData(): array
|
public function pageData(): array
|
||||||
{
|
{
|
||||||
return $this->cacheRemember('homepage:page_data', 900, function () {
|
$categories = Category::getActiveWithProducts();
|
||||||
$categories = Category::getActiveWithProducts();
|
$products = $this->getProducts();
|
||||||
$products = $this->getProducts();
|
|
||||||
|
|
||||||
$configuration = SystemConfiguration::instance();
|
$configuration = SystemConfiguration::instance();
|
||||||
$logo = MediaPresenter::first($configuration, 'logo');
|
$logo = MediaPresenter::first($configuration, 'logo');
|
||||||
$logoUrl = $logo['url'] ?? null;
|
$logoUrl = $logo['url'] ?? null;
|
||||||
|
|
||||||
$settings = app(SystemSettings::class);
|
$settings = app(SystemSettings::class);
|
||||||
$socialSettings = app(SocialMediaSettings::class);
|
$socialSettings = app(SocialMediaSettings::class);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'categories' => $categories,
|
'categories' => $categories,
|
||||||
'products' => $products,
|
'products' => $products,
|
||||||
'appName' => $settings->app_name ?? 'DST Collection',
|
'appName' => $settings->app_name ?? 'DST Collection',
|
||||||
'aboutApp' => $settings->about_app ?? '',
|
'aboutApp' => $settings->about_app ?? '',
|
||||||
'contactEmail' => $settings->email ?? '',
|
'contactEmail' => $settings->email ?? '',
|
||||||
'contactPhone' => $settings->phone ?? '',
|
'contactPhone' => $settings->phone ?? '',
|
||||||
'contactAddress' => $settings->address ?? '',
|
'contactAddress' => $settings->address ?? '',
|
||||||
'logoUrl' => $logoUrl,
|
'logoUrl' => $logoUrl,
|
||||||
'instagramUrl' => $socialSettings->instagram_url ?? null,
|
'instagramUrl' => $socialSettings->instagram_url ?? null,
|
||||||
'facebookUrl' => $socialSettings->facebook_url ?? null,
|
'facebookUrl' => $socialSettings->facebook_url ?? null,
|
||||||
'tiktokUrl' => $socialSettings->tiktok_url ?? null,
|
'tiktokUrl' => $socialSettings->tiktok_url ?? null,
|
||||||
'homepage' => $this->homepageSettingService->homepageData(),
|
'homepage' => $this->homepageSettingService->homepageData(),
|
||||||
];
|
];
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getProducts(): array
|
private function getProducts(): array
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
'ssr' => [
|
'ssr' => [
|
||||||
'enabled' => true,
|
'enabled' => false,
|
||||||
'url' => 'http://127.0.0.1:13714',
|
'url' => 'http://127.0.0.1:13714',
|
||||||
// 'bundle' => base_path('bootstrap/ssr/ssr.mjs'),
|
// 'bundle' => base_path('bootstrap/ssr/ssr.mjs'),
|
||||||
|
|
||||||
|
|||||||
@ -5,24 +5,26 @@ import { Toaster } from '@/components/ui/sonner';
|
|||||||
import { useFlashToast } from '@/composables/useFlashToast';
|
import { useFlashToast } from '@/composables/useFlashToast';
|
||||||
import { restoreConnection } from '@/lib/thermal-printer/stable-transport';
|
import { restoreConnection } from '@/lib/thermal-printer/stable-transport';
|
||||||
|
|
||||||
if ('serviceWorker' in navigator) {
|
if (typeof window !== 'undefined') {
|
||||||
navigator.serviceWorker
|
if ('serviceWorker' in navigator) {
|
||||||
.register('/sw.js', { scope: '/' })
|
navigator.serviceWorker
|
||||||
.then((reg) => {
|
.register('/sw.js', { scope: '/' })
|
||||||
console.log('[SW] Registered:', reg.scope);
|
.then((reg) => {
|
||||||
})
|
console.log('[SW] Registered:', reg.scope);
|
||||||
.catch((err) => {
|
})
|
||||||
console.error('[SW] Registration failed:', err);
|
.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';
|
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
|
||||||
|
|
||||||
createInertiaApp({
|
createInertiaApp({
|
||||||
|
|||||||
@ -529,11 +529,11 @@ const productBarData = computed<ProductData[]>(() => {
|
|||||||
|
|
||||||
function applyFilters() {
|
function applyFilters() {
|
||||||
router.get(
|
router.get(
|
||||||
admin.analysis.url({
|
admin.analysis.url(),
|
||||||
|
{
|
||||||
start_date: startDate.value,
|
start_date: startDate.value,
|
||||||
end_date: endDate.value,
|
end_date: endDate.value,
|
||||||
}),
|
},
|
||||||
{},
|
|
||||||
{
|
{
|
||||||
preserveState: true,
|
preserveState: true,
|
||||||
preserveScroll: true,
|
preserveScroll: true,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user