This commit is contained in:
zzc
2025-03-28 18:28:06 +08:00
commit 939c43f281
206 changed files with 30419 additions and 0 deletions

7
src/config/index.js Normal file
View File

@@ -0,0 +1,7 @@
/**
* @description 3个子配置通用配置|主题配置|网络配置导出
*/
const setting = require('./setting.config')
const theme = require('./theme.config')
const network = require('./net.config')
module.exports = Object.assign({}, setting, theme, network)

20
src/config/net.config.js Normal file
View File

@@ -0,0 +1,20 @@
/**
* @description 导出默认网路配置
**/
const network = {
// 默认的接口地址 如果是开发环境和生产环境走vab-mock-server当然你也可以选择自己配置成需要的接口地址
baseURL: process.env.NODE_ENV === 'development' ? 'http://127.0.0.1:3999' : 'http://127.0.0.1:3999',
//配后端数据的接收方式application/json;charset=UTF-8或者application/x-www-form-urlencoded;charset=UTF-8
contentType: 'application/json;charset=UTF-8',
//消息框消失时间
messageDuration: 3000,
//最长请求时间
requestTimeout: 5000,
//操作正常code支持String、Array、int多种类型
successCode: [200, 0],
//登录失效code
invalidCode: 402,
//无权限code
noPermissionCode: 401,
}
module.exports = network

76
src/config/permission.js Normal file
View File

@@ -0,0 +1,76 @@
/**
* @author https://github.com/zxwk1998/vue-admin-better 不想保留author可删除
* @description 路由守卫目前两种模式all模式与intelligence模式
*/
import router from '@/router'
import store from '@/store'
import VabProgress from 'nprogress'
import 'nprogress/nprogress.css'
import getPageTitle from '@/utils/pageTitle'
import { authentication, loginInterception, progressBar, recordRoute, routesWhiteList } from '@/config'
VabProgress.configure({
easing: 'ease',
speed: 500,
trickleSpeed: 200,
showSpinner: false,
})
router.beforeResolve(async (to, from, next) => {
if (progressBar) VabProgress.start()
let hasToken = store.getters['user/accessToken']
if (!loginInterception) hasToken = true
if (hasToken) {
if (to.path === '/login') {
next({ path: '/' })
if (progressBar) VabProgress.done()
} else {
const hasPermissions = store.getters['user/permissions'] && store.getters['user/permissions'].length > 0
if (hasPermissions) {
next()
} else {
try {
let permissions
if (!loginInterception) {
//settings.js loginInterception为false时创建虚拟权限
await store.dispatch('user/setPermissions', ['admin'])
permissions = ['admin']
} else {
permissions = await store.dispatch('user/getUserInfo')
}
let accessRoutes = []
if (authentication === 'intelligence') {
accessRoutes = await store.dispatch('routes/setRoutes', permissions)
} else if (authentication === 'all') {
accessRoutes = await store.dispatch('routes/setAllRoutes')
}
accessRoutes.forEach((item) => {
router.addRoute(item)
})
next({ ...to, replace: true })
} catch {
await store.dispatch('user/resetAccessToken')
if (progressBar) VabProgress.done()
}
}
}
} else {
if (routesWhiteList.indexOf(to.path) !== -1) {
next()
} else {
if (recordRoute) {
next(`/login?redirect=${to.path}`)
} else {
next('/login')
}
if (progressBar) VabProgress.done()
}
}
document.title = getPageTitle(to.meta.title)
})
router.afterEach(() => {
if (progressBar) VabProgress.done()
})

View File

@@ -0,0 +1,70 @@
/**
* @description 导出默认通用配置
*/
const setting = {
// 开发以及部署时的URL
publicPath: '',
// 生产环境构建文件的目录名
outputDir: 'dist',
// 放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录。
assetsDir: 'static',
// 开发环境每次保存时是否输出为eslint编译警告
lintOnSave: true,
// 进行编译的依赖
transpileDependencies: [],
//标题 (包括初次加载雪花屏的标题 页面的标题 浏览器的标题)
title: '管理后台',
//简写
abbreviation: 'vab',
//开发环境端口号
devPort: '81',
//版本号
version: process.env.VUE_APP_VERSION,
//这一项非常重要请务必保留MIT协议下package.json及copyright作者信息 即可免费商用不遵守此项约定你将无法使用该框架如需自定义版权信息请联系QQ1204505056
copyright: 'vab',
//是否显示页面底部自定义版权信息
footerCopyright: true,
//是否显示顶部进度条
progressBar: true,
//缓存路由的最大数量
keepAliveMaxNum: 99,
// 路由模式,可选值为 history 或 hash
routerMode: 'hash',
//不经过token校验的路由
routesWhiteList: ['/login', '/register', '/404', '/401'],
//加载时显示文字
loadingText: '正在加载中...',
//token名称
tokenName: 'accessToken',
//token在localStorage、sessionStorage存储的key的名称
tokenTableName: 'vue-admin-better-2024',
//token存储位置localStorage sessionStorage
storage: 'localStorage',
//token失效回退到登录页时是否记录本次的路由
recordRoute: true,
//是否显示logo不显示时设置false显示时请填写remixIcon图标名称暂时只支持设置remixIcon
logo: 'vuejs-fill',
//是否显示在页面高亮错误
errorLog: ['development', 'production'],
//是否开启登录拦截
loginInterception: true,
//是否开启登录RSA加密
loginRSA: true,
//intelligence和all两种方式前者后端权限只控制permissions不控制view文件的import前后端配合减轻后端工作量all方式完全交给后端前端只负责加载
authentication: 'intelligence',
//vertical布局时是否只保持一个子菜单的展开
uniqueOpened: true,
//vertical布局时默认展开的菜单path使用逗号隔开建议只展开一个
defaultOopeneds: ['/vab'],
//需要加loading层的请求防止重复提交
debounce: ['doEdit'],
//需要自动注入并加载的模块
providePlugin: {},
//代码生成机生成在view下的文件夹名称
templateFolder: 'project',
//是否显示终端donation打印
donation: true,
//是否开启图片压缩
imageCompression: true,
}
module.exports = setting

6
src/config/settings.js Normal file
View File

@@ -0,0 +1,6 @@
/**
* @description 3个子配置通用配置|主题配置|网络配置
*/
//默认配置
const { setting, theme, network } = require('./')
module.exports = Object.assign({}, setting, theme, network)

View File

@@ -0,0 +1,14 @@
/**
* @description 导出默认主题配置
*/
const theme = {
//是否国定头部 固定fixed 不固定noFixed
header: 'fixed',
//横纵布局 horizontal vertical
layout: 'vertical',
//是否开启主题配置按钮
themeBar: true,
//是否显示多标签页
tabsBar: true,
}
module.exports = theme