| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import { AppKernel } from "@scripts/app/AppKernel";
- import { UIViewID } from "@scripts/define/UIDefine";
- export enum RouteType {
- None,
- UI,
- Url,
- }
- function parseUIParams(link: string) {
- let res = { viewID: link, params: null }
- if (link.indexOf('?')) {
- const url = new URL(link, "https://test.com/");
- const viewID = url.pathname.replace(/^\//, "");
- let params: any = {};
- url.searchParams.forEach((value, key) => {
- params[key] = value;
- })
- res.params = params;
- res.viewID = viewID;
- }
- return res;
- }
- export function handleRoute(link: string) {
- //ui://
- //target://
- if (link.startsWith('http')) {
- window.open(link);
- return;
- }
- const { viewID, params } = parseUIParams(link);
- if (viewID && !!UIViewID[viewID]) {
- AppKernel.ui.open(viewID as UIViewID, params);
- return;
- }
- }
|