Последняя версия с сервера прошлого разработчика

This commit is contained in:
2025-07-10 04:35:51 +00:00
commit c731570032
1174 changed files with 134314 additions and 0 deletions

108
nova/resources/js/router/index.js vendored Executable file
View File

@@ -0,0 +1,108 @@
import _ from 'lodash'
import Vue from 'vue'
import Router from 'vue-router'
import routes from './routes'
Vue.use(Router)
const router = createRouter({ base: window.config.base })
export default router
/**
* The router factory
*/
function createRouter({ base }) {
const router = new Router({
scrollBehavior,
base,
mode: 'history',
routes,
})
router.beforeEach(beforeEach)
router.afterEach(afterEach)
return router
}
/**
* Global router guard.
*
* @param {Route} to
* @param {Route} from
* @param {Function} next
*/
async function beforeEach(to, from, next) {
// Get the matched components and resolve them.
const components = await resolveComponents(
router.getMatchedComponents({ ...to })
)
if (components.length === 0) {
return next()
}
// Start the loading bar.
if (components[components.length - 1].loading !== false) {
router.app.$nextTick(() => router.app.$loading.start())
}
next()
}
/**
* Global after hook.
*
* @param {Route} to
* @param {Route} from
* @param {Function} next
*/
async function afterEach(to, from, next) {
await router.app.$nextTick()
router.app.$loading.finish()
}
/**
* Resolve async components.
*
* @param {Array} components
* @return {Array}
*/
function resolveComponents(components) {
return Promise.all(
components.map(component => {
return typeof component === 'function' ? component() : component
})
)
}
/**
* Scroll Behavior
*
* @link https://router.vuejs.org/en/advanced/scroll-behavior.html
*
* @param {Route} to
* @param {Route} from
* @param {Object|undefined} savedPosition
* @return {Object}
*/
function scrollBehavior(to, from, savedPosition) {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (savedPosition) {
return resolve(savedPosition)
}
if (from.name !== to.name) {
return resolve({ x: 0, y: 0 })
}
if (from.params.resourceName !== to.params.resourceName) {
return resolve({ x: 0, y: 0 })
}
return resolve({})
}, 250)
})
}

121
nova/resources/js/router/routes.js vendored Executable file
View File

@@ -0,0 +1,121 @@
import Dashboard from '@/views/Dashboard'
import ResourceIndex from '@/views/Index'
import ResourceDetail from '@/views/Detail'
import CreateResource from '@/views/Create'
import UpdateResource from '@/views/Update'
import AttachResource from '@/views/Attach'
import UpdateAttachedResource from '@/views/UpdateAttached'
import Lens from '@/views/Lens'
import Error403 from '@/views/403'
import Error404 from '@/views/404'
export default [
{
name: 'dashboard',
path: '/',
redirect: '/dashboards/main',
},
{
name: 'dashboard.custom',
path: '/dashboards/:name',
component: Dashboard,
props: true,
},
{
name: 'action-events.edit',
path: '/resources/action-events/:id/edit',
redirect: {
name: '404',
},
},
{
name: 'index',
path: '/resources/:resourceName',
component: ResourceIndex,
props: true,
},
{
name: 'lens',
path: '/resources/:resourceName/lens/:lens',
component: Lens,
props: true,
},
{
name: 'create',
path: '/resources/:resourceName/new',
component: CreateResource,
props: route => {
return {
resourceName: route.params.resourceName,
viaResource: route.query.viaResource || '',
viaResourceId: route.query.viaResourceId || '',
viaRelationship: route.query.viaRelationship || '',
}
},
},
{
name: 'edit',
path: '/resources/:resourceName/:resourceId/edit',
component: UpdateResource,
props: route => {
return {
resourceName: route.params.resourceName,
resourceId: route.params.resourceId,
viaResource: route.query.viaResource || '',
viaResourceId: route.query.viaResourceId || '',
viaRelationship: route.query.viaRelationship || '',
}
},
},
{
name: 'attach',
path: '/resources/:resourceName/:resourceId/attach/:relatedResourceName',
component: AttachResource,
props: route => {
return {
resourceName: route.params.resourceName,
resourceId: route.params.resourceId,
relatedResourceName: route.params.relatedResourceName,
viaRelationship: route.query.viaRelationship,
polymorphic: route.query.polymorphic == '1',
}
},
},
{
name: 'edit-attached',
path:
'/resources/:resourceName/:resourceId/edit-attached/:relatedResourceName/:relatedResourceId',
component: UpdateAttachedResource,
props: route => {
return {
resourceName: route.params.resourceName,
resourceId: route.params.resourceId,
relatedResourceName: route.params.relatedResourceName,
relatedResourceId: route.params.relatedResourceId,
viaRelationship: route.query.viaRelationship,
viaPivotId: route.query.viaPivotId,
}
},
},
{
name: 'detail',
path: '/resources/:resourceName/:resourceId',
component: ResourceDetail,
props: true,
},
{
name: '403',
path: '/403',
component: Error403,
},
{
name: '404',
path: '/404',
component: Error404,
},
{
name: 'catch-all',
path: '*',
component: Error404,
},
]