UNPKG

ivue-material-plus

Version:

A high quality UI components Library with Vue.js

79 lines (76 loc) 1.76 kB
import { computed } from 'vue'; import { isClient } from '../helpers.mjs'; const mixinsLink = (proxy, { to, replace, target }) => { const linkUrl = computed(() => { const type = typeof to; if (type !== "string") { return null; } if (to.includes("//")) { return to; } const router = proxy.$router; if (router) { const current = proxy.$route; const route = router.resolve(to, current); return route ? route.href : to; } return to; }); const handleOpenTo = () => { if (!isClient) { return; } const router = proxy.$router; let _to = to; if (router) { const current = proxy.$route; const route = router.resolve(to, current); _to = route ? route.href : to; } if (typeof to === "string") { return; } window.open(_to); }; const handleLink = (newWindow = false) => { if (!isClient) { return; } if (newWindow) { handleOpenTo(); } else { const router = proxy.$router; if (router) { if (typeof to === "string" && to.includes("//")) { window.location.href = to; } else { replace ? proxy.$router.replace(to, () => { }) : proxy.$router.push(to, () => { }); } } else { window.location.href = to; } } }; const handleCheckClick = (event, newWindow = false) => { if (to) { if (target === "_blank") { handleOpenTo(); return false; } else { event.preventDefault(); handleLink(newWindow); } } }; return { linkUrl, handleOpenTo, handleLink, handleCheckClick }; }; export { mixinsLink }; //# sourceMappingURL=mixins-link.mjs.map