changes
This commit is contained in:
@@ -14,11 +14,11 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true, // Сделаем title обязательным
|
required: true,
|
||||||
},
|
},
|
||||||
link: {
|
link: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true, // Сделаем link обязательным
|
required: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -28,10 +28,20 @@ export default {
|
|||||||
new URL(this.link);
|
new URL(this.link);
|
||||||
return this.link; // Если это валидный URL, возвращаем его
|
return this.link; // Если это валидный URL, возвращаем его
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Если это не валидный URL, предполагаем, что это название роута Inertia
|
// Если это не валидный URL, предполагаем, что это название роута
|
||||||
// Убедитесь, что функция route() доступна глобально или импортирована
|
// Используем this.route() который доступен через ZiggyVue mixin
|
||||||
// (обычно она доступна в Laravel-приложениях через Inertia)
|
if (typeof this.route === 'function') {
|
||||||
return route(this.link);
|
try {
|
||||||
|
return this.route(this.link);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Route function failed:', err);
|
||||||
|
return '#';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback: возвращаем ссылку как есть или хэш
|
||||||
|
console.warn('route() function is not available');
|
||||||
|
return '#';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import createServer from '@inertiajs/vue3/server'
|
|||||||
import { renderToString } from '@vue/server-renderer'
|
import { renderToString } from '@vue/server-renderer'
|
||||||
import { createSSRApp, h } from 'vue'
|
import { createSSRApp, h } from 'vue'
|
||||||
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';
|
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';
|
||||||
|
import { default as Router } from '../../vendor/tightenco/ziggy/dist/index.m.js';
|
||||||
|
|
||||||
createServer(page =>
|
createServer(page =>
|
||||||
createInertiaApp({
|
createInertiaApp({
|
||||||
@@ -32,6 +33,19 @@ createServer(page =>
|
|||||||
ziggyConfig.location = new URL(process.env.APP_URL || 'http://localhost');
|
ziggyConfig.location = new URL(process.env.APP_URL || 'http://localhost');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Создаем функцию route с правильной конфигурацией
|
||||||
|
const route = (name, params, absolute, config) => {
|
||||||
|
const ziggyConfigForRoute = {
|
||||||
|
...page.props.ziggy,
|
||||||
|
location: ziggyConfig.location,
|
||||||
|
};
|
||||||
|
const router = new Router(name, params, absolute, ziggyConfigForRoute);
|
||||||
|
return router.toString();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Делаем route доступным глобально
|
||||||
|
ssrApp.config.globalProperties.route = route;
|
||||||
|
|
||||||
return ssrApp
|
return ssrApp
|
||||||
.use(plugin)
|
.use(plugin)
|
||||||
.use(ZiggyVue, ziggyConfig);
|
.use(ZiggyVue, ziggyConfig);
|
||||||
|
|||||||
Reference in New Issue
Block a user