Template
1
0
mirror of https://github.com/un-pany/v3-admin-vite.git synced 2025-04-20 19:09:21 +08:00

fix: 修复 RouteMeta 字段不完整的问题

This commit is contained in:
pany 2022-08-23 18:09:13 +08:00
parent a9f8e6ccc2
commit f1c8a14b98
5 changed files with 46 additions and 36 deletions

View File

@ -1,8 +1,9 @@
import { createRouter, createWebHashHistory, createWebHistory, RouteRecordRaw } from "vue-router"
import { createRouter, createWebHashHistory, createWebHistory } from "vue-router"
import type { RouteRecordRaw } from "vue-router"
const Layout = () => import("@/layout/index.vue")
/** 常驻路由 */
export const constantRoutes: Array<RouteRecordRaw> = [
export const constantRoutes: RouteRecordRaw[] = [
{
path: "/redirect",
component: Layout,
@ -138,7 +139,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
* (Roles )
* Name
*/
export const asyncRoutes: Array<RouteRecordRaw> = [
export const asyncRoutes: RouteRecordRaw[] = [
{
path: "/permission",
component: Layout,
@ -220,7 +221,7 @@ export function resetRouter() {
}
})
} catch (error) {
// 强制刷新浏览器,不过体验不是很好
// 强制刷新浏览器也行,只是交互体验不是很好
window.location.reload()
}
}

View File

@ -1,9 +0,0 @@
declare module "*.svg"
declare module "*.png"
declare module "*.jpg"
declare module "*.jpeg"
declare module "*.gif"
declare module "*.bmp"
declare module "*.tiff"
declare module "*.yaml"
declare module "*.json"

View File

@ -4,15 +4,6 @@ declare module "*.vue" {
export default component
}
declare module "*.gif" {
export const gif: any
}
declare module "*.svg" {
const content: any
export default content
}
declare module "*.scss" {
const scss: Record<string, string>
export default scss

View File

@ -1,14 +0,0 @@
import { ElMessage } from "element-plus"
declare module "@vue/runtime-core" {
interface ComponentCustomProperties {
$message: ElMessage
}
}
declare module "vue-router" {
interface RouteMeta {
roles?: string[]
activeMenu?: string
}
}

41
types/vue-router.d.ts vendored Normal file
View File

@ -0,0 +1,41 @@
import 'vue-router'
declare module "vue-router" {
interface RouteMeta {
/**
*
*/
title?: string
/**
* svg @/icons/svg
*/
icon?: string
/**
* false true
*/
hidden?: boolean
/**
*
*/
roles?: string[]
/**
* true false
*/
breadcrumb?: boolean
/**
* false true tags-view
*/
affix?: boolean
/**
* children 1
*
* children
* alwaysShow: true
*/
alwaysShow?: boolean
/**
* activeMenu
*/
activeMenu?: string
}
}