diff options
author | 2021-01-08 12:23:31 +0800 | |
---|---|---|
committer | 2021-01-08 12:24:04 +0800 | |
commit | 5bead046179e8e00c2cc4681992a6ffe24e4b97e (patch) | |
tree | 42ff8dbab525359dcb978faa5708542cf2b5e664 /usecaseui-portal/src/app/guard | |
parent | 114398200f66e9139352d236beb5eb6417baa879 (diff) |
feat: embedding vue framwork in angular
Signed-off-by: wangyuerg <wangyuerg@chinamobile.com>
Change-Id: Ib065f7d3e1b7533161f880b5093ee9b829d2e46d
Issue-ID: USECASEUI-444
Diffstat (limited to 'usecaseui-portal/src/app/guard')
-rw-r--r-- | usecaseui-portal/src/app/guard/jump.guard.ts | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/usecaseui-portal/src/app/guard/jump.guard.ts b/usecaseui-portal/src/app/guard/jump.guard.ts new file mode 100644 index 00000000..27892115 --- /dev/null +++ b/usecaseui-portal/src/app/guard/jump.guard.ts @@ -0,0 +1,46 @@ +import {CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from "@angular/router"; +import { Route } from "@angular/compiler/src/core"; +import { menu, address } from "../const/index" +import { environment } from '../../environments/environment' + + +export class JumpGuard implements CanActivate { + + canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { + let next: boolean = true + console.log(state.url) + const target: string = state.url + console.log('不在该框架') + // looking for the source of this path + const menuList: Array<any> = menu.MENU_ITEM + let source: string = null + for (let item of menuList) { + if (item.path === target) { + source = item.source + } else { + for (let val of item.children) { // If you can't find it, recurse deeper + if (val.path === target) { + source = val.source + } + } + } + } + if (source === null) { // The source of the path is not recorded in the routing table + console.log('The source of the path is not recorded in the routing table') + } else { + const targetServer = address.ADDRESS[source] + console.log(targetServer, environment) + let newUrl: string = '' + if (environment.production === false) { + newUrl = `${targetServer}#${target}` + console.log(newUrl) + } else { // production + let baseUrl = window.location.href.split('#')[0] + newUrl = `${baseUrl}${source}/#${target}` + } + next = false + window.location.href = newUrl + } + return next; + } +}
\ No newline at end of file |