Skip to content

Commit

Permalink
feat: use global static share, allow select ip
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Apr 19, 2024
1 parent 17aeb51 commit a26e3cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pages/share.vue
Expand Up @@ -79,7 +79,10 @@ useSeoMeta(seoMeta)
const url = new URL(origin.value)
const hostname = url.hostname
const ips = getAllIps()
ips.push(hostname)
// 确保不会重复
if (!ips.includes(hostname)) {
ips.push(hostname)
}
// datas
const attrs = JsonUtil.safeParse<any>(post?.attrs ?? "{}", {})
Expand Down
3 changes: 2 additions & 1 deletion utils/urlUtil.ts
Expand Up @@ -75,8 +75,9 @@ export const getAllIps = () => {
}

const v4IPs = ips.filter((ip: string) => !ip.startsWith("[") && !ip.endsWith("]"))
logger.info("v4IPs =>", v4IPs)
const uniqueIPs = Array.from(new Set(v4IPs)) as any[]
logger.info("getAll v4Ips =>", uniqueIPs)
logger.info("uniqueIPs =>", uniqueIPs)
return uniqueIPs
}

Expand Down

0 comments on commit a26e3cf

Please sign in to comment.