All checks were successful
continuous-integration/drone/push Build is passing
- back-home-link 移到 #login/#regist 的 Vue 实例外面,不受 v-cloak 影响 - 过渡动画改用捕获阶段(true),比 Vue 先拦截 click - 加 transitioning 防抖,防止重复触发 - 暴露 window.__navigateTo() 供 Vue 编程式跳转使用
46 lines
1.8 KiB
PHP
46 lines
1.8 KiB
PHP
<!-- =======公共======= -->
|
|
<script src="/{$template_catalog}/template/{$public_themes}/utils/directive.js"></script>
|
|
<script src="/{$template_catalog}/template/{$public_themes}/js/common/axios.min.js"></script>
|
|
<script src="/{$template_catalog}/template/{$public_themes}/utils/request.js"></script>
|
|
<script src="/{$template_catalog}/template/{$public_themes}/api/common.js"></script>
|
|
<script src="/{$template_catalog}/template/{$themes}/components/coinActive/coinActive.js"></script>
|
|
<script src="/{$template_catalog}/template/{$public_themes}/components/asideMenu/asideMenu.js"></script>
|
|
<script src="/{$template_catalog}/template/{$public_themes}/components/topMenu/topMenu.js"></script>
|
|
|
|
<!-- 页面过渡动画 -->
|
|
<script>
|
|
(function() {
|
|
var transitioning = false;
|
|
|
|
function doTransition(href) {
|
|
if (transitioning || !href) return;
|
|
transitioning = true;
|
|
document.body.classList.add('page-leaving');
|
|
setTimeout(function() {
|
|
// 直接用原始赋值跳转
|
|
Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window.location), 'href')
|
|
? (window.location.href = href)
|
|
: (window.location = href);
|
|
}, 250);
|
|
}
|
|
|
|
// 1) 拦截 <a> 标签点击
|
|
document.addEventListener('click', function(e) {
|
|
var link = e.target.closest('a[href]');
|
|
if (!link) return;
|
|
var href = link.getAttribute('href');
|
|
if (!href || href.startsWith('#') || href.startsWith('javascript') ||
|
|
link.target === '_blank' || e.ctrlKey || e.metaKey || e.shiftKey) return;
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
doTransition(href);
|
|
}, true); // 用捕获阶段,比 Vue 先拦截
|
|
|
|
// 2) 暴露全局函数供 Vue 调用(覆盖常见跳转方法)
|
|
window.__navigateTo = function(href) { doTransition(href); };
|
|
})();
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|