123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- import {createRouter, createWebHistory} from 'vue-router'
- import gettext from '../gettext'
- import {useUserStore} from '@/pinia'
- import {
- CloudOutlined,
- CodeOutlined,
- FileOutlined,
- HomeOutlined,
- InfoCircleOutlined,
- UserOutlined,
- FileTextOutlined,
- SettingOutlined,
- SafetyCertificateOutlined
- } from '@ant-design/icons-vue'
- const {$gettext} = gettext
- export const routes = [
- {
- path: '/',
- name: () => $gettext('Home'),
- component: () => import('@/layouts/BaseLayout.vue'),
- redirect: '/dashboard',
- children: [
- {
- path: 'dashboard',
- component: () => import('@/views/dashboard/DashBoard.vue'),
- name: () => $gettext('Dashboard'),
- meta: {
- // hiddenHeaderContent: true,
- icon: HomeOutlined
- }
- },
- {
- path: 'user',
- name: () => $gettext('Manage Users'),
- component: () => import('@/views/user/User.vue'),
- meta: {
- icon: UserOutlined
- }
- },
- {
- path: 'domain',
- name: () => $gettext('Manage Sites'),
- component: () => import('@/layouts/BaseRouterView.vue'),
- meta: {
- icon: CloudOutlined
- },
- redirect: '/domain/list',
- children: [{
- path: 'list',
- name: () => $gettext('Sites List'),
- component: () => import('@/views/domain/DomainList.vue')
- }, {
- path: 'add',
- name: () => $gettext('Add Site'),
- component: () => import('@/views/domain/DomainAdd.vue')
- }, {
- path: ':name',
- name: () => $gettext('Edit Site'),
- component: () => import('@/views/domain/DomainEdit.vue'),
- meta: {
- hiddenInSidebar: true
- }
- }]
- },
- {
- path: 'config',
- name: () => $gettext('Manage Configs'),
- component: () => import('@/views/config/Config.vue'),
- meta: {
- icon: FileOutlined,
- hideChildren: true
- }
- },
- {
- path: 'config/:name+/edit',
- name: () => $gettext('Edit Configuration'),
- component: () => import('@/views/config/ConfigEdit.vue'),
- meta: {
- hiddenInSidebar: true
- }
- },
- {
- path: 'cert',
- name: () => $gettext('Certification'),
- component: () => import('@/views/cert/Cert.vue'),
- meta: {
- icon: SafetyCertificateOutlined
- }
- },
- {
- path: 'terminal',
- name: () => $gettext('Terminal'),
- component: () => import('@/views/pty/Terminal.vue'),
- meta: {
- icon: CodeOutlined
- }
- },
- {
- path: 'nginx_log',
- name: () => $gettext('Nginx Log'),
- meta: {
- icon: FileTextOutlined
- },
- children: [{
- path: 'access',
- name: () => $gettext('Access Logs'),
- component: () => import('@/views/nginx_log/NginxLog.vue')
- }, {
- path: 'error',
- name: () => $gettext('Error Logs'),
- component: () => import('@/views/nginx_log/NginxLog.vue')
- }, {
- path: 'site',
- name: () => $gettext('Site Logs'),
- component: () => import('@/views/nginx_log/NginxLog.vue'),
- meta: {
- hiddenInSidebar: true
- }
- }]
- },
- {
- path: 'preference',
- name: () => $gettext('Preference'),
- component: () => import('@/views/preference/Preference.vue'),
- meta: {
- icon: SettingOutlined
- }
- },
- {
- path: 'about',
- name: () => $gettext('About'),
- component: () => import('@/views/other/About.vue'),
- meta: {
- icon: InfoCircleOutlined
- }
- }
- ]
- },
- {
- path: '/install',
- name: () => $gettext('Install'),
- component: () => import('@/views/other/Install.vue'),
- meta: {noAuth: true}
- },
- {
- path: '/login',
- name: () => $gettext('Login'),
- component: () => import('@/views/other/Login.vue'),
- meta: {noAuth: true}
- },
- {
- path: '/:pathMatch(.*)*',
- name: () => $gettext('Not Found'),
- component: () => import('@/views/other/Error.vue'),
- meta: {noAuth: true, status_code: 404, error: () => $gettext('Not Found')}
- }
- ]
- const router = createRouter({
- history: createWebHistory(),
- // @ts-ignore
- routes: routes
- })
- router.beforeEach((to, from, next) => {
- // @ts-ignore
- document.title = to.name?.() + ' | Nginx UI'
- const user = useUserStore()
- const {is_login} = user
- if (to.meta.noAuth || is_login) {
- next()
- } else {
- next({path: '/login', query: {next: to.fullPath}})
- }
- })
- export default router
|