官网开发中 0731
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 链接解析:区分外部 URL 与站内路由
|
||||
*
|
||||
* 站内路由自动加当前语言前缀(中文无前缀,英文 /en 前缀)。
|
||||
*/
|
||||
export function useLinkResolver() {
|
||||
const localePath = useLocalePath();
|
||||
|
||||
function isExternal(link: string): boolean {
|
||||
return /^https?:\/\//.test(link);
|
||||
}
|
||||
|
||||
function resolveLink(link: string): string {
|
||||
if (!link) return '';
|
||||
if (isExternal(link)) return link;
|
||||
return localePath(link);
|
||||
}
|
||||
|
||||
return { isExternal, resolveLink };
|
||||
}
|
||||
Reference in New Issue
Block a user