Skip to content

Commit

Permalink
style: code style lint
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzhang1030 committed Apr 28, 2022
1 parent 38c6fdc commit a1cfa85
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
7 changes: 3 additions & 4 deletions src/layouts/default/sidebar/components/MenuItem.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<a-menu-item
:key="parentPath ? `${parentPath}/${menu.path}` : menu.path"
<a-menu-item
:key="parentPath ? `${parentPath}/${menu.path}` : menu.path"
@click="handleClick(menu.path)"
>
<template #icon>
Expand All @@ -11,7 +11,7 @@
</template>
<script setup lang="ts">
import type { RouteModuleList } from '~/router/routes/typings'
import { isUrl } from '~/utils/is';
import { isUrl } from '~/utils/is'
interface Props {
menu: GetArrayItemType<RouteModuleList>
Expand All @@ -22,7 +22,6 @@ interface Props {
const props = defineProps<Props>()
const router = useRouter()
function handleClick(path: string) {
if (isUrl(path)) return window.open(path)
const routeMeta = props.menu.meta
Expand Down
2 changes: 1 addition & 1 deletion src/router/routes/plugins/dynamicRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useRouteStore } from '~/stores'
type RouteModule = GetArrayItemType<RouteModuleList>

function sortBySortKey(routerModuleList: RouteModuleList | RouteModule['children']) {
return routerModuleList.sort((a: RouteModule, b: RouteModule) => a.meta!.sort - b.meta!.sort)
return routerModuleList!.sort((a: RouteModule, b: RouteModule) => a.meta!.sort - b.meta!.sort)
}

function sortRoutesBySortKey(routerModuleList: RouteModuleList) {
Expand Down
8 changes: 4 additions & 4 deletions src/utils/is.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function isDef<T = unknown>(val?: T): val is T {
}

export function isUrl(url: string): boolean {
const reg =
/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$/i;
return reg.test(url);
}
const reg
= /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$/i
return reg.test(url)
}
4 changes: 2 additions & 2 deletions types/routes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ declare module 'vue-router' {
// 是否是单独的菜单
single?: boolean
// 路由携带参数
routeParams?: RouteLocationNormalized["params"]
routeQuery?: RouteLocationNormalized["query"]
routeParams?: RouteLocationNormalized['params']
routeQuery?: RouteLocationNormalized['query']
}
}

0 comments on commit a1cfa85

Please sign in to comment.