UNPKG

ivue-material-plus

Version:

A high quality UI components Library with Vue.js

83 lines (78 loc) 1.86 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); var helpers = require('../helpers.js'); const mixinsLink = (proxy, { to, replace, target }) => { const linkUrl = vue.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 (!helpers.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 (!helpers.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 }; }; exports.mixinsLink = mixinsLink; //# sourceMappingURL=mixins-link.js.map