Browse Source

feat: 调整了useGo方法,让菜单可以跳转到外链接

main
LAPTOP-CNV4CMCJ\cheng 2 years ago
parent
commit
45604f5703
  1. 6
      src/hooks/web/usePage.ts

6
src/hooks/web/usePage.ts

@ -22,7 +22,11 @@ export function useGo(_router?: Router) {
if (!opt) {
return
}
isReplace ? replace(opt).catch(handleError) : push(opt).catch(handleError)
if (/^(https?:|mailto:|tel:)/.test(opt as string)) {
window.open(opt as string, '_blank', 'noopener=yes')
} else {
isReplace ? replace(opt).catch(handleError) : push(opt).catch(handleError)
}
}
return go
}