|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import LoadingComponent from "@/microhost/components/pageLoading"
|
|
|
|
|
import { dynamic } from 'umi'
|
|
|
|
|
import {AppstoreOutlined, HomeOutlined} from "@ant-design/icons"
|
|
|
|
|
import { AppstoreOutlined, HomeOutlined } from "@ant-design/icons"
|
|
|
|
|
import lodash, { isArray } from "lodash"
|
|
|
|
|
import MicroApps from './microhost/system/apps'
|
|
|
|
|
import Runtime from './microhost/runtimes'
|
|
|
|
@ -14,7 +14,7 @@ let globalApps: any[] = []
|
|
|
|
|
//window.RuntimeRoutes = new Array()
|
|
|
|
|
|
|
|
|
|
window.addEventListener("error", (error) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
window.addEventListener("unhandledrejection", (error) => {
|
|
|
|
@ -24,7 +24,7 @@ window.addEventListener("unhandledrejection", (error) => {
|
|
|
|
|
/**
|
|
|
|
|
* Step 3
|
|
|
|
|
* 重载路由
|
|
|
|
|
* @param param0
|
|
|
|
|
* @param param0
|
|
|
|
|
*/
|
|
|
|
|
export function patchRoutes({ routes }) {
|
|
|
|
|
routes = !routes ? [] : routes
|
|
|
|
@ -34,10 +34,10 @@ export function patchRoutes({ routes }) {
|
|
|
|
|
|
|
|
|
|
//console.log(localStorage.getItem("_sk_act"))
|
|
|
|
|
|
|
|
|
|
for(let i = 0; i < routes.length; i++){
|
|
|
|
|
for (let i = 0; i < routes.length; i++) {
|
|
|
|
|
let route = routes[i]
|
|
|
|
|
|
|
|
|
|
if(route.path == "/"){
|
|
|
|
|
if (route.path == "/") {
|
|
|
|
|
// route.component = dynamic({
|
|
|
|
|
// loader: (a: any) => import(/* webpackChunkName: 'layouts__MicroAppLayout' */ `@/microhost/layouts/${themeFounder.skin}/patterns/microapp`),
|
|
|
|
|
// //loader: () => import(/* webpackChunkName: 'layouts__MicroAppLayout' */ '@/layouts/iBKLinkerLayout'),
|
|
|
|
@ -52,53 +52,53 @@ export function patchRoutes({ routes }) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!docked){
|
|
|
|
|
if (!docked) {
|
|
|
|
|
// let plats = patchPlatformRoutes()
|
|
|
|
|
// console.log("platform routes", plats)
|
|
|
|
|
routes.push({
|
|
|
|
|
path: "/",
|
|
|
|
|
component: dynamic({
|
|
|
|
|
loader: (a: any) => import(/* webpackChunkName: 'layouts__MicroAppLayout' */ `@/microhost/layouts/${themeFounder.skin}`),
|
|
|
|
|
//loader: () => import(/* webpackChunkName: 'layouts__MicroAppLayout' */ '@/layouts/iBKLinkerLayout'),
|
|
|
|
|
loading: LoadingComponent,
|
|
|
|
|
tmpl: `@/microhost/layouts/${themeFounder.skin}`,
|
|
|
|
|
}),
|
|
|
|
|
loader: (a: any) => import(/* webpackChunkName: 'layouts__MicroAppLayout' */ `@/microhost/layouts/${themeFounder.skin}`),
|
|
|
|
|
//loader: () => import(/* webpackChunkName: 'layouts__MicroAppLayout' */ '@/layouts/iBKLinkerLayout'),
|
|
|
|
|
loading: LoadingComponent,
|
|
|
|
|
tmpl: `@/microhost/layouts/${themeFounder.skin}`,
|
|
|
|
|
}),
|
|
|
|
|
// routes: extraRoutes.concat(plats)
|
|
|
|
|
routes: [
|
|
|
|
|
...extraRoutes,
|
|
|
|
|
// ...plats,
|
|
|
|
|
{
|
|
|
|
|
name: "工作台",
|
|
|
|
|
path: `/$plat/workbench`,
|
|
|
|
|
name: "工作台",
|
|
|
|
|
path: `/$plat/workbench`,
|
|
|
|
|
component: dynamic({
|
|
|
|
|
loader: (a: any) => import(`@/pages/workbench`),
|
|
|
|
|
loading: LoadingComponent,
|
|
|
|
|
}),
|
|
|
|
|
loading: "@/microhost/components/pageLoading",
|
|
|
|
|
hideInMenu: true,
|
|
|
|
|
}),
|
|
|
|
|
loading: "@/microhost/components/pageLoading",
|
|
|
|
|
hideInMenu: true,
|
|
|
|
|
platform: {
|
|
|
|
|
openmind: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
children: undefined,
|
|
|
|
|
url: `/$plat/workbench`,
|
|
|
|
|
moduleId: `plat/workbench/index`,
|
|
|
|
|
id: `plat/workbench/index`,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "平台首页",
|
|
|
|
|
path: `/$plat/homepage`,
|
|
|
|
|
name: "平台首页",
|
|
|
|
|
path: `/$plat/homepage`,
|
|
|
|
|
component: dynamic({
|
|
|
|
|
loader: (a: any) => import(`@/pages/homepage`),
|
|
|
|
|
loading: LoadingComponent,
|
|
|
|
|
}),
|
|
|
|
|
loading: "@/microhost/components/pageLoading",
|
|
|
|
|
}),
|
|
|
|
|
loading: "@/microhost/components/pageLoading",
|
|
|
|
|
hideInMenu: true,
|
|
|
|
|
locked: true,
|
|
|
|
|
icon: "HomeOutlined",
|
|
|
|
|
platform: {
|
|
|
|
|
openmind: true,
|
|
|
|
|
steep: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
children: undefined,
|
|
|
|
|
url: `/$plat/homepage`,
|
|
|
|
|
moduleId: `plat/homepage/index`,
|
|
|
|
@ -108,7 +108,7 @@ export function patchRoutes({ routes }) {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
MicroApps.GetRuntimeRouter().patchRoutes(routes)
|
|
|
|
|
MicroApps.GetRuntimeRouter().routeWorking = routes
|
|
|
|
|
MicroApps.GetRuntimeRouter().routeWorking = routes
|
|
|
|
|
//let apppath = MicroApps.GetRuntimeTheme().pattern("app")
|
|
|
|
|
//console.log("patch routes", routes, apppath)
|
|
|
|
|
//window.RuntimeRoutes = routes
|
|
|
|
@ -116,11 +116,11 @@ export function patchRoutes({ routes }) {
|
|
|
|
|
|
|
|
|
|
function patchPlatformRoutes() {
|
|
|
|
|
let results: any[] = []
|
|
|
|
|
if(!PlatformRoutes || PlatformRoutes.length == 0) return results
|
|
|
|
|
if (!PlatformRoutes || PlatformRoutes.length == 0) return results
|
|
|
|
|
|
|
|
|
|
PlatformRoutes.forEach((route) => {
|
|
|
|
|
let handle = patchSeekRoutes(route)
|
|
|
|
|
if(handle){
|
|
|
|
|
if (handle) {
|
|
|
|
|
results.push(handle)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
@ -129,26 +129,26 @@ function patchPlatformRoutes() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function patchSeekRoutes(route: any) {
|
|
|
|
|
if(!route) return undefined
|
|
|
|
|
if (!route) return undefined
|
|
|
|
|
|
|
|
|
|
let children: any[] = []
|
|
|
|
|
|
|
|
|
|
if(isArray(route.children) && route.children.length > 0){
|
|
|
|
|
if (isArray(route.children) && route.children.length > 0) {
|
|
|
|
|
route.children.forEach((child: any) => {
|
|
|
|
|
let handle = patchSeekRoutes(child)
|
|
|
|
|
if(handle){
|
|
|
|
|
if (handle) {
|
|
|
|
|
children.push(handle)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
...route,
|
|
|
|
|
...route,
|
|
|
|
|
component: dynamic({
|
|
|
|
|
loader: (a: any) => import(route.component),
|
|
|
|
|
loading: LoadingComponent,
|
|
|
|
|
}),
|
|
|
|
|
loading: "@/microhost/components/pageLoading",
|
|
|
|
|
}),
|
|
|
|
|
loading: "@/microhost/components/pageLoading",
|
|
|
|
|
//children: children && children.length > 0 ? children : undefined,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -156,15 +156,15 @@ function patchSeekRoutes(route: any) {
|
|
|
|
|
/**
|
|
|
|
|
* Step 2
|
|
|
|
|
* 动态注入路由
|
|
|
|
|
* @param param0
|
|
|
|
|
* @param param0
|
|
|
|
|
*/
|
|
|
|
|
export function render(oldRender: () => void) {
|
|
|
|
|
//extraRoutes = lodash.cloneDeep(MicroApps.runtimes.router.routeExtends)
|
|
|
|
|
oldRender();
|
|
|
|
|
oldRender();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function onRouteChange(params: any) {
|
|
|
|
|
//console.log("on route change", params)
|
|
|
|
|
//console.log("on route change", params)
|
|
|
|
|
MicroApps.GetRuntimeRouter().onRouteChanged(params)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -184,7 +184,7 @@ const getApps = async () => {
|
|
|
|
|
*/
|
|
|
|
|
export const qiankun = getApps().then((apps: any) => {
|
|
|
|
|
apps = !apps ? [] : apps
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const tmp = apps.map((app: any) => {
|
|
|
|
|
return {
|
|
|
|
|
...app,
|
|
|
|
@ -238,7 +238,14 @@ export async function getInitialState() {
|
|
|
|
|
let model = new SystemData()
|
|
|
|
|
let params = await model.parameters()
|
|
|
|
|
//console.log("params", params)
|
|
|
|
|
|
|
|
|
|
const host: string = window.location.hostname
|
|
|
|
|
if (host.indexOf("localhost") !== -1) {
|
|
|
|
|
} else {
|
|
|
|
|
if (window.top === window.self) {
|
|
|
|
|
window.location.href = 'https://metal.dayesteel.com.cn';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
userRoutes: MicroApps.runtimes.router.routeExtends,
|
|
|
|
|
userInfo: userData,
|
|
|
|
@ -246,4 +253,4 @@ export async function getInitialState() {
|
|
|
|
|
parameters: params,
|
|
|
|
|
ws: params?.SocketServer
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|