进行优化
This commit is contained in:
parent
7cfca66ac4
commit
99634a49d7
|
|
@ -0,0 +1,2 @@
|
|||
# 本地环境
|
||||
NODE_ENV = 'development'
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
# 线上环境
|
||||
NODE_ENV = "production"
|
||||
|
|
@ -17,13 +17,12 @@ router.beforeEach(async(to, from, next) => {
|
|||
if(typeof(to.meta.title) === 'string'){
|
||||
document.title = to.meta.title ||'vue-admin-perfect'
|
||||
}
|
||||
// 确定用户是否已登录
|
||||
// 确定用户是否已登录过,存在Token
|
||||
const hasToken = getToken()
|
||||
if (hasToken) {
|
||||
if (to.path === '/login') {
|
||||
// 如果已登录,请重定向到主页
|
||||
next({ path: '/' })
|
||||
NProgress.done()
|
||||
} else {
|
||||
try {
|
||||
// 路由添加进去了没有及时更新 需要重新进去一次拦截
|
||||
|
|
@ -40,7 +39,6 @@ router.beforeEach(async(to, from, next) => {
|
|||
} catch (error) {
|
||||
next(`/login?redirect=${to.path}`)
|
||||
}
|
||||
NProgress.done()
|
||||
}
|
||||
}else{
|
||||
if (whiteList.indexOf(to.path) !== -1) {
|
||||
|
|
@ -49,8 +47,11 @@ router.beforeEach(async(to, from, next) => {
|
|||
next(`/login?redirect=${to.path}`)
|
||||
|
||||
}
|
||||
NProgress.done()
|
||||
}
|
||||
})
|
||||
|
||||
router.afterEach(() => {
|
||||
NProgress.done();
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
import { createRouter, createWebHistory, RouteRecordRaw,createWebHashHistory,Router } from 'vue-router'
|
||||
import Layout from "@/layout/index.vue";
|
||||
|
||||
// 扩展继承属性
|
||||
interface extendRoute {
|
||||
hidden?:boolean
|
||||
}
|
||||
|
||||
// 引入组件
|
||||
import chartsRouter from './modules/charts'
|
||||
import chatRouter from './modules/chat'
|
||||
|
|
@ -14,19 +19,24 @@ import excelRouter from './modules/excel'
|
|||
import nestedRouter from './modules/nested'
|
||||
import systemRouter from './modules/system'
|
||||
|
||||
|
||||
interface extendRoute {
|
||||
hidden?:boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* alwaysShow 如果设置为true,将始终显示根菜单,无论其子路由长度如何
|
||||
* hidden 如果“hidden:true”不会显示在侧边栏中(默认值为false)
|
||||
* keepAlive 设为true 缓存
|
||||
* path ==> 路由路径
|
||||
* name ==> 路由名称
|
||||
* component ==> 路由组件
|
||||
* redirect ==> 路由重定向
|
||||
* alwaysShow ==> 如果设置为true,将始终显示根菜单,无论其子路由长度如何
|
||||
* hidden ==> 如果“hidden:true”不会显示在侧边栏中(默认值为false)
|
||||
* keepAlive ==> 设为true 缓存
|
||||
* meta ==> 路由元信息
|
||||
* meta.title ==> 路由标题
|
||||
* meta.icon ==> 菜单icon
|
||||
*/
|
||||
|
||||
|
||||
export const constantRoutes: Array<RouteRecordRaw&extendRoute> = [
|
||||
{
|
||||
path: "/",
|
||||
redirect: { name: "login" }
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
|
|
@ -34,7 +44,6 @@ export const constantRoutes: Array<RouteRecordRaw&extendRoute> = [
|
|||
hidden: true,
|
||||
meta: { title: '登录',}
|
||||
},
|
||||
|
||||
{
|
||||
path: '/',
|
||||
name: 'layout',
|
||||
|
|
@ -49,7 +58,6 @@ export const constantRoutes: Array<RouteRecordRaw&extendRoute> = [
|
|||
},
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
const clipboardTable = {
|
||||
|
|
@ -95,37 +103,33 @@ const zipRoutes = {
|
|||
|
||||
]
|
||||
}
|
||||
//
|
||||
|
||||
// // 异步组件
|
||||
export const asyncRoutes = [
|
||||
tableRouter,
|
||||
chartsRouter,
|
||||
chatRouter,
|
||||
componentsRouter,
|
||||
othersRouter,
|
||||
nestedRouter,
|
||||
tableRouter,
|
||||
chartsRouter,
|
||||
chatRouter,
|
||||
componentsRouter,
|
||||
othersRouter,
|
||||
nestedRouter,
|
||||
excelRouter,
|
||||
zipRoutes,
|
||||
errorRouter,
|
||||
externalLink,
|
||||
clipboardTable,
|
||||
errorRouter,
|
||||
externalLink,
|
||||
clipboardTable,
|
||||
systemRouter,
|
||||
permissionRouter,
|
||||
permissionRouter,
|
||||
|
||||
{
|
||||
path: '/:pathMatch(.*)',
|
||||
redirect: '/error/404'
|
||||
}
|
||||
{
|
||||
path: '/:pathMatch(.*)',
|
||||
redirect: '/error/404'
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
const router = createRouter({
|
||||
// history: createWebHistory(process.env.BASE_URL), // history
|
||||
history: createWebHashHistory(), // hash
|
||||
routes:constantRoutes
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
export default router
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
<el-form-item>
|
||||
<el-button @click="reset(ruleFormRef)">重置</el-button>
|
||||
<el-button type="primary" @click="onSubmit">查询</el-button>
|
||||
<el-button type="text" @click="isExpand = !isExpand"
|
||||
<el-button link @click="isExpand = !isExpand"
|
||||
>{{ isExpand ? '合并' : '展开'
|
||||
}}<el-icon>
|
||||
<arrow-down v-if="!isExpand" />
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": ["ESNext", "DOM"],
|
||||
// 跳过库检查,解决打包失败
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ export default defineConfig({
|
|||
// Components({
|
||||
// resolvers: [ElementPlusResolver()],
|
||||
// }),
|
||||
// * 使用 svg 图标
|
||||
createSvgIconsPlugin({
|
||||
// 指定需要缓存的图标文件夹
|
||||
iconDirs: [path.resolve(process.cwd(), 'src/icons/svg')],
|
||||
|
|
@ -55,11 +56,20 @@ export default defineConfig({
|
|||
},
|
||||
//启动服务配置
|
||||
server: {
|
||||
// 服务器主机名,如果允许外部访问,可设置为 "0.0.0.0" 也可设置成你的ip地址
|
||||
host: '0.0.0.0',
|
||||
port: 8100,
|
||||
open: true,
|
||||
https: false,
|
||||
proxy: {},
|
||||
cors: true,
|
||||
// 代理跨域(模拟示例)
|
||||
proxy: {
|
||||
// "/api": {
|
||||
// target: "", // easymock
|
||||
// changeOrigin: true,
|
||||
// rewrite: path => path.replace(/^\/api/, "")
|
||||
// }
|
||||
}
|
||||
},
|
||||
// 生产环境打包配置
|
||||
//去除 console debugger
|
||||
|
|
|
|||
Loading…
Reference in New Issue