feat(XPack): 路由配置

This commit is contained in:
fit2-zhao 2021-03-03 18:47:09 +08:00
parent 032b9e16e1
commit d40fe759a9
2 changed files with 8 additions and 5 deletions

View File

@ -29,15 +29,15 @@
</template> </template>
<script> <script>
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const requireContext = require.context('@/business/components/xpack/', true, /router\.js$/)
const report = requireComponent.keys().length > 0 ? requireComponent("./report/ReportAnalysis.vue") : null; const report = requireContext.keys().map(key => requireContext(key).report);
const isReport = report && report != null && report.length > 0 && report[0] != undefined ? true : false;
export default { export default {
name: "MsTopMenus", name: "MsTopMenus",
data() { data() {
return { return {
activeIndex: '/', activeIndex: '/',
isReport: report isReport: isReport
} }
}, },
watch: { watch: {

View File

@ -5,7 +5,10 @@ import Setting from "@/business/components/settings/router";
import API from "@/business/components/api/router"; import API from "@/business/components/api/router";
import Performance from "@/business/components/performance/router"; import Performance from "@/business/components/performance/router";
import Track from "@/business/components/track/router"; import Track from "@/business/components/track/router";
const requireContext = require.context('@/business/components/xpack/', true, /router\.js$/) const requireContext = require.context('@/business/components/xpack/', true, /router\.js$/)
const Report = requireContext.keys().map(key => requireContext(key).report);
const ReportObj = Report && Report != null && Report.length > 0 && Report[0] != undefined ? Report : [{path: "/sidebar"}];
Vue.use(VueRouter); Vue.use(VueRouter);
@ -22,7 +25,7 @@ const router = new VueRouter({
API, API,
Performance, Performance,
Track, Track,
...requireContext.keys().map(key => requireContext(key).report), ...ReportObj
] ]
}); });