Commit dc75af53 authored by 前端-许佳敏's avatar 前端-许佳敏

feat: 权限路由2.0

parent a3304074
......@@ -24,9 +24,15 @@ system.json
/.idea
config/base.config.json
config/component.config.json
config/router.config.ts
config/router.config.js
config/router.config.json
/src/services/index.ts
src/global/config/global.d.ts
src/services/*Api.ts
src/services/*Api
.vscode
scripts/god-scripts
/*
/*
* @Author: Bill
* @Date: 2020-10-22 15:05:27
* @Description: 平台结算管理
......
......@@ -6,55 +6,57 @@
/**
* @description 路由配置页, 更多配置可查看 https://umijs.org/zh-CN/docs/routing#routes
*/
import pageCustomized from './pageCustomized'
import calssPropertyRoute from './calssPropertyRoute' // 品类属性路由
import trademarkRoute from './brandRoute' // 品牌路由
import commodity from './commodityRoute' // 商品审核路由
import demandOrderRoute from './demandOrderRoute' //需求单审核
import demandQuoteOrderRoute from './demandQuoteOrderRoute' //需求报价单管理
import logisticsRoutes from './logisticsRoutes'
import memberAbility from './memberAbility'
import ruleSettingRoutes from './ruleSettingRoutes'
import authConfig from './authConfig'
import rfqRoute from './rfqRoute' // 询价单路由
import rfqOfferRoute from './rfqOfferRoute' // 询价单路由
import commentRoutes from './commentRoutes';
import contentRoute from './contentRoute'; // 内容管理
import balancedRoute from './balancedRoute'; // 平台结算管理
import capitalAccount from './capitalAccountRoute'; // 会员资金账户
import messageRoute from './messgeRoute'; // 消息管理
import systemManageRoute from './systemManageRoute'; // 系统管理
import orderSystemRoutes from './orderSystemRoutes'; // 订单管理
import productionNoticeRoutes from './productionNoticeRoute'; // 生产通知单管理
import exchangeManageRoutes from './exchangeManageRoute'; // 换货申请单管理
import returnManageRoute from './returnManageRoute'; // 退货申请单管理
import repairManageRoute from './repairManageRoute'; // 维修申请单管理
// import pageCustomized from './pageCustomized'
// import calssPropertyRoute from './calssPropertyRoute' // 品类属性路由
// import trademarkRoute from './brandRoute' // 品牌路由
// import commodity from './commodityRoute' // 商品审核路由
// import demandOrderRoute from './demandOrderRoute' //需求单审核
// import demandQuoteOrderRoute from './demandQuoteOrderRoute' //需求报价单管理
// import logisticsRoutes from './logisticsRoutes'
// import memberAbility from './memberAbility'
// import ruleSettingRoutes from './ruleSettingRoutes'
// import authConfig from './authConfig'
// import rfqRoute from './rfqRoute' // 询价单路由
// import rfqOfferRoute from './rfqOfferRoute' // 询价单路由
// import commentRoutes from './commentRoutes';
// import contentRoute from './contentRoute'; // 内容管理
// import balancedRoute from './balancedRoute'; // 平台结算管理
// import capitalAccount from './capitalAccountRoute'; // 会员资金账户
// import messageRoute from './messgeRoute'; // 消息管理
// import systemManageRoute from './systemManageRoute'; // 系统管理
// import orderSystemRoutes from './orderSystemRoutes'; // 订单管理
// import productionNoticeRoutes from './productionNoticeRoute'; // 生产通知单管理
// import exchangeManageRoutes from './exchangeManageRoute'; // 换货申请单管理
// import returnManageRoute from './returnManageRoute'; // 退货申请单管理
// import repairManageRoute from './repairManageRoute'; // 维修申请单管理
const routeList = [
pageCustomized,
calssPropertyRoute,
trademarkRoute,
commodity,
rfqRoute,
rfqOfferRoute,
logisticsRoutes,
memberAbility,
ruleSettingRoutes,
authConfig,
commentRoutes,
contentRoute,
balancedRoute,
demandOrderRoute,
demandQuoteOrderRoute,
capitalAccount,
messageRoute,
systemManageRoute,
orderSystemRoutes,
productionNoticeRoutes,
exchangeManageRoutes,
returnManageRoute,
repairManageRoute,
]
//@ts-ignore
import asyncRoutes from '../router.config.json'
// const routeList = [
// pageCustomized,
// calssPropertyRoute,
// trademarkRoute,
// commodity,
// rfqRoute,
// rfqOfferRoute,
// logisticsRoutes,
// memberAbility,
// ruleSettingRoutes,
// authConfig,
// commentRoutes,
// contentRoute,
// balancedRoute,
// demandOrderRoute,
// demandQuoteOrderRoute,
// capitalAccount,
// messageRoute,
// systemManageRoute,
// orderSystemRoutes,
// productionNoticeRoutes,
// exchangeManageRoutes,
// returnManageRoute,
// repairManageRoute,
// ]
const router = [
{
......@@ -89,13 +91,7 @@ const router = [
path: '/',
redirect: '/home'
},
{
path: '/home',
name: 'home',
component: '@/pages/home',
icon: 'BarChartOutlined'
},
...routeList,
...asyncRoutes,
{
path: '/noAuth',
hidePageHeader: true,
......
......@@ -76,6 +76,7 @@
},
"devDependencies": {
"@types/sortablejs": "^1.10.6",
"async": "^3.2.0",
"axios": "^0.19.2",
"connect-history-api-fallback": "^1.6.0",
"cross-env": "^7.0.2",
......
......@@ -8,16 +8,17 @@ const fetchConfig = require(runFile).fetchConfig
const gulp = require('gulp')
const json2ts = require('json2ts')
const uploadBuildStram = require('./build')
const pullRemoteRouter = require('./pullRemoteRouterList')
const rootPath = '../';
const outputPath = path.resolve(__dirname, rootPath, 'config/base.config.json')
const outputPath = path.resolve(__dirname, rootPath, 'config/base.config.json')
const outputDts = path.resolve(__dirname, rootPath, 'src/global/config/global.d.ts')
Logs.start('gulp start')
gulp.task('start', gulp.series(done => {
getAsyncConfig(done)
startRemotePull(done)
}))
gulp.task('upload', gulp.series(done => {
......@@ -59,10 +60,18 @@ function genarateDtsFile(json, done) {
}
/**
* 异步读取远程路由并写入
*/
async function startRemotePull(done) {
await pullRemoteRouter()
getAsyncConfig(done)
}
/**
* 异步获取远程配置
* @todo
*/
async function getAsyncConfig(done) {
const data = await fetchConfig()
genarateBaseJson(data, done)
}
\ No newline at end of file
}
/**
* 用于在项目开始前获取所有的配置
* 在项目开始前运行`yarn scripts:build`
* @todo 缺少异常处理清空
* @author xjm
*/
const Axios = require('axios').default;
const deepClone = require('clone')
const fs = require('fs')
const path = require('path')
const BACK_GATEWAY = process.env.BACK_GATEWAY
const source = 99
const remoteUrl = BACK_GATEWAY || process.argv[2] || 'http://10.0.0.25:8100'
console.log(`\n当前访问的后端url是${remoteUrl}!!!!!!`)
const axios = Axios.create({
baseURL: remoteUrl,
responseType: 'json',
})
const serviceConfig = {
//初始化会员支付策略配置
router: {
componentList: {
url: '/system/menu/code/list',
method: 'get',
params: {
source
}
},
routerList: {
url: '/system/menu/tree',
method: 'get',
params: {
source
}
}
},
}
function code2component(components, codes) {
components.forEach(v => {
if (v.routes) {
code2component(v.routes, codes)
}
if (v.component) {
const codeResult = codes.find(c => c.code === v.component)
if (!codeResult) {
console.error(`出现不匹配的component->${v.component}\n`)
}
v.component = codeResult.url
}
})
}
// 批量组装接口
async function batchAxiosHttps() {
const asyncHttpQueue = deepClone(serviceConfig)
const httpErrorQueue = []
const serverErrorQueue = []
console.log('\n')
for (const item in serviceConfig) {
if (JSON.stringify(item) !== '{}') {
for (const subItem in serviceConfig[item]) {
try {
const data = await axios(serviceConfig[item][subItem])
// 当接口出错时 不写入json文件
if (data.data.code === 1000) {
asyncHttpQueue[item][subItem] = data.data.data
} else {
serverErrorQueue.push({ ...asyncHttpQueue[item][subItem], ...data.data })
// 默认置为null
asyncHttpQueue[item][subItem] = null
}
} catch (err) {
httpErrorQueue.push({ ...serviceConfig[item][subItem], ...err.response.data })
}
}
}
}
if (httpErrorQueue.length > 0) {
console.log('\n网络错误\n')
// 可在此做日志收集
console.log(httpErrorQueue)
}
if (serverErrorQueue.length > 0) {
console.log('接口服务错误\n')
// 可在此做日志收集
console.log(serverErrorQueue)
}
if (httpErrorQueue.length > 0 || serverErrorQueue.length > 0) {
// 退出构建
console.log('\n脚本构建失败!!!!!!')
// 终止当前进程
process.exit(1)
}
// fs.writeFile(path.resolve(__dirname, '../config/component.config.json'), `${JSON.stringify(asyncHttpQueue.router.componentList)}`, function(err) {
// if (err) throw err
// })
// code2component(asyncHttpQueue.router.routerList, asyncHttpQueue.router.componentList)
fs.writeFile(path.resolve(__dirname, '../config/router.config.json'), `${JSON.stringify(asyncHttpQueue.router.routerList)}`, function(err) {
if (err) throw err
})
}
module.exports = batchAxiosHttps
......@@ -47,11 +47,11 @@ export const getSelectedMenuKeys = (
};
const Layout = props => {
const { formatMessage } = useIntl();
// const { formatMessage } = useIntl();
const basicInfo = getMenuData(
props.route.routes,
{ locale: true },
formatMessage,
{ locale: false },
// formatMessage,
);
const [collapseState, setCollapseState] = useState(false);
const defaultOpenKeysRef = useRef<string[]>([]);
......@@ -89,7 +89,8 @@ const Layout = props => {
<ProLayout
title="瓴犀平台后台"
navTheme="light"
formatMessage={formatMessage}
locale={false}
// formatMessage={formatMessage}
onCollapse={collapse => {
setCollapseState(collapse);
}}
......
......@@ -156,12 +156,13 @@ class MenuUtil {
formatMessage
} = this.props
const { name, locale } = item;
if (locale && formatMessage) {
return formatMessage({
id: locale,
defaultMessage: name,
});
}
// 去除菜单的国际化 交给配置来控制
// if (locale && formatMessage) {
// return formatMessage({
// id: locale,
// defaultMessage: name,
// });
// }
return name;
};
......
......@@ -11,6 +11,7 @@
"sourceMap": true,
"baseUrl": "./",
"strict": true,
"resolveJsonModule": true,
"paths": {
"@/*": ["src/*"],
"@@/*": ["src/.umi/*"]
......
......@@ -4014,8 +4014,8 @@ async@^2.6.2:
async@^3.2.0:
version "3.2.0"
resolved "http://10.0.0.21:8081/repository/node-group/async/-/async-3.2.0.tgz#b3a2685c5ebb641d3de02d161002c60fc9f85720"
integrity sha1-s6JoXF67ZB094C0WEALGD8n4VyA=
resolved "http://10.0.0.19:4873/async/-/async-3.2.0.tgz#b3a2685c5ebb641d3de02d161002c60fc9f85720"
integrity sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==
asynckit@^0.4.0:
version "0.4.0"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment