commit
186f53f634
@ -18,6 +18,7 @@ export type RouteKey =
|
|||||||
| 'document_vue'
|
| 'document_vue'
|
||||||
| 'document_vite'
|
| 'document_vite'
|
||||||
| 'document_naive'
|
| 'document_naive'
|
||||||
|
| 'document_project'
|
||||||
| 'plugin'
|
| 'plugin'
|
||||||
| 'plugin_map'
|
| 'plugin_map'
|
||||||
| 'plugin_video'
|
| 'plugin_video'
|
||||||
|
@ -22,6 +22,7 @@ import type { MenuOption } from 'naive-ui';
|
|||||||
import { useThemeStore, useAppStore } from '@/store';
|
import { useThemeStore, useAppStore } from '@/store';
|
||||||
import { menus } from '@/router';
|
import { menus } from '@/router';
|
||||||
import { GlobalMenuOption } from '@/interface';
|
import { GlobalMenuOption } from '@/interface';
|
||||||
|
import { isUrl } from '@/utils';
|
||||||
|
|
||||||
const theme = useThemeStore();
|
const theme = useThemeStore();
|
||||||
const app = useAppStore();
|
const app = useAppStore();
|
||||||
@ -49,7 +50,11 @@ function getActiveKeysInMenus(menu: GlobalMenuOption) {
|
|||||||
|
|
||||||
function handleUpdateMenu(_key: string, item: MenuOption) {
|
function handleUpdateMenu(_key: string, item: MenuOption) {
|
||||||
const menuItem = item as GlobalMenuOption;
|
const menuItem = item as GlobalMenuOption;
|
||||||
router.push(menuItem.routePath);
|
if (isUrl(menuItem.routePath)) {
|
||||||
|
window.open(menuItem.routePath, '__blank');
|
||||||
|
} else {
|
||||||
|
router.push(menuItem.routePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleUpdateExpandedKeys(keys: string[]) {
|
function handleUpdateExpandedKeys(keys: string[]) {
|
||||||
|
@ -107,6 +107,14 @@ const routeConstMap = new Map<RouteKey, RouteConst>([
|
|||||||
title: 'naive文档'
|
title: 'naive文档'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'document_project',
|
||||||
|
{
|
||||||
|
name: 'document_project',
|
||||||
|
path: 'https://docs.soybean.pro/',
|
||||||
|
title: '项目文档(外链)'
|
||||||
|
}
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'plugin',
|
'plugin',
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { RouteRecordRaw } from 'vue-router';
|
import type { RouteRecordRaw } from 'vue-router';
|
||||||
import { BasicLayout } from '@/layouts';
|
import { BasicLayout, BlankLayout } from '@/layouts';
|
||||||
import { DocumentVue, DocumentVite, DocumentNaive } from '@/views';
|
import { DocumentVue, DocumentVite, DocumentNaive } from '@/views';
|
||||||
import { routeName, routePath, routeTitle } from '../constant';
|
import { routeName, routePath, routeTitle } from '../constant';
|
||||||
|
|
||||||
@ -45,6 +45,16 @@ const document: RouteRecordRaw = {
|
|||||||
title: routeTitle('document_naive'),
|
title: routeTitle('document_naive'),
|
||||||
fullPage: true
|
fullPage: true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: routeName('document_project'),
|
||||||
|
path: routePath('document_project'),
|
||||||
|
component: BlankLayout,
|
||||||
|
meta: {
|
||||||
|
requiresAuth: true,
|
||||||
|
title: routeTitle('document_project'),
|
||||||
|
fullPage: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
@ -47,3 +47,10 @@ export function transformRouteToMenu(routes: RouteRecordRaw[]) {
|
|||||||
});
|
});
|
||||||
return globalMenu;
|
return globalMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 判断路由是否为Url链接 */
|
||||||
|
export function isUrl(path: string): boolean {
|
||||||
|
const reg =
|
||||||
|
/(((^https?:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
|
||||||
|
return reg.test(path);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user